Use java.util.Objects instead of Guava 82/36682/5
authorRobert Varga <rovarga@cisco.com>
Wed, 23 Mar 2016 19:41:25 +0000 (20:41 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 30 Mar 2016 15:18:34 +0000 (15:18 +0000)
Java 8 gives us a Objects.equals(), so stop using Guava.

Change-Id: I319d01c3d1d8abeaa2da4a38286e024f3055996b
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardInformation.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java

index 8d5536f..620b2eb 100644 (file)
@@ -14,7 +14,6 @@ import akka.actor.ActorSelection;
 import akka.actor.PoisonPill;
 import akka.japi.Procedure;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Objects;
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import java.io.Serializable;
@@ -22,6 +21,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Supplier;
 import javax.annotation.Nonnull;
@@ -436,7 +436,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
 
         // it can happen that the state has not changed but the leader has changed.
         Optional<ActorRef> roleChangeNotifier = getRoleChangeNotifier();
-        if(!Objects.equal(lastValidLeaderId, currentBehavior.getLeaderId()) ||
+        if(!Objects.equals(lastValidLeaderId, currentBehavior.getLeaderId()) ||
            oldBehaviorState.getLeaderPayloadVersion() != currentBehavior.getLeaderPayloadVersion()) {
             if(roleChangeNotifier.isPresent()) {
                 roleChangeNotifier.get().tell(newLeaderStateChanged(getId(), currentBehavior.getLeaderId(),
@@ -605,7 +605,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
         LOG.debug("{}: RaftPolicy used with prev.config {}, RaftPolicy used with newConfig {}", persistenceId(),
             oldRaftPolicy, newRaftPolicy);
         context.setConfigParams(configParams);
-        if (!Objects.equal(oldRaftPolicy, newRaftPolicy)) {
+        if (!Objects.equals(oldRaftPolicy, newRaftPolicy)) {
             // The RaftPolicy was modified. If the current behavior is Follower then re-initialize to Follower
             // but transfer the previous leaderId so it doesn't immediately try to schedule an election. This
             // avoids potential disruption. Otherwise, switch to Follower normally.
index fcc325e..403f19b 100644 (file)
@@ -8,11 +8,11 @@
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.createEntity;
-import com.google.common.base.Objects;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import java.util.Collection;
+import java.util.Objects;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -55,9 +55,9 @@ class EntityOwnerChangeListener extends AbstractEntityOwnerChangeListener {
 
             LOG.debug("{}: New owner: {}, Original owner: {}", logId(), newOwner, origOwner);
 
-            if(!Objects.equal(origOwner, newOwner)) {
-                boolean isOwner = Objects.equal(localMemberName, newOwner);
-                boolean wasOwner = Objects.equal(localMemberName, origOwner);
+            if(!Objects.equals(origOwner, newOwner)) {
+                boolean isOwner = Objects.equals(localMemberName, newOwner);
+                boolean wasOwner = Objects.equals(localMemberName, origOwner);
                 boolean hasOwner = !Strings.isNullOrEmpty(newOwner);
 
                 Entity entity = createEntity(change.getRootPath());
index a37a94f..42636ca 100644 (file)
@@ -10,13 +10,13 @@ package org.opendaylight.controller.cluster.datastore.shardmanager;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.serialization.Serialization;
-import com.google.common.base.Objects;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
@@ -155,7 +155,7 @@ final class ShardInformation {
     }
 
     boolean isLeader() {
-        return Objects.equal(leaderId, shardId.toString());
+        return Objects.equals(leaderId, shardId.toString());
     }
 
     String getSerializedLeaderActor() {
@@ -224,7 +224,7 @@ final class ShardInformation {
     }
 
     boolean setLeaderId(String leaderId) {
-        boolean changed = !Objects.equal(this.leaderId, leaderId);
+        boolean changed = !Objects.equals(this.leaderId, leaderId);
         this.leaderId = leaderId;
         if(leaderId != null) {
             this.leaderAvailable = true;
index e45604b..ec96cf4 100644 (file)
@@ -26,7 +26,6 @@ import akka.testkit.JavaTestKit;
 import akka.util.Timeout;
 import com.codahale.metrics.MetricRegistry;
 import com.codahale.metrics.Timer;
-import com.google.common.base.Objects;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.CheckedFuture;
@@ -37,6 +36,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -450,8 +450,7 @@ public abstract class AbstractTransactionProxyTest {
                 }
             }
 
-            for(int i = 0; i < expReplies.length; i++) {
-                Object expReply = expReplies[i];
+            for (Object expReply : expReplies) {
                 boolean found = false;
                 Iterator<?> iter = futureResults.iterator();
                 while(iter.hasNext()) {
@@ -459,7 +458,7 @@ public abstract class AbstractTransactionProxyTest {
                     if(CommitTransactionReply.isSerializedType(expReply) &&
                        CommitTransactionReply.isSerializedType(actual)) {
                         found = true;
-                    } else if(expReply instanceof ActorSelection && Objects.equal(expReply, actual)) {
+                    } else if(expReply instanceof ActorSelection && Objects.equals(expReply, actual)) {
                         found = true;
                     } else if(expReply instanceof Class && ((Class<?>)expReply).isInstance(actual)) {
                         found = true;