Fix ShardIdentifier warning 15/14515/3
authorRobert Varga <rovarga@cisco.com>
Mon, 26 Jan 2015 18:08:24 +0000 (19:08 +0100)
committerRobert Varga <rovarga@cisco.com>
Wed, 28 Jan 2015 16:18:59 +0000 (17:18 +0100)
The format string should be a constant, but we are not using it anyway.
Let's remmove it altogether and expand the corresponding comment.

Change-Id: I53245be3163ed3a874d14ddf981455dcd58c4ceb
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java

index d65af61ba3f8a957b6f67bdc355035fa93297431..5053d47f84e6fff6f0ab8aa33521dc23fbf45e4d 100644 (file)
@@ -9,19 +9,18 @@
 package org.opendaylight.controller.cluster.datastore.identifiers;
 
 import com.google.common.base.Preconditions;
-
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 public class ShardIdentifier {
+    // This pattern needs to remain in sync with toString(), which produces
+    // strings with corresponding to "%s-shard-%s-%s"
+    private static final Pattern PATTERN = Pattern.compile("(\\S+)-shard-(\\S+)-(\\S+)");
+
     private final String shardName;
     private final String memberName;
     private final String type;
 
-    //format and pattern should be in sync
-    private final String format = "%s-shard-%s-%s";
-    private static final Pattern pattern = Pattern.compile("(\\S+)-shard-(\\S+)-(\\S+)");
-
     public ShardIdentifier(String shardName, String memberName, String type) {
 
         Preconditions.checkNotNull(shardName, "shardName should not be null");
@@ -116,7 +115,7 @@ public class ShardIdentifier {
         }
 
         public Builder fromShardIdString(String shardId){
-            Matcher matcher = pattern.matcher(shardId);
+            Matcher matcher = PATTERN.matcher(shardId);
 
             if (matcher.matches()) {
                 memberName = matcher.group(1);