BUG-113: allow for per-object subobject registries
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / object / PCEPObjectiveFunctionObjectParser.java
index b37523999128aa08e23875274849ec4227a65a18..0d9f03324f63a8095b4b06c136f7ec1db392ca0d 100644 (file)
@@ -9,8 +9,8 @@ package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
@@ -22,7 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link OfObject}
  */
-public class PCEPObjectiveFunctionObjectParser extends AbstractObjectParser<OfBuilder> {
+public class PCEPObjectiveFunctionObjectParser extends AbstractObjectWithTlvsParser<OfBuilder> {
 
        public static final int CLASS = 21;
 
@@ -38,14 +38,15 @@ public class PCEPObjectiveFunctionObjectParser extends AbstractObjectParser<OfBu
        public static final int OF_CODE_F_OFFSET = 0;
        public static final int TLVS_OFFSET = OF_CODE_F_OFFSET + OF_CODE_F_LENGTH + 2; // added reserved field of size 2
 
-       public PCEPObjectiveFunctionObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPObjectiveFunctionObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
        public OfObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               }
 
                final OfBuilder builder = new OfBuilder();
 
@@ -65,9 +66,10 @@ public class PCEPObjectiveFunctionObjectParser extends AbstractObjectParser<OfBu
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof OfObject))
+               if (!(object instanceof OfObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
                                        + ". Needed PCEPObjectiveFunction.");
+               }
 
                final OfObject specObj = (OfObject) object;
                // FIXME