Minor changes 33/52433/1
authorDavid <david.suarez.fuentes@ericsson.com>
Tue, 28 Feb 2017 23:25:08 +0000 (00:25 +0100)
committerDavid <david.suarez.fuentes@ericsson.com>
Tue, 28 Feb 2017 23:28:22 +0000 (00:28 +0100)
- Reorder modifiers
- Private constructor to avoid instantiation

Change-Id: I201648759962387c40e8f62960db16e530612e70
Signed-off-by: David <david.suarez.fuentes@ericsson.com>
aaa-authn/src/main/java/org/opendaylight/aaa/AuthenticationManager.java
aaa-authn/src/main/java/org/opendaylight/aaa/EqualUtil.java
aaa-authn/src/main/java/org/opendaylight/aaa/HashCodeUtil.java
aaa-authn/src/test/java/org/opendaylight/aaa/SecureBlockingQueueTest.java

index 5f6420a3df22c83fe227d20acb3b1439f74e6bfa..8b7e133e7ca2fe812f960231c6ab60ed83050504 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
+ * Copyright (c) 2014, 2017 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -31,7 +31,7 @@ public class AuthenticationManager implements AuthenticationService, ManagedServ
     // In non-Karaf environments, authEnabled is set to false by default
     private static volatile boolean authEnabled = false;
 
-    private final static AuthenticationManager am = new AuthenticationManager();
+    private static final AuthenticationManager am = new AuthenticationManager();
     private final ThreadLocal<Authentication> auth = new InheritableThreadLocal<>();
 
     private AuthenticationManager() {
index 17204d0e37c278f0ee8bae9745f4ba334dad0595..4c6ff10445b48ba2dba44ba31d6b2260bd50d30f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
+ * Copyright (c) 2014, 2017 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -16,27 +16,31 @@ package org.opendaylight.aaa;
  * <code>Arrays.equals</code> methods should be used for array fields.
  */
 public final class EqualUtil {
-    static public boolean areEqual(boolean aThis, boolean aThat) {
+
+    private EqualUtil () {
+    }
+
+    public static boolean areEqual(boolean aThis, boolean aThat) {
         return aThis == aThat;
     }
 
-    static public boolean areEqual(char aThis, char aThat) {
+    public static boolean areEqual(char aThis, char aThat) {
         return aThis == aThat;
     }
 
-    static public boolean areEqual(long aThis, long aThat) {
+    public static boolean areEqual(long aThis, long aThat) {
         return aThis == aThat;
     }
 
-    static public boolean areEqual(float aThis, float aThat) {
+    public static boolean areEqual(float aThis, float aThat) {
         return Float.floatToIntBits(aThis) == Float.floatToIntBits(aThat);
     }
 
-    static public boolean areEqual(double aThis, double aThat) {
+    public static boolean areEqual(double aThis, double aThat) {
         return Double.doubleToLongBits(aThis) == Double.doubleToLongBits(aThat);
     }
 
-    static public boolean areEqual(Object aThis, Object aThat) {
+    public static boolean areEqual(Object aThis, Object aThat) {
         return aThis == null ? aThat == null : aThis.equals(aThat);
     }
 }
index c295b3ed224b9a79bf448fcea5416b52a7cb37e3..bb4311834c2177ab65de1c4d581aaa51527c154f 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2014 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
+ * Copyright (c) 2014, 2017 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -35,6 +35,9 @@ public final class HashCodeUtil {
      */
     public static final int SEED = 23;
 
+    private HashCodeUtil() {
+    }
+
     /** booleans. */
     public static int hash(int aSeed, boolean aBoolean) {
         return firstTerm(aSeed) + (aBoolean ? 1 : 0);
@@ -52,7 +55,7 @@ public final class HashCodeUtil {
 
     /** longs. */
     public static int hash(int aSeed, long aLong) {
-        return firstTerm(aSeed) + (int) (aLong ^ (aLong >>> 32));
+        return firstTerm(aSeed) + (int) (aLong ^ aLong >>> 32);
     }
 
     /** floats. */
@@ -101,4 +104,4 @@ public final class HashCodeUtil {
     private static boolean isArray(Object aObject) {
         return aObject.getClass().isArray();
     }
-}
\ No newline at end of file
+}
index 16627d9f26381e4371c92e4d7153b69247e6103e..3655983b002ba32cae27f9c4b2e29e92d08ea78d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
+ * Copyright (c) 2014, 2017 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -30,7 +30,7 @@ import org.opendaylight.aaa.SecureBlockingQueue.SecureData;
 import org.opendaylight.aaa.api.Authentication;
 
 public class SecureBlockingQueueTest {
-    private final int MAX_TASKS = 100;
+    private static final int MAX_TASKS = 100;
 
     @Before
     public void setup() {
@@ -53,7 +53,7 @@ public class SecureBlockingQueueTest {
 
     @Test
     public void testNormalThreadPoolExecutor() throws InterruptedException, ExecutionException {
-        BlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(10);
+        BlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(10);
         ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 10, 500, TimeUnit.MILLISECONDS,
                 queue);
         executor.prestartAllCoreThreads();
@@ -84,11 +84,13 @@ public class SecureBlockingQueueTest {
     public void testCollectionOps() throws InterruptedException, ExecutionException {
         BlockingQueue<String> queue = new SecureBlockingQueue<>(
                 new ArrayBlockingQueue<SecureData<String>>(6));
-        for (int i = 1; i <= 3; i++)
+        for (int i = 1; i <= 3; i++) {
             queue.add("User" + i);
+        }
         Iterator<String> it = queue.iterator();
-        while (it.hasNext())
+        while (it.hasNext()) {
             assertTrue(it.next().startsWith("User"));
+        }
         assertEquals(3, queue.toArray().length);
         List<String> actual = Arrays.asList(queue.toArray(new String[0]));
         assertEquals("User1", actual.iterator().next());
@@ -184,8 +186,7 @@ public class SecureBlockingQueueTest {
         public String call() {
             queue.remove();
             Authentication auth = AuthenticationManager.instance().get();
-            return (auth == null) ? null : auth.user();
+            return auth == null ? null : auth.user();
         }
     }
-
 }