From 489a6290823086a928474bbe4979ccd2dc405187 Mon Sep 17 00:00:00 2001 From: Driptaroop Das Date: Tue, 9 Apr 2019 01:01:39 +0530 Subject: Future.java - sonar fixes Future.java - sonar fixes Issue-ID: AAF-807 Change-Id: I1d94cf7db94f3e5a15fe61be72d23e0ea6084bdb Signed-off-by: Driptaroop Das --- .../org/onap/aaf/auth/batch/helpers/Future.java | 45 +++++++++------------- 1 file changed, 18 insertions(+), 27 deletions(-) (limited to 'auth/auth-batch/src/main/java/org') diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Future.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Future.java index 4f87e330..74c3411f 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Future.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Future.java @@ -93,18 +93,16 @@ public class Future implements CacheChange.Data, Comparable { fdd.expires = expires; fdd.construct = construct; String role = null; - switch(target) { - case "user_role": - UserRoleDAO.Data urdd = new UserRoleDAO.Data(); - try { - urdd.reconstitute(construct); - fdd.target_key = urdd.user + '|' + urdd.role; - fdd.target_date=urdd.expires; - role=urdd.role; - } catch (IOException e) { - e.printStackTrace(System.err); - } - break; + if ("user_role".equals(target)) { + UserRoleDAO.Data urdd = new UserRoleDAO.Data(); + try { + urdd.reconstitute(construct); + fdd.target_key = urdd.user + '|' + urdd.role; + fdd.target_date = urdd.expires; + role = urdd.role; + } catch (IOException e) { + e.printStackTrace(System.err); + } } this.role = role; } @@ -130,21 +128,14 @@ public class Future implements CacheChange.Data, Comparable { } public static void load(Trans trans, Session session, Creator creator) { - load(trans,session,creator, new Visitor() { - @Override - public void visit(Future f) { - data.put(f.fdd.id,f); - if (f.role==null) { - return; - } - List lf = byRole.get(f.role); - if (lf==null) { - lf = new ArrayList<>(); - byRole.put(f.role,lf); - } - lf.add(f); - } - }); + load(trans,session,creator, f -> { + data.put(f.fdd.id,f); + if (f.role==null) { + return; + } + List lf = byRole.computeIfAbsent(f.role, k -> new ArrayList<>()); + lf.add(f); + }); } -- cgit 1.2.3-korg