Fix warnings/javadocs in sal-distributed-datastore
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / utils / SerializationUtils.java
index 97e3383490d5bb058d3999c454464c435d16ee0c..5ab07599152460171dcf8213a2e0b38d27dd6ee8 100644 (file)
@@ -41,7 +41,7 @@ public final class SerializationUtils {
 
     private static NormalizedNodeDataOutput streamWriter(DataOutput out) throws IOException {
         NormalizedNodeDataOutput streamWriter = REUSABLE_WRITER_TL.get();
-        if(streamWriter == null) {
+        if (streamWriter == null) {
             streamWriter = NormalizedNodeInputOutput.newDataOutput(out);
         }
 
@@ -50,7 +50,7 @@ public final class SerializationUtils {
 
     private static NormalizedNodeDataInput streamReader(DataInput in) throws IOException {
         NormalizedNodeDataInput streamReader = REUSABLE_READER_TL.get();
-        if(streamReader == null) {
+        if (streamReader == null) {
             streamReader = new NormalizedNodeInputStreamReader(in);
         }
 
@@ -82,17 +82,14 @@ public final class SerializationUtils {
         }
     }
 
-    public static void serializeNormalizedNode(NormalizedNode<?, ?> node, DataOutput out) {
-        try {
-            out.writeBoolean(node != null);
-            if(node != null) {
-                NormalizedNodeDataOutput streamWriter = streamWriter(out);
-                streamWriter.writeNormalizedNode(node);
-            }
-        } catch (IOException e) {
-            throw new IllegalArgumentException(String.format("Error serializing NormalizedNode %s",
-                    node), e);
+    private static NormalizedNode<?, ?> tryDeserializeNormalizedNode(DataInput in) throws IOException {
+        boolean present = in.readBoolean();
+        if (present) {
+            NormalizedNodeDataInput streamReader = streamReader(in);
+            return streamReader.readNormalizedNode();
         }
+
+        return null;
     }
 
     public static NormalizedNode<?, ?> deserializeNormalizedNode(DataInput in) {
@@ -103,20 +100,10 @@ public final class SerializationUtils {
         }
     }
 
-    private static NormalizedNode<?, ?> tryDeserializeNormalizedNode(DataInput in) throws IOException {
-        boolean present = in.readBoolean();
-        if(present) {
-            NormalizedNodeDataInput streamReader = streamReader(in);
-            return streamReader.readNormalizedNode();
-        }
-
-        return null;
-    }
-
     public static NormalizedNode<?, ?> deserializeNormalizedNode(byte [] bytes) {
         try {
             return tryDeserializeNormalizedNode(new DataInputStream(new ByteArrayInputStream(bytes)));
-        } catch(InvalidNormalizedNodeStreamException e) {
+        } catch (InvalidNormalizedNodeStreamException e) {
             // Probably from legacy protobuf serialization - try that.
             try {
                 NormalizedNodeMessages.Node serializedNode = NormalizedNodeMessages.Node.parseFrom(bytes);
@@ -129,6 +116,19 @@ public final class SerializationUtils {
         }
     }
 
+    public static void serializeNormalizedNode(NormalizedNode<?, ?> node, DataOutput out) {
+        try {
+            out.writeBoolean(node != null);
+            if (node != null) {
+                NormalizedNodeDataOutput streamWriter = streamWriter(out);
+                streamWriter.writeNormalizedNode(node);
+            }
+        } catch (IOException e) {
+            throw new IllegalArgumentException(String.format("Error serializing NormalizedNode %s",
+                    node), e);
+        }
+    }
+
     public static byte [] serializeNormalizedNode(NormalizedNode<?, ?> node) {
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         serializeNormalizedNode(node, new DataOutputStream(bos));