Improve LocalProxyTransaction.doExists()
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / identifiers / ShardIdentifier.java
index fc3aa592f97ce44063149d449e320073d330c8ed..7c206adc5859cc5117894ee72eb6e5bb1f62db9a 100644 (file)
@@ -5,10 +5,11 @@
  * 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.controller.cluster.datastore.identifiers;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
@@ -23,10 +24,10 @@ public class ShardIdentifier {
     private final String type;
     private final String fullName;
 
-    private ShardIdentifier(String shardName, MemberName memberName, String type) {
-        this.shardName = Preconditions.checkNotNull(shardName, "shardName should not be null");
-        this.memberName = Preconditions.checkNotNull(memberName, "memberName should not be null");
-        this.type = Preconditions.checkNotNull(type, "type should not be null");
+    ShardIdentifier(final String shardName, final MemberName memberName, final String type) {
+        this.shardName = requireNonNull(shardName, "shardName should not be null");
+        this.memberName = requireNonNull(memberName, "memberName should not be null");
+        this.type = requireNonNull(type, "type should not be null");
 
         fullName = memberName.getName() + "-shard-" + shardName + "-" + type;
     }
@@ -37,21 +38,21 @@ public class ShardIdentifier {
 
     public static ShardIdentifier fromShardIdString(final String shardIdString) {
         final Matcher matcher = PATTERN.matcher(shardIdString);
-        Preconditions.checkArgument(matcher.matches(), "Invalid shard id \"%s\"", shardIdString);
+        checkArgument(matcher.matches(), "Invalid shard id \"%s\"", shardIdString);
 
         return new ShardIdentifier(matcher.group(2), MemberName.forName(matcher.group(1)), matcher.group(3));
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) {
+    public boolean equals(final Object obj) {
+        if (this == obj) {
             return true;
         }
-        if (o == null || getClass() != o.getClass()) {
+        if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
 
-        ShardIdentifier that = (ShardIdentifier) o;
+        ShardIdentifier that = (ShardIdentifier) obj;
 
         if (!memberName.equals(that.memberName)) {
             return false;
@@ -97,26 +98,26 @@ public class ShardIdentifier {
         private MemberName memberName;
         private String type;
 
-        public ShardIdentifier build(){
+        public ShardIdentifier build() {
             return new ShardIdentifier(shardName, memberName, type);
         }
 
-        public Builder shardName(String shardName){
-            this.shardName = shardName;
+        public Builder shardName(final String newShardName) {
+            this.shardName = newShardName;
             return this;
         }
 
-        public Builder memberName(MemberName memberName){
-            this.memberName = memberName;
+        public Builder memberName(final MemberName newMemberName) {
+            this.memberName = newMemberName;
             return this;
         }
 
-        public Builder type(String type){
-            this.type = type;
+        public Builder type(final String newType) {
+            this.type = newType;
             return this;
         }
 
-        public Builder fromShardIdString(String shardId){
+        public Builder fromShardIdString(final String shardId) {
             Matcher matcher = PATTERN.matcher(shardId);
 
             if (matcher.matches()) {