Fix modernization issues
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / BackendInfo.java
index bdffb08c3eb81bf576d3420520db7ef814942013..891de52fb5a48ecf9b132f7d55c80ced68b6b047 100644 (file)
@@ -7,19 +7,22 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 
 /**
  * Basic information about how to talk to the backend. ClientActorBehavior uses this information to dispatch requests
  * to the backend.
  *
+ * <p>
  * This class is not final so concrete actor behavior implementations may subclass it and track more information about
  * the backend. The {@link #hashCode()} and {@link #equals(Object)} methods are made final to ensure subclasses compare
- * on identity.
+ * on object identity.
  *
  * @author Robert Varga
  */
@@ -28,11 +31,14 @@ public class BackendInfo {
     private final ActorRef actor;
     private final int maxMessages;
     private final long sessionId;
+    private final String name;
 
-    protected BackendInfo(final ActorRef actor, final long sessionId, final ABIVersion version, final int maxMessages) {
-        this.version = Preconditions.checkNotNull(version);
-        this.actor = Preconditions.checkNotNull(actor);
-        Preconditions.checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
+    protected BackendInfo(final ActorRef actor, final String name, final long sessionId, final ABIVersion version,
+            final int maxMessages) {
+        this.version = requireNonNull(version);
+        this.actor = requireNonNull(actor);
+        this.name = requireNonNull(name);
+        checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
         this.maxMessages = maxMessages;
         this.sessionId = sessionId;
     }
@@ -41,6 +47,10 @@ public class BackendInfo {
         return actor;
     }
 
+    public final String getName() {
+        return name;
+    }
+
     public final ABIVersion getVersion() {
         return version;
     }
@@ -65,7 +75,7 @@ public class BackendInfo {
 
     @Override
     public final String toString() {
-        return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
+        return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
     }
 
     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {