Removed checkstyle warnings.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / tlv / OrderTlvParser.java
index c883b3b94bea5e512978148721b23a470158e77a..df84505864ed1940ae20f978fec7700bac783941 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.protocol.pcep.impl.tlv;
 
+import io.netty.buffer.ByteBuf;
+
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
@@ -20,29 +22,31 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 public class OrderTlvParser implements TlvParser, TlvSerializer {
 
-       public static final int TYPE = 5;
-
-       private static final int ORDR_DEL_LENGTH = 4;
-
-       private static final int ORDR_SETUP_LENGTH = 4;
-
-       @Override
-       public Order parseTlv(final byte[] buffer) throws PCEPDeserializerException {
-               return new OrderBuilder().setDelete(Long.valueOf(ByteArray.bytesToLong(ByteArray.subByte(buffer, 0, ORDR_DEL_LENGTH)))).setSetup(
-                               ByteArray.bytesToLong(ByteArray.subByte(buffer, ORDR_DEL_LENGTH, ORDR_SETUP_LENGTH))).build();
-       }
-
-       @Override
-       public byte[] serializeTlv(final Tlv tlv) {
-               if (tlv == null) {
-                       throw new IllegalArgumentException("OrderTlv is mandatory.");
-               }
-               final Order otlv = (Order) tlv;
-               final byte[] bytes = new byte[ORDR_DEL_LENGTH + ORDR_SETUP_LENGTH];
-               int offset = 0;
-               ByteArray.copyWhole(ByteArray.longToBytes(otlv.getDelete(), ORDR_DEL_LENGTH), bytes, offset);
-               offset += ORDR_DEL_LENGTH;
-               ByteArray.copyWhole(ByteArray.longToBytes(otlv.getSetup(), ORDR_SETUP_LENGTH), bytes, offset);
-               return TlvUtil.formatTlv(TYPE, bytes);
-       }
+    public static final int TYPE = 5;
+
+    private static final int ORDR_DEL_LENGTH = 4;
+
+    private static final int ORDR_SETUP_LENGTH = 4;
+
+    @Override
+    public Order parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
+        if (buffer == null) {
+            return null;
+        }
+        return new OrderBuilder().setDelete(buffer.readUnsignedInt()).setSetup(buffer.readUnsignedInt()).build();
+    }
+
+    @Override
+    public byte[] serializeTlv(final Tlv tlv) {
+        if (tlv == null) {
+            throw new IllegalArgumentException("OrderTlv is mandatory.");
+        }
+        final Order otlv = (Order) tlv;
+        final byte[] bytes = new byte[ORDR_DEL_LENGTH + ORDR_SETUP_LENGTH];
+        int offset = 0;
+        ByteArray.copyWhole(ByteArray.longToBytes(otlv.getDelete(), ORDR_DEL_LENGTH), bytes, offset);
+        offset += ORDR_DEL_LENGTH;
+        ByteArray.copyWhole(ByteArray.longToBytes(otlv.getSetup(), ORDR_SETUP_LENGTH), bytes, offset);
+        return TlvUtil.formatTlv(TYPE, bytes);
+    }
 }