Bump versions by x.(y+1).z
[lispflowmapping.git] / mappingservice / lisp-proto / src / main / java / org / opendaylight / lispflowmapping / lisp / serializer / address / LcafSerializer.java
index 1d0eca9e2a608120f7ece8841752ada19a482332..3f548c9bf724ad958c00eb0747c637f84d0c7e0b 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.lispflowmapping.lisp.serializer.address;
 
 import java.nio.ByteBuffer;
-
 import org.opendaylight.lispflowmapping.lisp.serializer.address.factory.LispAddressSerializerFactory;
 import org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException;
 import org.opendaylight.lispflowmapping.lisp.util.AddressTypeMap;
@@ -21,7 +20,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.ei
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc;
 
 public class LcafSerializer extends LispAddressSerializer {
-
     private static final LcafSerializer INSTANCE = new LcafSerializer();
     private static final byte DEFAULT_IID_MASK_LENGTH = (byte) 32;
 
@@ -43,6 +41,7 @@ public class LcafSerializer extends LispAddressSerializer {
         return Length.LCAF_HEADER;
     }
 
+    @Override
     protected short getLcafLength(LispAddress lispAddress) {
         throw new LispSerializationException("Unimplemented method");
     }
@@ -64,13 +63,14 @@ public class LcafSerializer extends LispAddressSerializer {
         LispAddressSerializer lcafSerializer = InstanceIdSerializer.getInstance();
         serializeLCAFAddressHeader(buffer, lispAddress, lcafSerializer);
         buffer.put(buffer.position() - 1, DEFAULT_IID_MASK_LENGTH);
-        buffer.putShort((short) (lcafSerializer.getLcafLength(lispAddress) -
-                LispAddressSerializer.getInstance().getInstanceIdExtraSize()));
+        buffer.putShort((short) (lcafSerializer.getLcafLength(lispAddress)
+                LispAddressSerializer.getInstance().getInstanceIdExtraSize()));
     }
 
-    private void serializeLCAFAddressHeader(ByteBuffer buffer, LispAddress lispAddress,
+    private static void serializeLCAFAddressHeader(ByteBuffer buffer, LispAddress lispAddress,
             LispAddressSerializer serializer) {
-        buffer.putShort((short) 0); // RES + Flags.
+        // RES + Flags
+        buffer.putShort((short) 0);
         buffer.put(serializer.getLcafType());
         buffer.put((byte) 0);
     }
@@ -79,7 +79,7 @@ public class LcafSerializer extends LispAddressSerializer {
     protected Eid deserializeEidData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
         buffer.position(buffer.position() + Length.RES + Length.FLAGS);
         byte lcafType = (byte) ByteUtil.getUnsignedByte(buffer);
-        Class <? extends LispAddressFamily> addressType = AddressTypeMap.getLcafType(lcafType);
+        LispAddressFamily addressType = AddressTypeMap.getLcafType(lcafType);
         // TODO move these to ctx to shorten the list of arguments
         byte res2 = buffer.get();
         short length = buffer.getShort();
@@ -90,7 +90,7 @@ public class LcafSerializer extends LispAddressSerializer {
         }
         // Reset the mask context here, since the general mask length field in mapping records doesn't apply to LCAF
         // address types; except for Instance ID, since we don't store it as an LCAF
-        if (ctx != null && addressType != InstanceIdLcaf.class) {
+        if (ctx != null && !InstanceIdLcaf.VALUE.equals(addressType)) {
             ctx.setMaskLen(LispAddressSerializerContext.MASK_LEN_MISSING);
         }
         return serializer.deserializeLcafEidData(buffer, res2, length, ctx);
@@ -100,7 +100,7 @@ public class LcafSerializer extends LispAddressSerializer {
     protected Rloc deserializeRlocData(ByteBuffer buffer) {
         buffer.position(buffer.position() + Length.RES + Length.FLAGS);
         byte lcafType = (byte) ByteUtil.getUnsignedByte(buffer);
-        Class <? extends LispAddressFamily> addressType = AddressTypeMap.getLcafType(lcafType);
+        LispAddressFamily addressType = AddressTypeMap.getLcafType(lcafType);
         byte res2 = buffer.get();
         short length = buffer.getShort();