/*
- * 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,
// 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() {
/*
- * 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,
* <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);
}
}
/*****************************************************************************
- * 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,
*/
public static final int SEED = 23;
+ private HashCodeUtil() {
+ }
+
/** booleans. */
public static int hash(int aSeed, boolean aBoolean) {
return firstTerm(aSeed) + (aBoolean ? 1 : 0);
/** longs. */
public static int hash(int aSeed, long aLong) {
- return firstTerm(aSeed) + (int) (aLong ^ (aLong >>> 32));
+ return firstTerm(aSeed) + (int) (aLong ^ aLong >>> 32);
}
/** floats. */
private static boolean isArray(Object aObject) {
return aObject.getClass().isArray();
}
-}
\ No newline at end of file
+}
/*
- * 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,
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() {
@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();
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());
public String call() {
queue.remove();
Authentication auth = AuthenticationManager.instance().get();
- return (auth == null) ? null : auth.user();
+ return auth == null ? null : auth.user();
}
}
-
}