Remove EqualUtil 55/69655/1
authorStephen Kitt <skitt@redhat.com>
Tue, 20 Mar 2018 08:41:45 +0000 (09:41 +0100)
committerStephen Kitt <skitt@redhat.com>
Tue, 20 Mar 2018 08:41:45 +0000 (09:41 +0100)
This patch uses Objects.equals() instead. The equality checks are
preserved as-is.

Change-Id: Iaf3cd4723ddf17f38dd04c527b81ebd555b0df52
Signed-off-by: Stephen Kitt <skitt@redhat.com>
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/tokenauthrealm/auth/AuthenticationBuilder.java
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/tokenauthrealm/auth/ClaimBuilder.java
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/tokenauthrealm/auth/PasswordCredentialBuilder.java
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/tokenauthrealm/util/EqualUtil.java [deleted file]

index 93f3a1a79e9b6690b747a5bbaf42915dc75f4769..649484e9e3be519804fd0f0fa520cc3a5026fbc9 100644 (file)
@@ -12,7 +12,6 @@ import java.util.Objects;
 import java.util.Set;
 import org.opendaylight.aaa.api.Authentication;
 import org.opendaylight.aaa.api.Claim;
-import org.opendaylight.aaa.shiro.tokenauthrealm.util.EqualUtil;
 
 /**
  * A builder for the authentication context.
@@ -97,12 +96,12 @@ public class AuthenticationBuilder {
                 return false;
             }
             Authentication authentication = (Authentication) object;
-            return EqualUtil.areEqual(expiration, authentication.expiration()) && EqualUtil
-                    .areEqual(claim.roles(), authentication.roles()) && EqualUtil
-                    .areEqual(claim.domain(), authentication.domain()) && EqualUtil
-                    .areEqual(claim.userId(), authentication.userId()) && EqualUtil
-                    .areEqual(claim.user(), authentication.user()) && EqualUtil
-                    .areEqual(claim.clientId(), authentication.clientId());
+            return expiration == authentication.expiration()
+                    && Objects.equals(claim.roles(), authentication.roles())
+                    && Objects.equals(claim.domain(), authentication.domain())
+                    && Objects.equals(claim.userId(), authentication.userId())
+                    && Objects.equals(claim.user(), authentication.user())
+                    && Objects.equals(claim.clientId(), authentication.clientId());
         }
 
         @Override
index 35594b126bef4ef19116b1712c73e3d3610e9c20..10083cc269a168d1f7f023453b1402b9a1ce6fdc 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.aaa.shiro.tokenauthrealm.auth;
 
-import static org.opendaylight.aaa.shiro.tokenauthrealm.util.EqualUtil.areEqual;
-
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableSet;
 import java.io.Serializable;
@@ -133,9 +131,11 @@ public class ClaimBuilder {
                 return false;
             }
             Claim claim = (Claim) object;
-            return areEqual(roles, claim.roles()) && areEqual(domain, claim.domain())
-                    && areEqual(userId, claim.userId()) && areEqual(user, claim.user())
-                    && areEqual(clientId, claim.clientId());
+            return Objects.equals(roles, claim.roles())
+                    && Objects.equals(domain, claim.domain())
+                    && Objects.equals(userId, claim.userId())
+                    && Objects.equals(user, claim.user())
+                    && Objects.equals(clientId, claim.clientId());
         }
 
         @Override
index df42bb87fdb2e5d75df4d692dd8205b7e1df9e67..034cfe1f3c8329bec69675745e6c9a7cec656ba8 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.aaa.shiro.tokenauthrealm.auth;
 
 import java.util.Objects;
 import org.opendaylight.aaa.api.PasswordCredentials;
-import org.opendaylight.aaa.shiro.tokenauthrealm.util.EqualUtil;
 
 /**
  * {@link PasswordCredentials} builder.
@@ -68,8 +67,8 @@ public class PasswordCredentialBuilder {
                 return false;
             }
             PasswordCredentials passwordCredentials = (PasswordCredentials) object;
-            return EqualUtil.areEqual(username, passwordCredentials.username())
-                    && EqualUtil.areEqual(password, passwordCredentials.password());
+            return Objects.equals(username, passwordCredentials.username())
+                    && Objects.equals(password, passwordCredentials.password());
         }
 
         @Override
diff --git a/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/tokenauthrealm/util/EqualUtil.java b/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/tokenauthrealm/util/EqualUtil.java
deleted file mode 100644 (file)
index c5e6840..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.shiro.tokenauthrealm.util;
-
-/**
- * Simple class to aide in implementing equals.
- *
- * <p>
- * <em>Arrays are not handled by this class</em>. This is because the
- * <code>Arrays.equals</code> methods should be used for array fields.
- */
-public final class EqualUtil {
-
-    private EqualUtil() {
-    }
-
-    public static boolean areEqual(boolean c1, boolean c2) {
-        return c1 == c2;
-    }
-
-    public static boolean areEqual(char c1, char c2) {
-        return c1 == c2;
-    }
-
-    public static boolean areEqual(long c1, long c2) {
-        return c1 == c2;
-    }
-
-    public static boolean areEqual(float c1, float c2) {
-        return Float.floatToIntBits(c1) == Float.floatToIntBits(c2);
-    }
-
-    public static boolean areEqual(double c1, double c2) {
-        return Double.doubleToLongBits(c1) == Double.doubleToLongBits(c2);
-    }
-
-    public static boolean areEqual(Object c1, Object c2) {
-        return c1 == null ? c2 == null : c1.equals(c2);
-    }
-}