Revert "BUG-47 : unfinished PCEP migration to generated DTOs."
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / subobject / RROUnnumberedInterfaceSubobjectParser.java
index 8606b66a137b3b2cec8283817ec9d86e38763b25..edcea4ec34f46cacc602ff11de1ce6c288131ccb 100644 (file)
@@ -7,13 +7,17 @@
  */
 package org.opendaylight.protocol.pcep.impl.subobject;
 
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.concepts.IPv4Address;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.concepts.UnnumberedInterfaceIdentifier;
 import org.opendaylight.protocol.pcep.subobject.RROUnnumberedInterfaceSubobject;
 import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
-import org.opendaylight.protocol.util.ByteArray;
+import com.google.common.primitives.UnsignedInts;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.RROUnnumberedInterfaceSubobject
+ * Parser for
+ * {@link org.opendaylight.protocol.pcep.subobject.RROUnnumberedInterfaceSubobject
  * RROUnnumberedInterfaceSubobject}
  */
 public class RROUnnumberedInterfaceSubobjectParser {
@@ -25,22 +29,18 @@ public class RROUnnumberedInterfaceSubobjectParser {
 
        public static final int CONTENT_LENGTH = INTERFACE_ID_NUMBER_OFFSET + INTERFACE_ID_NUMBER_LENGTH;
 
-       public static RROUnnumberedInterfaceSubobject parse(final byte[] soContentsBytes) throws PCEPDeserializerException {
+       public static RROUnnumberedInterfaceSubobject parse(byte[] soContentsBytes) throws PCEPDeserializerException {
                if (soContentsBytes == null || soContentsBytes.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
-                                       + CONTENT_LENGTH + ".");
-
-               // return new RROUnnumberedInterfaceSubobject(new IPv4Address(
-               // ByteArray.subByte(soContentsBytes, ROUTER_ID_NUMBER_OFFSET, ROUTER_ID_NUMBER_LENGTH)), new
-               // UnnumberedInterfaceIdentifier(
-               // UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(soContentsBytes, INTERFACE_ID_NUMBER_OFFSET,
-               // INTERFACE_ID_NUMBER_LENGTH)))));
-               return null;
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: " + CONTENT_LENGTH + ".");
+
+               return new RROUnnumberedInterfaceSubobject(new IPv4Address(
+                               ByteArray.subByte(soContentsBytes, ROUTER_ID_NUMBER_OFFSET, ROUTER_ID_NUMBER_LENGTH)), new UnnumberedInterfaceIdentifier(
+                               UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(soContentsBytes, INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH)))));
        }
 
-       public static byte[] put(final ReportedRouteSubobject objToSerialize) {
+       public static byte[] put(ReportedRouteSubobject objToSerialize) {
                if (!(objToSerialize instanceof RROUnnumberedInterfaceSubobject))
                        throw new IllegalArgumentException("Unknown ReportedRouteSubobject instance. Passed " + objToSerialize.getClass()
                                        + ". Needed RROUnnumberedInterfaceSubobject.");
@@ -50,8 +50,8 @@ public class RROUnnumberedInterfaceSubobjectParser {
                final RROUnnumberedInterfaceSubobject specObj = (RROUnnumberedInterfaceSubobject) objToSerialize;
 
                ByteArray.copyWhole(specObj.getRouterID().getAddress(), retBytes, ROUTER_ID_NUMBER_OFFSET);
-               System.arraycopy(ByteArray.longToBytes(specObj.getInterfaceID().getInterfaceId()), Long.SIZE / Byte.SIZE
-                               - INTERFACE_ID_NUMBER_LENGTH, retBytes, INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH);
+               System.arraycopy(ByteArray.longToBytes(specObj.getInterfaceID().getInterfaceId()), Long.SIZE / Byte.SIZE - INTERFACE_ID_NUMBER_LENGTH, retBytes,
+                               INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH);
 
                return retBytes;
        }