Migrate pcep-ietf-stateful07 to use ByteBufUtils
[bgpcep.git] / pcep / ietf-stateful07 / src / main / java / org / opendaylight / protocol / pcep / ietf / stateful07 / Stateful07LSPIdentifierIpv6TlvParser.java
index fc64d8c3736ba46ec79d0adfee428a8cd427f3f4..007b270f511980dda0b00565557e32b34c03680d 100644 (file)
@@ -9,8 +9,6 @@ package org.opendaylight.protocol.pcep.ietf.stateful07;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Address;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeShort;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -66,10 +64,13 @@ public final class Stateful07LSPIdentifierIpv6TlvParser implements TlvParser, Tl
         final Ipv6 ipv6 = ((Ipv6Case) lsp.getAddressFamily()).getIpv6();
         checkArgument(ipv6.getIpv6TunnelSenderAddress() != null, "Ipv6TunnelSenderAddress is mandatory.");
         writeIpv6Address(ipv6.getIpv6TunnelSenderAddress(), body);
-        checkArgument(lsp.getLspId() != null, "LspId is mandatory.");
-        writeShort(lsp.getLspId().getValue().shortValue(), body);
-        checkArgument(lsp.getTunnelId() != null, "TunnelId is mandatory.");
-        writeUnsignedShort(lsp.getTunnelId().getValue(), body);
+
+        final LspId lspId = lsp.getLspId();
+        checkArgument(lspId != null, "LspId is mandatory.");
+        body.writeShort(lspId.getValue().shortValue());
+        final TunnelId tunnelId = lsp.getTunnelId();
+        checkArgument(tunnelId != null, "TunnelId is mandatory.");
+        ByteBufUtils.write(body, tunnelId.getValue());
         checkArgument(ipv6.getIpv6ExtendedTunnelId() != null, "Ipv6ExtendedTunnelId is mandatory.");
         writeIpv6Address(ipv6.getIpv6ExtendedTunnelId(), body);
         checkArgument(ipv6.getIpv6TunnelEndpointAddress() != null, "Ipv6TunnelEndpointAddress is mandatory.");