From 7376e919b83a467742eebb50c63deac6643cb28d Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 15 Oct 2015 13:56:03 +0200 Subject: [PATCH] =?utf8?q?use=20static,=20then=20it=20will=20remain=20ther?= =?utf8?q?e=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../validator/user/UserIdValidator.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/org/mxchange/addressbook/validator/user/UserIdValidator.java b/src/org/mxchange/addressbook/validator/user/UserIdValidator.java index ddd1ef76..17f76a7e 100644 --- a/src/org/mxchange/addressbook/validator/user/UserIdValidator.java +++ b/src/org/mxchange/addressbook/validator/user/UserIdValidator.java @@ -54,15 +54,7 @@ public class UserIdValidator extends BaseLongValidator implements Validator { /** * Cached user status */ - private final ConcurrentMap cachedStatus; - - /** - * Default constructor - */ - public UserIdValidator () { - // Init map - this.cachedStatus = new ConcurrentHashMap<>(0); - } + private static final ConcurrentMap cachedStatus = new ConcurrentHashMap<>(0); @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { @@ -82,15 +74,15 @@ public class UserIdValidator extends BaseLongValidator implements Validator { Boolean ifUserExists = false; // Is a map entry there? - if (this.cachedStatus.containsKey(userId)) { + if (UserIdValidator.cachedStatus.containsKey(userId)) { // Get from cache - ifUserExists = this.cachedStatus.get(userId); + ifUserExists = UserIdValidator.cachedStatus.get(userId); } else { // Get status ifUserExists = this.userBean.ifUserIdExists(userId); // Add to cache - this.cachedStatus.put(userId, ifUserExists); + UserIdValidator.cachedStatus.put(userId, ifUserExists); } // Is the address book id valid? @@ -128,6 +120,6 @@ public class UserIdValidator extends BaseLongValidator implements Validator { User registeredUser = event.getUser(); // Update cache - this.cachedStatus.put(registeredUser.getUserId(), Boolean.TRUE); + UserIdValidator.cachedStatus.put(registeredUser.getUserId(), Boolean.TRUE); } } -- 2.39.5