Checkstyle fixes (to be enforced) 44/42344/2
authorMichael Vorburger <vorburger@redhat.com>
Fri, 22 Jul 2016 21:05:19 +0000 (23:05 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Fri, 22 Jul 2016 22:12:04 +0000 (00:12 +0200)
preparing for https://git.opendaylight.org/gerrit/#/c/41305/ with:
  * Utility classes should have private constructor
  * potential future problems re. hidden fields
  * inner assignments

Change-Id: I616414ed56e468910167a790b5e67a6807600f37
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/FutureTransformUtils.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbClientImpl.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcDecoder.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonUtils.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/message/MonitorRequestBuilder.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/message/TableUpdate.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/notation/Column.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/schema/BaseType.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/schema/ColumnSchema.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/schema/ColumnType.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/schema/TableSchema.java

index 2bf2679397689a4204bae7787490003ff3b6bcc6..374421e517dfce6e1e12c2f5c3f055ecb522e800 100644 (file)
@@ -22,6 +22,9 @@ import org.opendaylight.ovsdb.lib.operations.OperationResult;
 public class FutureTransformUtils {
     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
 
+    private FutureTransformUtils() {
+    }
+
     public static final ListenableFuture<List<OperationResult>> transformTransactResponse(
             ListenableFuture<List<JsonNode>> transactResponseFuture, final List<Operation> operations) {
         OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
index 89a7a1ff619af6b6253c8f8411470f3afac22335..2560c7192a483412292e31bf0b12f1290a9b2fb6 100644 (file)
@@ -63,7 +63,7 @@ public class OvsdbClientImpl implements OvsdbClient {
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbClientImpl.class);
     private ExecutorService executorService;
     private OvsdbRPC rpc;
-    private Map<String, DatabaseSchema> schema = Maps.newHashMap();
+    private Map<String, DatabaseSchema> schemas = Maps.newHashMap();
     private Map<String, CallbackContext> monitorCallbacks = Maps.newHashMap();
     private OvsdbRPC.Callback rpcCallback;
     private OvsdbConnectionInfo connectionInfo;
@@ -86,7 +86,7 @@ public class OvsdbClientImpl implements OvsdbClient {
     }
 
     /**
-     * Genereate the threadFactory based on ACTIVE, PASSIVE (SSL/NON-SSL) connection type.
+     * Generate the threadFactory based on ACTIVE, PASSIVE (SSL/NON-SSL) connection type.
      * @param type ACTIVE or PASSIVE {@link ConnectionType}
      * @param socketConnType SSL or NON-SSL {@link SocketConnectionType}
      * @param executorNameArgs Additional args to append to thread name format
@@ -158,7 +158,7 @@ public class OvsdbClientImpl implements OvsdbClient {
             for (Iterator<Map.Entry<String,JsonNode>> itr = updatesJson.fields(); itr.hasNext();) {
                 Map.Entry<String, JsonNode> entry = itr.next();
 
-                DatabaseSchema databaseSchema = this.schema.get(dbSchema.getName());
+                DatabaseSchema databaseSchema = this.schemas.get(dbSchema.getName());
                 TableSchema table = databaseSchema.table(entry.getKey(), TableSchema.class);
                 tableUpdateMap.put(entry.getKey(), table.updatesFromJson(entry.getValue()));
 
@@ -310,7 +310,7 @@ public class OvsdbClientImpl implements OvsdbClient {
 
     public boolean isReady(int timeout) throws InterruptedException {
         while (timeout > 0) {
-            if (!schema.isEmpty()) {
+            if (!schemas.isEmpty()) {
                 return true;
             }
             Thread.sleep(1000);
@@ -327,7 +327,7 @@ public class OvsdbClientImpl implements OvsdbClient {
     @Override
     public ListenableFuture<DatabaseSchema> getSchema(final String database) {
 
-        DatabaseSchema databaseSchema = schema.get(database);
+        DatabaseSchema databaseSchema = schemas.get(database);
 
         if (databaseSchema == null) {
             return Futures.transform(
@@ -338,7 +338,7 @@ public class OvsdbClientImpl implements OvsdbClient {
                             if (result.containsKey(database)) {
                                 DatabaseSchema dbSchema = result.get(database);
                                 dbSchema.populateInternallyGeneratedColumns();
-                                OvsdbClientImpl.this.schema.put(database, dbSchema);
+                                OvsdbClientImpl.this.schemas.put(database, dbSchema);
                                 return dbSchema;
                             } else {
                                 return null;
@@ -401,7 +401,7 @@ public class OvsdbClientImpl implements OvsdbClient {
 
     @Override
     public DatabaseSchema getDatabaseSchema(String dbName) {
-        return schema.get(dbName);
+        return schemas.get(dbName);
     }
 
     /**
index 8aa082e4ef9505f4ba59a61a17114f49b4aba355..b8e3e29cf593d0d7beb6a3666aea84b192733d1f 100644 (file)
@@ -109,7 +109,9 @@ public class JsonRpcDecoder extends ByteToMessageDecoder {
                 JsonParser jp = jacksonJsonFactory.createParser(new ByteBufInputStream(slice));
                 JsonNode root = jp.readValueAsTree();
                 out.add(root);
-                leftCurlies = rightCurlies = lastRecordBytes = 0;
+                leftCurlies = 0;
+                rightCurlies = 0;
+                lastRecordBytes = 0;
                 recordsRead++;
                 break;
             }
index 6b507139baf7dccdb862bf6b551c897a0b9d81e9..3b4c542978dedab7043f251be32d4c4f71314635 100644 (file)
@@ -5,19 +5,19 @@
  * 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.ovsdb.lib.jsonrpc;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectWriter;
 
-
 public class JsonUtils {
 
-    static ObjectMapper mapper = new ObjectMapper();
+    private static ObjectMapper mapper = new ObjectMapper();
+    private static ObjectWriter prettyWriter = mapper.writerWithDefaultPrettyPrinter();
 
-    static ObjectWriter prettyWriter = mapper.writerWithDefaultPrettyPrinter();
+    private JsonUtils() {
+    }
 
     public static String prettyString(Object jsonNode) {
         try {
index 0a10991d86e03a64718a5ff1218fde62c02b2e29..cc5e36809e1c47cced738ae8e5956792ee4cf75b 100644 (file)
@@ -60,11 +60,11 @@ public class MonitorRequestBuilder<E extends TableSchema<E>> {
     }
 
     public MonitorRequest build() {
-        MonitorRequest monitorRequest = getMonitorRequest();
-        if (monitorRequest.getSelect() == null) {
-            monitorRequest.setSelect(new MonitorSelect());
+        MonitorRequest newBuiltMonitorRequest = getMonitorRequest();
+        if (newBuiltMonitorRequest.getSelect() == null) {
+            newBuiltMonitorRequest.setSelect(new MonitorSelect());
         }
-        monitorRequest.setTableName(tableSchema.getName());
-        return monitorRequest;
+        newBuiltMonitorRequest.setTableName(tableSchema.getName());
+        return newBuiltMonitorRequest;
     }
 }
index ec10b71c4c5f8835c5de3fc0b88530cb489ef122..180192f89b76664c0a9c7d123e4b7f01b5ccc07e 100644 (file)
@@ -40,14 +40,15 @@ public class TableUpdate<E extends TableSchema<E>> {
             return oldRow;
         }
 
-        public void setOld(Row<E> oldRow) {
-            this.oldRow = oldRow;
+        public void setOld(Row<E> old) {
+            this.oldRow = old;
         }
 
         public Row<E> getNew() {
             return newRow;
         }
 
+        @SuppressWarnings("checkstyle:HiddenField")
         public void setNew(Row<E> newRow) {
             this.newRow = newRow;
         }
index 006334f28135654796697d324605a2c6395c755f..65aeb6600e9cb3b10b3a20406355e055d0ad6afa 100644 (file)
@@ -5,15 +5,12 @@
  * 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.ovsdb.lib.notation;
 
-
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
 import org.opendaylight.ovsdb.lib.schema.TableSchema;
 
-
 public class Column<E extends TableSchema<E>, D> {
     @JsonIgnore
     private ColumnSchema<E, D> schema;
@@ -24,8 +21,8 @@ public class Column<E extends TableSchema<E>, D> {
         this.data = data;
     }
 
-    public <E extends TableSchema<E>, T> T getData(ColumnSchema<E, T> schema) {
-        return schema.validate(data);
+    public <E extends TableSchema<E>, T> T getData(ColumnSchema<E, T> anotherSchema) {
+        return anotherSchema.validate(data);
     }
 
     public D getData() {
index 2e0e483bdd86053fa30bb937f783c70c7e77820c..f3fb5cd0ed3343509c99b7e5eb5a95f549bf926d 100644 (file)
@@ -93,17 +93,14 @@ public abstract class BaseType<E extends BaseType<E>> {
 
         @Override
         protected void getConstraints(IntegerBaseType baseType, JsonNode type) {
-
-            JsonNode node = null;
-
-            if ((node = type.get("maxInteger")) != null) {
-                baseType.setMax(node.asLong());
+            JsonNode typeMaxNode = type.get("maxInteger");
+            if (typeMaxNode != null) {
+                baseType.setMax(typeMaxNode.asLong());
             }
-
-            if ((node = type.get("minInteger")) != null) {
-                baseType.setMin(node.asLong());
+            JsonNode typeMinNode = type.get("minInteger");
+            if (typeMinNode != null) {
+                baseType.setMin(typeMinNode.asLong());
             }
-
             populateEnum(type);
         }
 
@@ -119,10 +116,10 @@ public abstract class BaseType<E extends BaseType<E>> {
 
         private void populateEnum(JsonNode node) {
             if (node.has("enum")) {
-                Set<Long> enums = Sets.newHashSet();
+                Set<Long> nodesEnums = Sets.newHashSet();
                 JsonNode anEnum = node.get("enum").get(1);
                 for (JsonNode enm : anEnum) {
-                    enums.add(enm.asLong());
+                    nodesEnums.add(enm.asLong());
                 }
             }
         }
@@ -208,17 +205,14 @@ public abstract class BaseType<E extends BaseType<E>> {
 
         @Override
         protected void getConstraints(RealBaseType baseType, JsonNode type) {
-
-            JsonNode node;
-
-            if ((node = type.get("maxReal")) != null) {
-                baseType.setMax(node.asLong());
+            JsonNode typeMaxNode = type.get("maxReal");
+            if (typeMaxNode != null) {
+                baseType.setMax(typeMaxNode.asLong());
             }
-
-            if ((node = type.get("minReal")) != null) {
-                baseType.setMin(node.asLong());
+            JsonNode typeMinNode = type.get("minReal");
+            if (typeMinNode != null) {
+                baseType.setMin(typeMinNode.asLong());
             }
-
             populateEnum(type);
         }
 
@@ -234,10 +228,10 @@ public abstract class BaseType<E extends BaseType<E>> {
 
         private void populateEnum(JsonNode node) {
             if (node.has("enum")) {
-                Set<Double> enums = Sets.newHashSet();
+                Set<Double> nodesEnums = Sets.newHashSet();
                 JsonNode anEnum = node.get("enum").get(1);
                 for (JsonNode enm : anEnum) {
-                    enums.add(enm.asDouble());
+                    nodesEnums.add(enm.asDouble());
                 }
             }
         }
@@ -354,17 +348,14 @@ public abstract class BaseType<E extends BaseType<E>> {
 
         @Override
         protected void getConstraints(StringBaseType baseType, JsonNode type) {
-
-            JsonNode node = null;
-
-            if ((node = type.get("maxLength")) != null) {
-                baseType.setMaxLength(node.asInt());
+            JsonNode typeMaxNode = type.get("maxLength");
+            if (typeMaxNode != null) {
+                baseType.setMaxLength(typeMaxNode.asInt());
             }
-
-            if ((node = type.get("minLength")) != null) {
-                baseType.setMinLength(node.asInt());
+            JsonNode typeMinNode = type.get("minLength");
+            if (typeMinNode != null) {
+                baseType.setMinLength(typeMinNode.asInt());
             }
-
             populateEnum(baseType, type);
         }
 
@@ -380,17 +371,17 @@ public abstract class BaseType<E extends BaseType<E>> {
 
         private void populateEnum(StringBaseType baseType, JsonNode node) {
             if (node.has("enum")) {
-                Set<String> enums = Sets.newHashSet();
+                Set<String> nodesEnums = Sets.newHashSet();
                 JsonNode enumVal = node.get("enum");
                 if (enumVal.isArray()) {
                     JsonNode anEnum = enumVal.get(1);
                     for (JsonNode enm : anEnum) {
-                        enums.add(enm.asText());
+                        nodesEnums.add(enm.asText());
                     }
                 } else if (enumVal.isTextual()) {
-                    enums.add(enumVal.asText());
+                    nodesEnums.add(enumVal.asText());
                 }
-                baseType.setEnums(enums);
+                baseType.setEnums(nodesEnums);
             }
         }
 
@@ -471,7 +462,6 @@ public abstract class BaseType<E extends BaseType<E>> {
         String refTable;
         RefType refType;
 
-
         @Override
         public UuidBaseType fromString(String typeString) {
             return "uuid".equals(typeString) ? new UuidBaseType() : null;
@@ -479,13 +469,11 @@ public abstract class BaseType<E extends BaseType<E>> {
 
         @Override
         protected void getConstraints(UuidBaseType baseType, JsonNode node) {
-
-            JsonNode refTable = node.get("refTable");
-            baseType.setRefTable(refTable != null ? refTable.asText() : null);
+            JsonNode refTableNode = node.get("refTable");
+            baseType.setRefTable(refTableNode != null ? refTableNode.asText() : null);
 
             JsonNode refTypeJson = node.get("refType");
             baseType.setRefType(refTypeJson != null ? RefType.valueOf(refTypeJson.asText()) : RefType.strong);
-
         }
 
         @Override
index 386dd679193123bb400c2d34623eb8c880391520..5171748eced06d9a7448e0eea22c6f2f1685166c 100644 (file)
@@ -129,9 +129,9 @@ public class ColumnSchema<E extends TableSchema<E>, D> {
 
     /**
      * Verifies if this Column if of the specified type.
-     * @param type the type to check for
+     * @param typeClass the type to check for
      */
-    public void validateType(Class<?> type) {
+    public void validateType(Class<?> typeClass) {
 
     }
 
index faa32f9d81f06351c012fe89f10d24423fee82cc..40b421d835facd22a2bc064cf0dd85cf7ea304c8 100644 (file)
@@ -177,15 +177,16 @@ public abstract class ColumnType {
 
                 AtomicColumnType atomicColumnType = new AtomicColumnType(jsonBaseType);
 
-                JsonNode node;
-                if ((node = json.get("min")) != null) {
-                    atomicColumnType.setMin(node.asLong());
+                JsonNode minNode = json.get("min");
+                if (minNode != null) {
+                    atomicColumnType.setMin(minNode.asLong());
                 }
 
-                if ((node = json.get("max")) != null) {
-                    if (node.isNumber()) {
-                        atomicColumnType.setMax(node.asLong());
-                    } else if ("unlimited".equals(node.asText())) {
+                JsonNode maxNode = json.get("max");
+                if (maxNode != null) {
+                    if (maxNode.isNumber()) {
+                        atomicColumnType.setMax(maxNode.asLong());
+                    } else if ("unlimited".equals(maxNode.asText())) {
                         atomicColumnType.setMax(Long.MAX_VALUE);
                     }
                 }
@@ -249,15 +250,16 @@ public abstract class ColumnType {
             BaseType valueType = BaseType.fromJson(json, "value");
 
             KeyValuedColumnType keyValueColumnType = new KeyValuedColumnType(jsonKeyType, valueType);
-            JsonNode node;
-            if ((node = json.get("min")) != null) {
-                keyValueColumnType.setMin(node.asLong());
+            JsonNode minNode = json.get("min");
+            if (minNode != null) {
+                keyValueColumnType.setMin(minNode.asLong());
             }
 
-            if ((node = json.get("max")) != null) {
-                if (node.isLong()) {
-                    keyValueColumnType.setMax(node.asLong());
-                } else if (node.isTextual() && "unlimited".equals(node.asText())) {
+            JsonNode maxNode = json.get("max");
+            if (maxNode != null) {
+                if (maxNode.isLong()) {
+                    keyValueColumnType.setMax(maxNode.asLong());
+                } else if (maxNode.isTextual() && "unlimited".equals(maxNode.asText())) {
                     keyValueColumnType.setMax(Long.MAX_VALUE);
                 }
             }
index 96a26eca6c2cfa250c35c2fdd7df8f3a7a6e80c3..55a2e70ca626cb39e3d95ec74febe93e6f6fd819 100644 (file)
@@ -137,7 +137,7 @@ public abstract class TableSchema<E extends TableSchema<E>> {
     }
 
     public Row<E> createRow(ObjectNode rowNode) {
-        List<Column<E, ?>> columns = new ArrayList<>();
+        List<Column<E, ?>> newColumns = new ArrayList<>();
         for (Iterator<Map.Entry<String, JsonNode>> iter = rowNode.fields(); iter.hasNext();) {
             Map.Entry<String, JsonNode> next = iter.next();
             ColumnSchema<E, Object> schema = column(next.getKey(), Object.class);
@@ -149,10 +149,10 @@ public abstract class TableSchema<E extends TableSchema<E>> {
              */
             if (schema != null) {
                 Object value = schema.valueFromJson(next.getValue());
-                columns.add(new Column<>(schema, value));
+                newColumns.add(new Column<>(schema, value));
             }
         }
-        return new Row<>(this, columns);
+        return new Row<>(this, newColumns);
     }
 
     public List<Row<E>> createRows(JsonNode rowsNode) {