Promote MessageRegistry to pcep-api
[bgpcep.git] / pcep / base-parser / src / main / java / org / opendaylight / protocol / pcep / parser / object / AbstractRROWithSubobjectsParser.java
index e3ea391477b1d7984d51e227ef4211e005a1cc46..3ebcfc5c7e61ea3f9561eaa5ea3d9d96aa480609 100644 (file)
@@ -7,16 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufUtil;
 import java.util.ArrayList;
 import java.util.List;
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
-import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.RROSubobjectRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject;
 import org.slf4j.Logger;
@@ -37,8 +37,7 @@ public abstract class AbstractRROWithSubobjectsParser extends CommonObjectParser
     }
 
     protected List<Subobject> parseSubobjects(final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
-                "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
         final List<Subobject> subs = new ArrayList<>();
         while (buffer.isReadable()) {
             final int type = buffer.readUnsignedByte();
@@ -48,7 +47,7 @@ public abstract class AbstractRROWithSubobjectsParser extends CommonObjectParser
                         "Wrong length specified. Passed: " + length + "; Expected: <= " + buffer.readableBytes());
             }
             LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
-            final Subobject sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length));
+            final Subobject sub = subobjReg.parseSubobject(type, buffer.readSlice(length));
             if (sub == null) {
                 LOG.warn("Parsing failed for subobject type: {}. Ignoring subobject.", type);
             } else {
@@ -60,10 +59,9 @@ public abstract class AbstractRROWithSubobjectsParser extends CommonObjectParser
     }
 
     protected final void serializeSubobject(final List<Subobject> subobjects, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobjects != null && !subobjects.isEmpty(),
-                "RRO must contain at least one subobject.");
+        checkArgument(subobjects != null && !subobjects.isEmpty(), "RRO must contain at least one subobject.");
         for (final Subobject subobject : subobjects) {
-            this.subobjReg.serializeSubobject(subobject, buffer);
+            subobjReg.serializeSubobject(subobject, buffer);
         }
     }
 }