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 8d5536f9245b29335c51e6d94e5a87f755ad99d9..620b2eb422bfb5576c7f8dc73fd74e631c45aa74 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 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;
 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.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;
 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();
 
         // 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(),
            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);
         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.
             // 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 fcc325e8d77ff49950dd6e8b78e31a2729805028..403f19b6239fd1f9543535db1cc4d737cf8f3a60 100644 (file)
@@ -8,11 +8,11 @@
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.createEntity;
 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 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;
 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);
 
 
             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());
                 boolean hasOwner = !Strings.isNullOrEmpty(newOwner);
 
                 Entity entity = createEntity(change.getRootPath());
index a37a94fd0ec860cbb2de342c3f144d627b6b8cf7..42636ca108315e376c04f9830d21fad5d24dda19 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 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 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;
 import java.util.Set;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
@@ -155,7 +155,7 @@ final class ShardInformation {
     }
 
     boolean isLeader() {
     }
 
     boolean isLeader() {
-        return Objects.equal(leaderId, shardId.toString());
+        return Objects.equals(leaderId, shardId.toString());
     }
 
     String getSerializedLeaderActor() {
     }
 
     String getSerializedLeaderActor() {
@@ -224,7 +224,7 @@ final class ShardInformation {
     }
 
     boolean setLeaderId(String leaderId) {
     }
 
     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;
         this.leaderId = leaderId;
         if(leaderId != null) {
             this.leaderAvailable = true;
index e45604b5febaf437428f7ac3eadf12cab159bb28..ec96cf478300e2074b9e43c62cf4bcbca3d449b2 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 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;
 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.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;
 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()) {
                 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;
                     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;
                         found = true;
                     } else if(expReply instanceof Class && ((Class<?>)expReply).isInstance(actual)) {
                         found = true;