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 / serialization / ValueSerializer.java
index 9e3230a623855d4add4249d68af0c2c216f4d79f..7523976a73d1c24d6fdf807f6b1297f9e5482a5e 100644 (file)
@@ -22,24 +22,24 @@ public class ValueSerializer {
             QNameSerializationContext context, Object value) {
         builder.setIntValueType(ValueType.getSerializableType(value).ordinal());
 
-        if(value instanceof YangInstanceIdentifier) {
+        if (value instanceof YangInstanceIdentifier) {
             builder.setInstanceIdentifierValue(
                 InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value, context));
-        } else if(value instanceof Set) {
+        } else if (value instanceof Set) {
             Set<?> set = (Set<?>) value;
             if (!set.isEmpty()) {
                 for (Object o : set) {
                     if (o instanceof String) {
                         builder.addBitsValue(o.toString());
                     } else {
-                        throw new IllegalArgumentException("Expected value type to be Bits but was : " +
-                                value.toString());
+                        throw new IllegalArgumentException("Expected value type to be Bits but was : "
+                            + value.toString());
                     }
                 }
             }
-        } else if(value instanceof byte[]) {
+        } else if (value instanceof byte[]) {
             builder.setBytesValue(ByteString.copyFrom((byte[]) value));
-        } else if(value == null){
+        } else if (value == null) {
             builder.setValue(NULL_VALUE);
         } else {
             builder.setValue(value.toString());
@@ -47,28 +47,28 @@ public class ValueSerializer {
     }
 
     public static void serialize(NormalizedNodeMessages.PathArgumentAttribute.Builder builder,
-            QNameSerializationContext context, Object value){
+            QNameSerializationContext context, Object value) {
 
         builder.setType(ValueType.getSerializableType(value).ordinal());
 
-        if(value instanceof YangInstanceIdentifier) {
+        if (value instanceof YangInstanceIdentifier) {
             builder.setInstanceIdentifierValue(
                     InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value, context));
-        } else if(value instanceof Set) {
+        } else if (value instanceof Set) {
             Set<?> set = (Set<?>) value;
             if (!set.isEmpty()) {
                 for (Object o : set) {
                     if (o instanceof String) {
                         builder.addBitsValue(o.toString());
                     } else {
-                        throw new IllegalArgumentException("Expected value type to be Bits but was : " +
-                                value.toString());
+                        throw new IllegalArgumentException("Expected value type to be Bits but was : "
+                            + value.toString());
                     }
                 }
             }
-        } else if(value instanceof byte[]){
+        } else if (value instanceof byte[]) {
             builder.setBytesValue(ByteString.copyFrom((byte[]) value));
-        } else if(value == null){
+        } else if (value == null) {
             builder.setValue(NULL_VALUE);
         } else {
             builder.setValue(value.toString());
@@ -77,12 +77,11 @@ public class ValueSerializer {
 
     public static Object deSerialize(QNameDeSerializationContext context,
             NormalizedNodeMessages.Node node) {
-        if(node.getIntValueType() == ValueType.YANG_IDENTIFIER_TYPE.ordinal()){
-            return InstanceIdentifierUtils.fromSerializable(
-                    node.getInstanceIdentifierValue(), context);
-        } else if(node.getIntValueType() == ValueType.BITS_TYPE.ordinal()){
+        if (node.getIntValueType() == ValueType.YANG_IDENTIFIER_TYPE.ordinal()) {
+            return InstanceIdentifierUtils.fromSerializable(node.getInstanceIdentifierValue(), context);
+        } else if (node.getIntValueType() == ValueType.BITS_TYPE.ordinal()) {
             return new HashSet<>(node.getBitsValueList());
-        } else if(node.getIntValueType() == ValueType.BINARY_TYPE.ordinal()){
+        } else if (node.getIntValueType() == ValueType.BINARY_TYPE.ordinal()) {
             return node.getBytesValue().toByteArray();
         }
         return deSerializeBasicTypes(node.getIntValueType(), node.getValue());
@@ -91,12 +90,11 @@ public class ValueSerializer {
     public static Object deSerialize(QNameDeSerializationContext context,
             NormalizedNodeMessages.PathArgumentAttribute attribute) {
 
-        if(attribute.getType() == ValueType.YANG_IDENTIFIER_TYPE.ordinal()){
-            return InstanceIdentifierUtils.fromSerializable(
-                    attribute.getInstanceIdentifierValue(), context);
-        } else if(attribute.getType() == ValueType.BITS_TYPE.ordinal()){
+        if (attribute.getType() == ValueType.YANG_IDENTIFIER_TYPE.ordinal()) {
+            return InstanceIdentifierUtils.fromSerializable(attribute.getInstanceIdentifierValue(), context);
+        } else if (attribute.getType() == ValueType.BITS_TYPE.ordinal()) {
             return new HashSet<>(attribute.getBitsValueList());
-        } else if(attribute.getType() == ValueType.BINARY_TYPE.ordinal()){
+        } else if (attribute.getType() == ValueType.BINARY_TYPE.ordinal()) {
             return attribute.getBytesValue().toByteArray();
         }
         return deSerializeBasicTypes(attribute.getType(), attribute.getValue());