Fix ALOTOF Checkstyle violation, and switch over to enforcement.
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / schema / ColumnType.java
index 85c4417eaa2127dbd3d1b5d21f163f90da1be88d..faa32f9d81f06351c012fe89f10d24423fee82cc 100644 (file)
@@ -8,13 +8,12 @@
 
 package org.opendaylight.ovsdb.lib.schema;
 
+import com.fasterxml.jackson.databind.JsonNode;
 import org.opendaylight.ovsdb.lib.error.TyperException;
 import org.opendaylight.ovsdb.lib.jsonrpc.JsonUtils;
 import org.opendaylight.ovsdb.lib.notation.OvsdbMap;
 import org.opendaylight.ovsdb.lib.notation.OvsdbSet;
 
-import com.fasterxml.jackson.databind.JsonNode;
-
 
 public abstract class ColumnType {
     BaseType baseType;
@@ -56,6 +55,8 @@ public abstract class ColumnType {
     }
 
     /**
+     * JSON.
+     * <pre>
             "type": {
                 "key": {
                      "maxInteger": 4294967295,
@@ -68,9 +69,7 @@ public abstract class ColumnType {
                     "refTable": "Queue"
                  },
                  "max": "unlimited"
-            }
-     * @param json
-     * @return
+            }</pre>
      */
     public static ColumnType fromJson(JsonNode json) {
         for (ColumnType colType : columns) {
@@ -86,11 +85,10 @@ public abstract class ColumnType {
 
 
     /**
-     * Creates a ColumnType from the JsonNode if the implementation  knows how to, returns null otherwise
+     * Creates a ColumnType from the JsonNode if the implementation  knows how to, returns null otherwise.
      *
      * @param json the JSONNode object that needs to converted
-     * @return a valid SubType or Null (if the JsonNode does not represent
-     * the subtype)
+     * @return a valid SubType or Null (if the JsonNode does not represent the subtype)
      */
     protected abstract ColumnType fromJsonNode(JsonNode json);
 
@@ -164,8 +162,8 @@ public abstract class ColumnType {
         public AtomicColumnType() {
         }
 
-        public AtomicColumnType(BaseType baseType1) {
-            super(baseType1);
+        public AtomicColumnType(BaseType baseType) {
+            super(baseType);
         }
 
         @Override
@@ -173,11 +171,11 @@ public abstract class ColumnType {
             if (json.isObject() && json.has("value")) {
                 return null;
             }
-            BaseType baseType = BaseType.fromJson(json, "key");
+            BaseType jsonBaseType = BaseType.fromJson(json, "key");
 
-            if (baseType != null) {
+            if (jsonBaseType != null) {
 
-                AtomicColumnType atomicColumnType = new AtomicColumnType(baseType);
+                AtomicColumnType atomicColumnType = new AtomicColumnType(jsonBaseType);
 
                 JsonNode node;
                 if ((node = json.get("min")) != null) {
@@ -247,10 +245,10 @@ public abstract class ColumnType {
             if (json.isValueNode() || !json.has("value")) {
                 return null;
             }
-            BaseType keyType = BaseType.fromJson(json, "key");
+            BaseType jsonKeyType = BaseType.fromJson(json, "key");
             BaseType valueType = BaseType.fromJson(json, "value");
 
-            KeyValuedColumnType keyValueColumnType = new KeyValuedColumnType(keyType, valueType);
+            KeyValuedColumnType keyValueColumnType = new KeyValuedColumnType(jsonKeyType, valueType);
             JsonNode node;
             if ((node = json.get("min")) != null) {
                 keyValueColumnType.setMin(node.asLong());
@@ -269,21 +267,19 @@ public abstract class ColumnType {
 
         @Override
         public Object valueFromJson(JsonNode node) {
-            if (node.isArray()) {
-                if (node.size() == 2) {
-                    if (node.get(0).isTextual() && "map".equals(node.get(0).asText())) {
-                        OvsdbMap<Object, Object> map = new OvsdbMap<>();
-                        for (JsonNode pairNode : node.get(1)) {
-                            if (pairNode.isArray() && node.size() == 2) {
-                                Object key = getKeyType().toValue(pairNode.get(0));
-                                Object value = getBaseType().toValue(pairNode.get(1));
-                                map.put(key, value);
-                            }
+            if (node.isArray() && node.size() == 2) {
+                if (node.get(0).isTextual() && "map".equals(node.get(0).asText())) {
+                    OvsdbMap<Object, Object> map = new OvsdbMap<>();
+                    for (JsonNode pairNode : node.get(1)) {
+                        if (pairNode.isArray() && node.size() == 2) {
+                            Object key = getKeyType().toValue(pairNode.get(0));
+                            Object value = getBaseType().toValue(pairNode.get(1));
+                            map.put(key, value);
                         }
-                        return map;
-                    } else if (node.size() == 0) {
-                        return null;
                     }
+                    return map;
+                } else if (node.size() == 0) {
+                    return null;
                 }
             }
             return null;