Added documentation to serializeObject method. 85/12285/2
authorDana Kutenicsova <dkutenic@cisco.com>
Tue, 28 Oct 2014 12:26:57 +0000 (13:26 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Fri, 31 Oct 2014 13:41:27 +0000 (14:41 +0100)
- to be more clear that there is a check for non-null Object argument

Change-Id: I71c1f723281f7ae02501b40dbcf8c533af090063
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractMessageParser.java

index 66c9489f0f074e8085297cc5a4d87c0d1b9f48ba..32295523449574dd0ca1430a57e0b8d771dcf67e 100644 (file)
@@ -17,6 +17,7 @@ import java.util.Arrays;
 import java.util.BitSet;
 import java.util.Collections;
 import java.util.List;
+import javax.annotation.Nullable;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
@@ -62,7 +63,13 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
         this.viRegistry = Preconditions.checkNotNull(viRegistry);
     }
 
-    protected void serializeObject(final Object object, final ByteBuf buffer) {
+    /**
+     * Calls registry to pick up specific object serializer for given object.
+     * Checks if the object is not null.
+     * @param object Object to be serialized, may be null
+     * @param buffer ByteBuf where the object should be serialized
+     */
+    protected void serializeObject(@Nullable final Object object, final ByteBuf buffer) {
         if (object == null) {
             return;
         }
@@ -78,7 +85,7 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
             }
             final int objClass = bytes.readUnsignedByte();
 
-            byte flagsByte = bytes.readByte();
+            final byte flagsByte = bytes.readByte();
             final int objType = UnsignedBytes.toInt(ByteArray.copyBitsRange(flagsByte, OT_SF_OFFSET, OT_SF_LENGTH));
             final byte[] flagsBytes = { ByteArray.copyBitsRange(flagsByte, FLAGS_SF_OFFSET, FLAGS_SF_LENGTH) };
             final BitSet flags = ByteArray.bytesToBitSet(flagsBytes);