Move ipv4/ipv6 ByteBuf utilities to Ipv{4,6}Util
[bgpcep.git] / pcep / base-parser / src / main / java / org / opendaylight / protocol / pcep / parser / object / end / points / PCEPEndPointsIpv6ObjectParser.java
index 5399cde7ec51f7ef496c0a9a8d9051a1026ea76b..775961fa219e27c05d8e50a474e148abe0071844 100644 (file)
@@ -7,9 +7,8 @@
  */
 package org.opendaylight.protocol.pcep.parser.object.end.points;
 
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Address;
+import static com.google.common.base.Preconditions.checkArgument;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
@@ -47,19 +46,16 @@ public final class PCEPEndPointsIpv6ObjectParser extends CommonObjectParser {
         final Ipv6 ipv6,
         final ByteBuf buffer) {
         final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH + Ipv6Util.IPV6_LENGTH);
-        Preconditions.checkArgument(ipv6.getSourceIpv6Address() != null,
-            "SourceIpv6Address is mandatory.");
-        writeIpv6Address(ipv6.getSourceIpv6Address(), body);
-        Preconditions.checkArgument(ipv6.getDestinationIpv6Address() != null,
-            "DestinationIpv6Address is mandatory.");
-        writeIpv6Address(ipv6.getDestinationIpv6Address(), body);
+        checkArgument(ipv6.getSourceIpv6Address() != null, "SourceIpv6Address is mandatory.");
+        Ipv6Util.writeIpv6Address(ipv6.getSourceIpv6Address(), body);
+        checkArgument(ipv6.getDestinationIpv6Address() != null, "DestinationIpv6Address is mandatory.");
+        Ipv6Util.writeIpv6Address(ipv6.getDestinationIpv6Address(), body);
         ObjectUtil.formatSubobject(TYPE, CLASS, processing, ignore, body, buffer);
     }
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
-        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
         final EndpointsObjBuilder builder = new EndpointsObjBuilder();
         if (!header.isProcessingRule()) {
             LOG.debug("Processed bit not set on Endpoints OBJECT, ignoring it.");