Code Cleanup: unused var and imports
[bgpcep.git] / pcep / spi / src / main / java / org / opendaylight / protocol / pcep / spi / AbstractMessageParser.java
index e4929b2aa7488b813546f465b440c13310ee4546..16e6ad5b8d37db42204d25a6d9163c9aa2cd997d 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.base.Preconditions;
 import com.google.common.primitives.UnsignedBytes;
 import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import javax.annotation.Nullable;
@@ -48,16 +47,9 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
     private static final int IGNORED = 7;
 
     private final ObjectRegistry registry;
-    private final VendorInformationObjectRegistry viRegistry;
 
     protected AbstractMessageParser(final ObjectRegistry registry) {
         this.registry = Preconditions.checkNotNull(registry);
-        this.viRegistry = null;
-    }
-
-    protected AbstractMessageParser(final ObjectRegistry registry, final VendorInformationObjectRegistry viRegistry) {
-        this.registry = Preconditions.checkNotNull(registry);
-        this.viRegistry = Preconditions.checkNotNull(viRegistry);
     }
 
     /**
@@ -97,9 +89,8 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
             final ObjectHeader header = new ObjectHeaderImpl(flags.get(PROCESSED), flags.get(IGNORED));
 
             if (VendorInformationUtil.isVendorInformationObject(objClass, objType)) {
-                Preconditions.checkState(this.viRegistry != null);
                 final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(bytesToPass.readUnsignedInt());
-                final Optional<? extends Object> obj = this.viRegistry.parseVendorInformationObject(enterpriseNumber, header, bytesToPass);
+                final Optional<? extends Object> obj = this.registry.parseVendorInformationObject(enterpriseNumber, header, bytesToPass);
                 if (obj.isPresent()) {
                     objs.add(obj.get());
                 }
@@ -122,9 +113,9 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
                     rp.get()).build())).build()).build();
         }
         return new PcerrBuilder().setPcerrMessage(
-                msgBuilder.setErrors(Arrays.asList(new ErrorsBuilder().setErrorObject(
-                        new ErrorObjectBuilder().setType(e.getErrorType()).setValue(
-                                e.getErrorValue()).build()).build())).build()).build();
+                msgBuilder.setErrors(Collections.singletonList(new ErrorsBuilder().setErrorObject(
+                    new ErrorObjectBuilder().setType(e.getErrorType()).setValue(
+                        e.getErrorValue()).build()).build())).build()).build();
     }
 
     protected abstract Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException;
@@ -143,7 +134,7 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
     protected final void serializeVendorInformationObjects(final List<VendorInformationObject> viObjects, final ByteBuf buffer) {
         if (viObjects != null) {
             for (final VendorInformationObject viObject : viObjects) {
-                this.viRegistry.serializeVendorInformationObject(viObject, buffer);
+                this.registry.serializeVendorInformationObject(viObject, buffer);
             }
         }
     }