Fix CS warnings in sal-clustering-commons and enable enforcement
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / NodeIdentifierFactory.java
index 08fd997aae4c936a33fa56eb26009b462ad8e7e3..acfb05fc389fe3d16bdc3d9d53b3610bbf061f77 100644 (file)
@@ -8,43 +8,43 @@
 
 package org.opendaylight.controller.cluster.datastore.node.utils;
 
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-
 import java.util.HashMap;
 import java.util.Map;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
 public class NodeIdentifierFactory {
-    private static final Map<String, YangInstanceIdentifier.PathArgument> cache = new HashMap<>();
-    public static YangInstanceIdentifier.PathArgument getArgument(String id){
-        YangInstanceIdentifier.PathArgument value = cache.get(id);
-        if(value == null){
-            synchronized (cache){
-                value = cache.get(id);
-                if(value == null) {
+    private static final Map<String, YangInstanceIdentifier.PathArgument> CACHE = new HashMap<>();
+
+    public static YangInstanceIdentifier.PathArgument getArgument(String id) {
+        YangInstanceIdentifier.PathArgument value = CACHE.get(id);
+        if (value == null) {
+            synchronized (CACHE) {
+                value = CACHE.get(id);
+                if (value == null) {
                     value = createPathArgument(id, null);
-                    cache.put(id, value);
+                    CACHE.put(id, value);
                 }
             }
         }
         return value;
     }
 
-    public static YangInstanceIdentifier.PathArgument createPathArgument(String id, DataSchemaNode schemaNode){
+    public static YangInstanceIdentifier.PathArgument createPathArgument(String id, DataSchemaNode schemaNode) {
         final NodeIdentifierWithPredicatesGenerator
             nodeIdentifierWithPredicatesGenerator = new NodeIdentifierWithPredicatesGenerator(id, schemaNode);
-        if(nodeIdentifierWithPredicatesGenerator.matches()){
+        if (nodeIdentifierWithPredicatesGenerator.matches()) {
             return nodeIdentifierWithPredicatesGenerator.getPathArgument();
         }
 
         final NodeIdentifierWithValueGenerator
             nodeWithValueGenerator = new NodeIdentifierWithValueGenerator(id, schemaNode);
-        if(nodeWithValueGenerator.matches()){
+        if (nodeWithValueGenerator.matches()) {
             return nodeWithValueGenerator.getPathArgument();
         }
 
         final AugmentationIdentifierGenerator augmentationIdentifierGenerator = new AugmentationIdentifierGenerator(id);
-        if(augmentationIdentifierGenerator.matches()){
+        if (augmentationIdentifierGenerator.matches()) {
             return augmentationIdentifierGenerator.getPathArgument();
         }