Update ObjectParser API 31/77631/2
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Thu, 8 Nov 2018 14:05:02 +0000 (15:05 +0100)
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Fri, 9 Nov 2018 10:23:47 +0000 (10:23 +0000)
- return Object Class
- return Object Type

This will allow to simplify parser registration
and remove duplicated code.

Change-Id: I1f712f87ad0be190db45e77cc13f55ab6352c2a7
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
61 files changed:
pcep/auto-bandwidth-extension/src/main/java/org/opendaylight/protocol/pcep/auto/bandwidth/extension/Activator.java
pcep/auto-bandwidth-extension/src/main/java/org/opendaylight/protocol/pcep/auto/bandwidth/extension/BandwidthUsageObjectCodec.java
pcep/auto-bandwidth-extension/src/test/java/org/opendaylight/protocol/pcep/auto/bandwidth/extension/PCEPBandwidthUsageObjectCodecTest.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/BaseParserExtensionActivator.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/AbstractEROWithSubobjectsParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/AbstractPccIdReqObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/AbstractPceIdObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/AbstractRROWithSubobjectsParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/AbstractVendorInformationObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/AbstractXROWithSubobjectsParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPBandwidthObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPClassTypeObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPCloseObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPEndPointsIpv4ObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPEndPointsIpv6ObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPErrorObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPExcludeRouteObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPExistingBandwidthObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPExplicitRouteObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPGlobalConstraintsObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPIncludeRouteObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPLoadBalancingObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPLspaObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPMetricObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPMonitoringObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPNoPathObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPNotificationObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPObjectiveFunctionObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPOpenObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPOverloadObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPPathKeyObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPPccIdReqIPv4ObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPPccIdReqIPv6ObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPPceIdIPv4ObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPPceIdIPv6ObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPProcTimeObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPReportedRouteObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPRequestParameterObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPSvecObjectParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/initiated00/CrabbeInitiatedActivator.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/Stateful07LspObjectParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/Stateful07SrpObjectParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/StatefulActivator.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/sync/optimizations/SyncOptimizationsActivator.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPObjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/TestVendorInformationObjectParser.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/PCCActivator.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/SegmentRoutingActivator.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/CommonObjectParser.java [new file with mode: 0644]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectRegistry.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectSerializer.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/ObjectParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPExtensionProviderContext.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectRegistry.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectSerializer.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/pojo/SimplePCEPExtensionProviderContext.java
pcep/spi/src/test/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsTest.java
pcep/spi/src/test/java/org/opendaylight/protocol/pcep/spi/RegistryTest.java

index 316875971990ab01aaf17caa6ae7c69cccb8dd00..e0532bc2019e1b2618b26f9b4a73e0b7de579878 100644 (file)
@@ -35,8 +35,7 @@ public class Activator extends AbstractPCEPExtensionProviderActivator {
 
         final BandwidthUsageObjectCodec bandwidthUsageObjectCodec =
                 new BandwidthUsageObjectCodec(this.bandwidthUsageObjectType);
-        regs.add(context.registerObjectParser(BandwidthUsageObjectCodec.CLASS, bandwidthUsageObjectCodec.getType(),
-                bandwidthUsageObjectCodec));
+        regs.add(context.registerObjectParser(bandwidthUsageObjectCodec));
         regs.add(context.registerObjectSerializer(BandwidthUsage.class, bandwidthUsageObjectCodec));
 
         final PcRptMessageCodec pcRptMessageCodec = new PcRptMessageCodec(context.getObjectHandlerRegistry());
index c60e6d31d4020c8094325e2c95113ee47cec246d..44a01bb4a4db59e8fda6ced6ea69fa9df088abee 100644 (file)
@@ -15,7 +15,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -26,16 +26,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.
 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;
 
-public class BandwidthUsageObjectCodec implements ObjectParser, ObjectSerializer {
+public final class BandwidthUsageObjectCodec extends CommonObjectParser implements ObjectSerializer {
 
-    static final int CLASS = 5;
+    private static final int CLASS = 5;
 
     private static final int BW_LENGTH = 4;
 
-    private final int type;
-
     public BandwidthUsageObjectCodec(final int type) {
-        this.type = type;
+        super(CLASS, type);
     }
 
     @Override
@@ -66,10 +64,7 @@ public class BandwidthUsageObjectCodec implements ObjectParser, ObjectSerializer
         for (final Bandwidth bw : bwSample) {
             writeFloat32(bw, body);
         }
-        ObjectUtil.formatSubobject(getType(), CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
-    }
-
-    public int getType() {
-        return this.type;
+        ObjectUtil.formatSubobject(getObjectType(), getObjectClass(), object.isProcessingRule(), object.isIgnore(),
+            body, buffer);
     }
 }
index 079ec1e97000fb23478c2b81173c81cd13d03785..29c68ab5afe8671fb478c7fd04feb44a631f7ef2 100644 (file)
@@ -30,7 +30,7 @@ public class PCEPBandwidthUsageObjectCodecTest {
     @Test
     public void testCodec() throws PCEPDeserializerException {
         final BandwidthUsageObjectCodec codec = new BandwidthUsageObjectCodec(5);
-        assertEquals(5, codec.getType());
+        assertEquals(5, codec.getObjectType());
 
         final BandwidthUsageBuilder builder = new BandwidthUsageBuilder();
         builder.setBwSample(Lists.newArrayList(new Bandwidth(new byte[]{0x00, 0x00, 0x10, 0x00}),
index 9219597fde9b410013bb2a3598718b92f51ce320..7d82ac8927604b598678410cbd96feb8c3049603 100644 (file)
@@ -197,38 +197,38 @@ public final class BaseParserExtensionActivator extends AbstractPCEPExtensionPro
         final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
         final VendorInformationTlvRegistry viTlvReg = context.getVendorInformationTlvRegistry();
         final PCEPOpenObjectParser openParser = new PCEPOpenObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, openParser));
+        regs.add(context.registerObjectParser(openParser));
         regs.add(context.registerObjectSerializer(Open.class, openParser));
 
         final PCEPRequestParameterObjectParser rpParser = new PCEPRequestParameterObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPRequestParameterObjectParser.CLASS, PCEPRequestParameterObjectParser.TYPE, rpParser));
+        regs.add(context.registerObjectParser(rpParser));
         regs.add(context.registerObjectSerializer(Rp.class, rpParser));
 
         final PCEPNoPathObjectParser noPathParser = new PCEPNoPathObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, noPathParser));
+        regs.add(context.registerObjectParser(noPathParser));
         regs.add(context.registerObjectSerializer(NoPath.class, noPathParser));
 
         final PCEPEndPointsIpv4ObjectParser endpoints4Parser = new PCEPEndPointsIpv4ObjectParser();
         final PCEPEndPointsIpv6ObjectParser endpoints6Parser = new PCEPEndPointsIpv6ObjectParser();
-        regs.add(context.registerObjectParser(PCEPEndPointsIpv4ObjectParser.CLASS, PCEPEndPointsIpv4ObjectParser.TYPE, endpoints4Parser));
-        regs.add(context.registerObjectParser(PCEPEndPointsIpv6ObjectParser.CLASS, PCEPEndPointsIpv6ObjectParser.TYPE, endpoints6Parser));
+        regs.add(context.registerObjectParser(endpoints4Parser));
+        regs.add(context.registerObjectParser(endpoints6Parser));
         regs.add(context.registerObjectSerializer(EndpointsObj.class, endpoints4Parser));
 
         final PCEPBandwidthObjectParser bwParser = new PCEPBandwidthObjectParser();
         final PCEPExistingBandwidthObjectParser bwExistingParser = new PCEPExistingBandwidthObjectParser();
-        regs.add(context.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, bwParser));
-        regs.add(context.registerObjectParser(PCEPExistingBandwidthObjectParser.CLASS, PCEPExistingBandwidthObjectParser.TYPE, bwExistingParser));
+        regs.add(context.registerObjectParser(bwParser));
+        regs.add(context.registerObjectParser(bwExistingParser));
         regs.add(context.registerObjectSerializer(Bandwidth.class, bwParser));
         regs.add(context.registerObjectSerializer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
             .pcep.types.rev131005.reoptimization.bandwidth.object.ReoptimizationBandwidth.class, bwExistingParser));
 
         final PCEPMetricObjectParser metricParser = new PCEPMetricObjectParser();
-        regs.add(context.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, metricParser));
+        regs.add(context.registerObjectParser(metricParser));
         regs.add(context.registerObjectSerializer(Metric.class, metricParser));
 
         final EROSubobjectRegistry eroSubReg = context.getEROSubobjectHandlerRegistry();
         final PCEPExplicitRouteObjectParser eroParser = new PCEPExplicitRouteObjectParser(eroSubReg);
-        regs.add(context.registerObjectParser(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE, eroParser));
+        regs.add(context.registerObjectParser(eroParser));
         regs.add(context.registerObjectSerializer(Ero.class, eroParser));
 
         final PCEPReportedRouteObjectParser rroParser = new PCEPReportedRouteObjectParser(context.getRROSubobjectHandlerRegistry());
@@ -236,31 +236,31 @@ public final class BaseParserExtensionActivator extends AbstractPCEPExtensionPro
         regs.add(context.registerObjectSerializer(Rro.class, rroParser));
 
         final PCEPLspaObjectParser lspaParser = new PCEPLspaObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, lspaParser));
+        regs.add(context.registerObjectParser(lspaParser));
         regs.add(context.registerObjectSerializer(Lspa.class, lspaParser));
 
         final PCEPIncludeRouteObjectParser iroParser = new PCEPIncludeRouteObjectParser(eroSubReg);
-        regs.add(context.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE, iroParser));
+        regs.add(context.registerObjectParser(iroParser));
         regs.add(context.registerObjectSerializer(Iro.class, iroParser));
 
         final PCEPSvecObjectParser svecParser = new PCEPSvecObjectParser();
-        regs.add(context.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, svecParser));
+        regs.add(context.registerObjectParser(svecParser));
         regs.add(context.registerObjectSerializer(Svec.class, svecParser));
 
         final PCEPNotificationObjectParser notParser = new PCEPNotificationObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE, notParser));
+        regs.add(context.registerObjectParser(notParser));
         regs.add(context.registerObjectSerializer(CNotification.class, notParser));
 
         final PCEPErrorObjectParser errParser = new PCEPErrorObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, errParser));
+        regs.add(context.registerObjectParser(errParser));
         regs.add(context.registerObjectSerializer(ErrorObject.class, errParser));
 
         final PCEPLoadBalancingObjectParser lbParser = new PCEPLoadBalancingObjectParser();
-        regs.add(context.registerObjectParser(PCEPLoadBalancingObjectParser.CLASS, PCEPLoadBalancingObjectParser.TYPE, lbParser));
+        regs.add(context.registerObjectParser(lbParser));
         regs.add(context.registerObjectSerializer(LoadBalancing.class, lbParser));
 
         final PCEPCloseObjectParser closeParser = new PCEPCloseObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, closeParser));
+        regs.add(context.registerObjectParser(closeParser));
         regs.add(context.registerObjectSerializer(CClose.class, closeParser));
 
         registerExtensionsObjectParsers(regs, context, tlvReg, viTlvReg, eroSubReg);
@@ -270,25 +270,25 @@ public final class BaseParserExtensionActivator extends AbstractPCEPExtensionPro
             final PCEPExtensionProviderContext context, final TlvRegistry tlvReg,
             final VendorInformationTlvRegistry viTlvReg, final EROSubobjectRegistry eroSubReg) {
         final PCEPPathKeyObjectParser pathKeyParser = new PCEPPathKeyObjectParser(eroSubReg);
-        regs.add(context.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, pathKeyParser));
+        regs.add(context.registerObjectParser(pathKeyParser));
         regs.add(context.registerObjectSerializer(
             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.PathKey.class,
             pathKeyParser));
 
         final PCEPExcludeRouteObjectParser xroParser = new PCEPExcludeRouteObjectParser(context.getXROSubobjectHandlerRegistry());
-        regs.add(context.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE, xroParser));
+        regs.add(context.registerObjectParser(xroParser));
         regs.add(context.registerObjectSerializer(Xro.class, xroParser));
 
         final PCEPObjectiveFunctionObjectParser objectiveParser = new PCEPObjectiveFunctionObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE, objectiveParser));
+        regs.add(context.registerObjectParser(objectiveParser));
         regs.add(context.registerObjectSerializer(Of.class, objectiveParser));
 
         final PCEPClassTypeObjectParser ctParser = new PCEPClassTypeObjectParser();
-        regs.add(context.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, ctParser));
+        regs.add(context.registerObjectParser(ctParser));
         regs.add(context.registerObjectSerializer(ClassType.class, ctParser));
 
         final PCEPGlobalConstraintsObjectParser gcParser = new PCEPGlobalConstraintsObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE, gcParser));
+        regs.add(context.registerObjectParser(gcParser));
         regs.add(context.registerObjectSerializer(Gc.class, gcParser));
 
         registerMonitoringExtensionParsers(regs, context, tlvReg, viTlvReg);
@@ -416,31 +416,31 @@ public final class BaseParserExtensionActivator extends AbstractPCEPExtensionPro
             final PCEPExtensionProviderContext context, final TlvRegistry tlvReg,
             final VendorInformationTlvRegistry viTlvReg) {
         final PCEPMonitoringObjectParser monParser = new PCEPMonitoringObjectParser(tlvReg, viTlvReg);
-        regs.add(context.registerObjectParser(PCEPMonitoringObjectParser.CLASS, PCEPMonitoringObjectParser.TYPE, monParser));
+        regs.add(context.registerObjectParser(monParser));
         regs.add(context.registerObjectSerializer(Monitoring.class, monParser));
 
         final PCEPPccIdReqIPv4ObjectParser pccIdIPv4Parser = new PCEPPccIdReqIPv4ObjectParser();
-        regs.add(context.registerObjectParser(PCEPPccIdReqIPv4ObjectParser.CLASS, PCEPPccIdReqIPv4ObjectParser.IPV4_TYPE, pccIdIPv4Parser));
+        regs.add(context.registerObjectParser(pccIdIPv4Parser));
         regs.add(context.registerObjectSerializer(PccIdReq.class, pccIdIPv4Parser));
 
         final PCEPPccIdReqIPv6ObjectParser pccIdIPv6Parser = new PCEPPccIdReqIPv6ObjectParser();
-        regs.add(context.registerObjectParser(PCEPPccIdReqIPv6ObjectParser.CLASS, PCEPPccIdReqIPv6ObjectParser.IPV6_TYPE, pccIdIPv6Parser));
+        regs.add(context.registerObjectParser(pccIdIPv6Parser));
         regs.add(context.registerObjectSerializer(PccIdReq.class, pccIdIPv6Parser));
 
         final PCEPPceIdIPv4ObjectParser pceIdIP4Parser = new PCEPPceIdIPv4ObjectParser();
-        regs.add(context.registerObjectParser(PCEPPceIdIPv4ObjectParser.CLASS, PCEPPceIdIPv4ObjectParser.IPV4_TYPE, pceIdIP4Parser));
+        regs.add(context.registerObjectParser(pceIdIP4Parser));
         regs.add(context.registerObjectSerializer(PceId.class, pceIdIP4Parser));
 
         final PCEPPceIdIPv6ObjectParser pceIdIP6Parser = new PCEPPceIdIPv6ObjectParser();
-        regs.add(context.registerObjectParser(PCEPPceIdIPv6ObjectParser.CLASS, PCEPPceIdIPv6ObjectParser.IPV6_TYPE, pceIdIP6Parser));
+        regs.add(context.registerObjectParser(pceIdIP6Parser));
         regs.add(context.registerObjectSerializer(PceId.class, pceIdIP6Parser));
 
         final PCEPProcTimeObjectParser procTimeParser = new PCEPProcTimeObjectParser();
-        regs.add(context.registerObjectParser(PCEPProcTimeObjectParser.CLASS, PCEPProcTimeObjectParser.TYPE, procTimeParser));
+        regs.add(context.registerObjectParser(procTimeParser));
         regs.add(context.registerObjectSerializer(ProcTime.class, procTimeParser));
 
         final PCEPOverloadObjectParser overloadParser = new PCEPOverloadObjectParser();
-        regs.add(context.registerObjectParser(PCEPOverloadObjectParser.CLASS, PCEPOverloadObjectParser.TYPE, overloadParser));
+        regs.add(context.registerObjectParser(overloadParser));
         regs.add(context.registerObjectSerializer(Overload.class, overloadParser));
     }
 }
index 57ca42011ca76d1463a6a90074a6711405dedb1e..1dfd0c5328ad05d0510efef216996409ac0b9d2a 100644 (file)
@@ -14,8 +14,8 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufUtil;
 import java.util.ArrayList;
 import java.util.List;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.util.Values;
@@ -23,7 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractEROWithSubobjectsParser implements ObjectParser, ObjectSerializer {
+public abstract class AbstractEROWithSubobjectsParser extends CommonObjectParser implements ObjectSerializer {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractEROWithSubobjectsParser.class);
 
@@ -31,7 +31,9 @@ public abstract class AbstractEROWithSubobjectsParser implements ObjectParser, O
 
     private final EROSubobjectRegistry subobjReg;
 
-    protected AbstractEROWithSubobjectsParser(final EROSubobjectRegistry subobjReg) {
+    protected AbstractEROWithSubobjectsParser(final EROSubobjectRegistry subobjReg, final int objectClass,
+        final int objectType) {
+        super(objectClass, objectType);
         this.subobjReg = requireNonNull(subobjReg);
     }
 
index 2c188deedea761171fe22409f5639c1b6e12c930..010c0bd5971d59821c4a8bc3c899cccfabd8e2fd 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.protocol.pcep.parser.object;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
@@ -20,11 +20,12 @@ import org.opendaylight.protocol.util.Ipv6Util;
 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.pcc.id.req.object.PccIdReq;
 
-public abstract class AbstractPccIdReqObjectParser implements ObjectSerializer, ObjectParser {
-    public static final int CLASS = 20;
+public abstract class AbstractPccIdReqObjectParser extends CommonObjectParser implements ObjectSerializer {
+    private static final int CLASS = 20;
 
-    public static final int IPV4_TYPE = 1;
-    public static final int IPV6_TYPE = 2;
+    public AbstractPccIdReqObjectParser(final int objectType) {
+        super(CLASS, objectType);
+    }
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
@@ -33,11 +34,11 @@ public abstract class AbstractPccIdReqObjectParser implements ObjectSerializer,
         if (pccIdReq.getIpAddress().getIpv4AddressNoZone() != null) {
             final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH);
             ByteBufWriteUtil.writeIpv4Address(pccIdReq.getIpAddress().getIpv4AddressNoZone(), body);
-            ObjectUtil.formatSubobject(IPV4_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
+            ObjectUtil.formatSubobject(getObjectType(), getObjectClass(), object.isProcessingRule(), object.isIgnore(), body, buffer);
         } else if (pccIdReq.getIpAddress().getIpv6AddressNoZone() != null) {
             final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH);
             ByteBufWriteUtil.writeIpv6Address(pccIdReq.getIpAddress().getIpv6AddressNoZone(), body);
-            ObjectUtil.formatSubobject(IPV6_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
+            ObjectUtil.formatSubobject(getObjectType(), getObjectClass(), object.isProcessingRule(), object.isIgnore(), body, buffer);
         }
     }
 }
index 03bba7a5a7ac2ace0f714c728184de35a0db2478..5ffb1532a78bac6a7dc0536671ff93fd0e0654ed 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.protocol.pcep.parser.object;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
@@ -20,26 +20,28 @@ import org.opendaylight.protocol.util.Ipv6Util;
 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.pce.id.object.PceId;
 
-public abstract class AbstractPceIdObjectParser implements ObjectParser, ObjectSerializer {
+public abstract class AbstractPceIdObjectParser extends CommonObjectParser implements ObjectSerializer {
+    private static final int CLASS = 25;
 
-    public static final int CLASS = 25;
-
-    public static final int IPV4_TYPE = 1;
-    public static final int IPV6_TYPE = 2;
+    public AbstractPceIdObjectParser(final int objectType) {
+        super(CLASS, objectType);
+    }
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof PceId, "Wrong instance of PCEPObject. Passed %s. Needed PccIdReqObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof PceId,
+            "Wrong instance of PCEPObject. Passed %s. Needed PccIdReqObject.", object.getClass());
         final PceId pceId = (PceId) object;
         if (pceId.getIpAddress().getIpv4AddressNoZone() != null) {
             final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH);
             ByteBufWriteUtil.writeIpv4Address(pceId.getIpAddress().getIpv4AddressNoZone(), body);
-            ObjectUtil.formatSubobject(IPV4_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
+            ObjectUtil.formatSubobject(getObjectType(), getObjectClass(), object.isProcessingRule(), object.isIgnore(),
+                body, buffer);
         } else if (pceId.getIpAddress().getIpv6AddressNoZone() != null) {
             final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH);
             ByteBufWriteUtil.writeIpv6Address(pceId.getIpAddress().getIpv6AddressNoZone(), body);
-            ObjectUtil.formatSubobject(IPV6_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
+            ObjectUtil.formatSubobject(getObjectType(), getObjectClass(), object.isProcessingRule(), object.isIgnore(),
+                body, buffer);
         }
     }
-
 }
index 229758aa24597f902ae2ce37be8f30b95403a671..9074fca5d1186c8e0ceba98685b8ac95eabb521c 100644 (file)
@@ -14,7 +14,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufUtil;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+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;
@@ -22,7 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractRROWithSubobjectsParser implements ObjectParser, ObjectSerializer {
+public abstract class AbstractRROWithSubobjectsParser extends CommonObjectParser implements ObjectSerializer {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractRROWithSubobjectsParser.class);
 
@@ -30,7 +30,9 @@ public abstract class AbstractRROWithSubobjectsParser implements ObjectParser, O
 
     private static final int HEADER_LENGTH = 2;
 
-    protected AbstractRROWithSubobjectsParser(final RROSubobjectRegistry subobjReg) {
+    protected AbstractRROWithSubobjectsParser(final RROSubobjectRegistry subobjReg,
+        final int objectClass, final int objectType) {
+        super(objectClass, objectType);
         this.subobjReg = requireNonNull(subobjReg);
     }
 
index 6300261835feeb183e3123730227f0954d2282be..34407048064ee9d19a90768774f82e8da552be08 100644 (file)
@@ -15,8 +15,8 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.EnterpriseSpecificInformationParser;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -26,7 +26,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObjectBuilder;
 
-public abstract class AbstractVendorInformationObjectParser implements ObjectSerializer, ObjectParser, EnterpriseSpecificInformationParser {
+public abstract class AbstractVendorInformationObjectParser extends CommonObjectParser
+    implements ObjectSerializer, EnterpriseSpecificInformationParser {
+
+    public AbstractVendorInformationObjectParser(final int objectClass, final int objectType) {
+        super(objectClass, objectType);
+    }
 
     @Override
     public final Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
index 1992e290f0c2b623f79223d52a7eef56334c4e7f..e170855e2f2440b93ba29b5e34fd92243cfde321 100644 (file)
@@ -15,7 +15,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufUtil;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+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.XROSubobjectRegistry;
@@ -24,7 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractXROWithSubobjectsParser implements ObjectParser, ObjectSerializer {
+public abstract class AbstractXROWithSubobjectsParser extends CommonObjectParser implements ObjectSerializer {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractXROWithSubobjectsParser.class);
 
@@ -32,16 +32,21 @@ public abstract class AbstractXROWithSubobjectsParser implements ObjectParser, O
 
     private final XROSubobjectRegistry subobjReg;
 
-    protected AbstractXROWithSubobjectsParser(final XROSubobjectRegistry subobjReg) {
+    protected AbstractXROWithSubobjectsParser(final XROSubobjectRegistry subobjReg,
+        final int objectClass, final int objectType) {
+        super(objectClass, objectType);
         this.subobjReg = requireNonNull(subobjReg);
     }
 
     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.");
+        Preconditions.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 boolean mandatory = ((buffer.getUnsignedByte(buffer.readerIndex()) & (1 << Values.FIRST_BIT_OFFSET)) != 0) ? true : false;
-            final int type = UnsignedBytes.checkedCast((buffer.readUnsignedByte() & Values.BYTE_MAX_VALUE_BYTES) & ~(1 << Values.FIRST_BIT_OFFSET));
+            final boolean mandatory =
+                ((buffer.getUnsignedByte(buffer.readerIndex()) & (1 << Values.FIRST_BIT_OFFSET)) != 0) ? true : false;
+            final int type = UnsignedBytes.checkedCast((buffer.readUnsignedByte() & Values.BYTE_MAX_VALUE_BYTES)
+                & ~(1 << Values.FIRST_BIT_OFFSET));
             final int length = buffer.readUnsignedByte() - HEADER_LENGTH;
             if (length > buffer.readableBytes()) {
                 throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
@@ -60,7 +65,8 @@ public abstract class AbstractXROWithSubobjectsParser implements ObjectParser, O
     }
 
     protected final void serializeSubobject(final List<Subobject> subobjects, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobjects != null && !subobjects.isEmpty(), "XRO must contain at least one subobject.");
+        Preconditions.checkArgument(subobjects != null && !subobjects.isEmpty(),
+            "XRO must contain at least one subobject.");
         for (final Subobject subobject : subobjects) {
             this.subobjReg.serializeSubobject(subobject, buffer);
         }
index 4ec074aad9f320829f99241453424c970e3dc112..9d9c3bd8f238bdbd9f4d0066bd42f9f0ca6a5f92 100644 (file)
@@ -12,7 +12,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -24,31 +24,38 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for Bandwidth
  */
-public class PCEPBandwidthObjectParser implements ObjectParser, ObjectSerializer {
+public final class PCEPBandwidthObjectParser extends CommonObjectParser implements ObjectSerializer {
 
-    public static final int CLASS = 5;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 5;
+    private static final int TYPE = 1;
 
     public static final int BANDWIDTH_F_LENGTH = 4;
 
+    public PCEPBandwidthObjectParser() {
+        super(CLASS, TYPE);
+    }
+
     @Override
     public Bandwidth 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         if (bytes.readableBytes() != BANDWIDTH_F_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: "
-                + BANDWIDTH_F_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: "
+                + bytes.readableBytes() + "; Expected: " + BANDWIDTH_F_LENGTH + ".");
         }
         final BandwidthBuilder builder = new BandwidthBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
-        builder.setBandwidth(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth(ByteArray.getAllBytes(bytes)));
+        builder.setBandwidth(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts
+            .rev131125.Bandwidth(ByteArray.getAllBytes(bytes)));
         return builder.build();
     }
 
     @Override
-    public void serializeObject(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Bandwidth, "Wrong instance of PCEPObject. Passed %s. Needed BandwidthObject.", object.getClass());
+    public void serializeObject(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types
+        .rev131005.Object object, final ByteBuf buffer) {
+        Preconditions.checkArgument(object instanceof Bandwidth,
+            "Wrong instance of PCEPObject. Passed %s. Needed BandwidthObject.", object.getClass());
         final ByteBuf body = Unpooled.buffer();
         writeFloat32(((Bandwidth) object).getBandwidth(), body);
         ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
index 5958efd75670b86adfea1c912b2173ce95c52698..c27fad263f733b21d5ddd5527f5984723628c66f 100644 (file)
@@ -12,7 +12,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -28,13 +28,11 @@ import org.slf4j.LoggerFactory;
 /**
  * Parser for {@link ClassType}
  */
-public class PCEPClassTypeObjectParser implements ObjectParser, ObjectSerializer {
+public final class PCEPClassTypeObjectParser extends CommonObjectParser implements ObjectSerializer {
 
     private static final Logger LOG = LoggerFactory.getLogger(PCEPClassTypeObjectParser.class);
-
-    public static final int CLASS = 22;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 22;
+    private static final int TYPE = 1;
 
     /**
      * Length of Class Type field in bits.
@@ -51,6 +49,10 @@ public class PCEPClassTypeObjectParser implements ObjectParser, ObjectSerializer
      */
     private static final int SIZE = (RESERVED + CT_F_LENGTH) / Byte.SIZE;
 
+    public PCEPClassTypeObjectParser() {
+        super(CLASS, TYPE);
+    }
+
     @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.");
index eb77a09a22d49fdcba81f7faef1776f4e323421b..238cd2d076082fd3a10cc5b5a234348c825920c4 100644 (file)
@@ -29,11 +29,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CClose PCEPCloseObject}
  */
-public class PCEPCloseObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
+public final class PCEPCloseObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
-    public static final int CLASS = 15;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 15;
+    private static final int TYPE = 1;
 
     /*
      * lengths of fields in bytes
@@ -42,7 +41,7 @@ public class PCEPCloseObjectParser extends AbstractObjectWithTlvsParser<TlvsBuil
     private static final int FLAGS_F_LENGTH = 1;
 
     public PCEPCloseObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
 
index 4284d413d40c2488602a450d1b49ad873a8ece70..079ec90e48a1ed087b5a1cfbecd5123bae73b10e 100644 (file)
@@ -12,7 +12,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv4Address;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -35,13 +35,16 @@ import org.slf4j.LoggerFactory;
 /**
  * Parser for IPv4 {@link EndpointsObj}
  */
-public class PCEPEndPointsIpv4ObjectParser implements ObjectParser, ObjectSerializer {
+public class PCEPEndPointsIpv4ObjectParser extends CommonObjectParser implements ObjectSerializer {
 
     private static final Logger LOG = LoggerFactory.getLogger(PCEPEndPointsIpv4ObjectParser.class);
 
-    public static final int CLASS = 4;
+    private static final int CLASS = 4;
+    private static final int TYPE = 1;
 
-    public static final int TYPE = 1;
+    public PCEPEndPointsIpv4ObjectParser() {
+        super(CLASS, TYPE);
+    }
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
index 512533bb6e85c53c7ba197e67a3933cbc73f9d42..d039c22769a27069aa6dc9648f7aa0f7f149930b 100644 (file)
@@ -12,7 +12,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Address;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
@@ -33,13 +33,16 @@ import org.slf4j.LoggerFactory;
 /**
  * Parser for IPv6 {@link EndpointsObj}
  */
-public class PCEPEndPointsIpv6ObjectParser implements ObjectParser {
+public class PCEPEndPointsIpv6ObjectParser extends CommonObjectParser {
 
     private static final Logger LOG = LoggerFactory.getLogger(PCEPEndPointsIpv6ObjectParser.class);
 
-    public static final int CLASS = 4;
+    private static final int CLASS = 4;
+    private static final int TYPE = 2;
 
-    public static final int TYPE = 2;
+    public PCEPEndPointsIpv6ObjectParser() {
+        super(CLASS, TYPE);
+    }
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
index 7e61b1cd867804e8037c492dff721107f81596af..c4fa222092aea5a82cd769e0dfed18c8d5af4d07 100644 (file)
@@ -32,23 +32,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link ErrorObject}
  */
-public class PCEPErrorObjectParser extends AbstractObjectWithTlvsParser<ErrorObjectBuilder> {
-
-    public static final int CLASS = 13;
-
-    public static final int TYPE = 1;
+public final class PCEPErrorObjectParser extends AbstractObjectWithTlvsParser<ErrorObjectBuilder> {
 
+    private static final int CLASS = 13;
+    private static final int TYPE = 1;
     private static final int FLAGS_F_LENGTH = 1;
-
     private static final int RESERVED  = 1;
 
     public PCEPErrorObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
     public ErrorObject 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final ErrorObjectBuilder builder = new ErrorObjectBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
@@ -68,7 +66,8 @@ public class PCEPErrorObjectParser extends AbstractObjectWithTlvsParser<ErrorObj
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof ErrorObject, "Wrong instance of PCEPObject. Passed %s. Needed ErrorObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof ErrorObject,
+            "Wrong instance of PCEPObject. Passed %s. Needed ErrorObject.", object.getClass());
         final ErrorObject errObj = (ErrorObject) object;
         final ByteBuf body = Unpooled.buffer();
         body.writeZero(FLAGS_F_LENGTH + RESERVED);
@@ -91,7 +90,9 @@ public class PCEPErrorObjectParser extends AbstractObjectWithTlvsParser<ErrorObj
     }
 
     @Override
-    protected final void addVendorInformationTlvs(final ErrorObjectBuilder builder, final List<VendorInformationTlv> tlvs) {
+    protected final void addVendorInformationTlvs(
+        final ErrorObjectBuilder builder,
+        final List<VendorInformationTlv> tlvs) {
         if (!tlvs.isEmpty()) {
             builder.setTlvs(new TlvsBuilder(builder.getTlvs()).setVendorInformationTlv(tlvs).build());
         }
index 9fa88deb5e7223ea9e2aaa6f73ff18f2455bee06..ff4735897ae4a8a08bef21ae1f17413147796236 100644 (file)
@@ -26,19 +26,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 public final class PCEPExcludeRouteObjectParser extends AbstractXROWithSubobjectsParser {
 
-    public static final int CLASS = 17;
-
-    public static final int TYPE = 1;
-
+    private static final int CLASS = 17;
+    private static final int TYPE = 1;
     private static final int FLAGS_OFFSET = 3;
 
     public PCEPExcludeRouteObjectParser(final XROSubobjectRegistry registry) {
-        super(registry);
+        super(registry, CLASS, TYPE);
     }
 
     @Override
     public Xro 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final XroBuilder builder = new XroBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
@@ -50,7 +49,8 @@ public final class PCEPExcludeRouteObjectParser extends AbstractXROWithSubobject
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Xro, "Wrong instance of PCEPObject. Passed %s. Needed XroObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof Xro,
+            "Wrong instance of PCEPObject. Passed %s. Needed XroObject.", object.getClass());
         final Xro obj = (Xro) object;
         final ByteBuf body = Unpooled.buffer();
         body.writeZero(FLAGS_OFFSET);
index 2f2b182993f811d006992a4fea32c1831b522938..b5380809e999897107595b2706c796535a730e63 100644 (file)
@@ -12,7 +12,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -24,11 +24,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for Bandwidth
  */
-public class PCEPExistingBandwidthObjectParser implements ObjectParser, ObjectSerializer {
+public class PCEPExistingBandwidthObjectParser extends CommonObjectParser implements ObjectSerializer {
 
-    public static final int CLASS = 5;
+    private static final int CLASS = 5;
 
-    public static final int TYPE = 2;
+    private static final int TYPE = 2;
+
+    public PCEPExistingBandwidthObjectParser() {
+        super(CLASS, TYPE);
+    }
 
     @Override
     public ReoptimizationBandwidth parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
index 0c65d57454b2c885f46219647c108ef1466fd27d..1bf3d57451972b3deab92a57fe71a118e3ac2f8b 100644 (file)
@@ -23,14 +23,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link Ero}
  */
-public class PCEPExplicitRouteObjectParser extends AbstractEROWithSubobjectsParser {
+public final class PCEPExplicitRouteObjectParser extends AbstractEROWithSubobjectsParser {
 
-    public static final int CLASS = 7;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 7;
+    private static final int TYPE = 1;
 
     public PCEPExplicitRouteObjectParser(final EROSubobjectRegistry subobjReg) {
-        super(subobjReg);
+        super(subobjReg, CLASS, TYPE);
     }
 
     @Override
@@ -46,7 +45,8 @@ public class PCEPExplicitRouteObjectParser extends AbstractEROWithSubobjectsPars
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Ero, "Wrong instance of PCEPObject. Passed %s. Needed EroObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof Ero,
+            "Wrong instance of PCEPObject. Passed %s. Needed EroObject.", object.getClass());
         final Ero ero = ((Ero) object);
         final ByteBuf body = Unpooled.buffer();
         serializeSubobject(ero.getSubobject(), body);
index fd3d90dad4911bd3b16edbb7c7ea3d7dd668e1d5..9ad6c1126cde55d12436922a73568042f27d4f75 100644 (file)
@@ -31,17 +31,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 public class PCEPGlobalConstraintsObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
-    public static final int CLASS = 24;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 24;
+    private static final int TYPE = 1;
 
     public PCEPGlobalConstraintsObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
     public Gc 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final GcBuilder builder = new GcBuilder();
 
         builder.setIgnore(header.isIgnore());
@@ -59,7 +59,8 @@ public class PCEPGlobalConstraintsObjectParser extends AbstractObjectWithTlvsPar
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Gc, "Wrong instance of PCEPObject. Passed %s. Needed GcObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof Gc,
+            "Wrong instance of PCEPObject. Passed %s. Needed GcObject.", object.getClass());
         final Gc specObj = (Gc) object;
         final ByteBuf body = Unpooled.buffer();
         writeUnsignedByte(specObj.getMaxHop(), body);
index c48b373f74203bf5360afce71a153e8465e8d0e9..7113a813ca0f4d8dc278f97debd84ae6b7685c28 100644 (file)
@@ -8,13 +8,10 @@
 package org.opendaylight.protocol.pcep.parser.object;
 
 import com.google.common.base.Preconditions;
-
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-
 import java.util.ArrayList;
 import java.util.List;
-
 import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -28,24 +25,25 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link Iro}
  */
-public class PCEPIncludeRouteObjectParser extends AbstractEROWithSubobjectsParser {
-
-    public static final int CLASS = 10;
+public final class PCEPIncludeRouteObjectParser extends AbstractEROWithSubobjectsParser {
 
-    public static final int TYPE = 1;
+    private static final int CLASS = 10;
+    private static final int TYPE = 1;
 
     public PCEPIncludeRouteObjectParser(final EROSubobjectRegistry subobjReg) {
-        super(subobjReg);
+        super(subobjReg, CLASS, TYPE);
     }
 
     @Override
     public Iro 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final IroBuilder builder = new IroBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
         final List<Subobject> subs = new ArrayList<>();
-        for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject s : parseSubobjects(bytes)) {
+        for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit
+            .route.object.ero.Subobject s : parseSubobjects(bytes)) {
             subs.add(new SubobjectBuilder().setLoose(s.isLoose()).setSubobjectType(s.getSubobjectType()).build());
         }
         builder.setSubobject(subs);
@@ -54,13 +52,16 @@ public class PCEPIncludeRouteObjectParser extends AbstractEROWithSubobjectsParse
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Iro, "Wrong instance of PCEPObject. Passed %s. Needed IroObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof Iro,
+            "Wrong instance of PCEPObject. Passed %s. Needed IroObject.", object.getClass());
         final Iro iro = ((Iro) object);
         final ByteBuf body = Unpooled.buffer();
-        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject> subs = new ArrayList<>();
+        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit
+            .route.object.ero.Subobject> subs = new ArrayList<>();
         for (final Subobject s : iro.getSubobject()) {
-            subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder().setLoose(
-                    s.isLoose()).setSubobjectType(s.getSubobjectType()).build());
+            subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005
+                .explicit.route.object.ero.SubobjectBuilder().setLoose(
+                s.isLoose()).setSubobjectType(s.getSubobjectType()).build());
         }
         serializeSubobject(subs, body);
         ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
index dfe2db04539c7d1ccf01ae7187628e88d1504ad0..7496959a8c57d71027deb4d91c2bab9ac0a8f147 100644 (file)
@@ -13,7 +13,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -27,23 +27,25 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link LoadBalancing}
  */
-public class PCEPLoadBalancingObjectParser implements ObjectParser, ObjectSerializer {
-
-    public static final int CLASS = 14;
-
-    public static final int TYPE = 1;
+public final class PCEPLoadBalancingObjectParser extends CommonObjectParser implements ObjectSerializer {
 
+    private static final int CLASS = 14;
+    private static final int TYPE = 1;
     private static final int RESERVED = 2;
     private static final int FLAGS_F_LENGTH = 1;
-
     private static final int SIZE = 8;
 
+    public PCEPLoadBalancingObjectParser() {
+        super(CLASS, TYPE);
+    }
+
     @Override
     public LoadBalancing 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         if (bytes.readableBytes() != SIZE) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + SIZE
-                    + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: "
+                + bytes.readableBytes() + "; Expected: " + SIZE + ".");
         }
         final LoadBalancingBuilder builder = new LoadBalancingBuilder();
         builder.setIgnore(header.isIgnore());
@@ -56,7 +58,9 @@ public class PCEPLoadBalancingObjectParser implements ObjectParser, ObjectSerial
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof LoadBalancing, "Wrong instance of PCEPObject. Passed %s. Needed LoadBalancingObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof LoadBalancing,
+            "Wrong instance of PCEPObject. Passed %s. Needed LoadBalancingObject.",
+            object.getClass());
         final LoadBalancing specObj = (LoadBalancing) object;
         final ByteBuf body = Unpooled.buffer(SIZE);
         body.writeZero(RESERVED + FLAGS_F_LENGTH);
index 6c440fbb07ae3ad106bde6f62598a6c1c2c72ccc..4f64859325455e5c89d4f003e6e54884c30b8ee9 100644 (file)
@@ -34,9 +34,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
  */
 public class PCEPLspaObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
-    public static final int CLASS = 9;
+    private static final int CLASS = 9;
 
-    public static final int TYPE = 1;
+    private static final int TYPE = 1;
 
     /*
      * lengths of fields in bytes
@@ -51,7 +51,7 @@ public class PCEPLspaObjectParser extends AbstractObjectWithTlvsParser<TlvsBuild
     private static final int RESERVED = 1;
 
     public PCEPLspaObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
index 58db1b40ad10dd1354036f0c62916d7fefd17fd3..7ec961866701523f846cf8de110e6ce59328d528 100644 (file)
@@ -13,7 +13,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -28,11 +28,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link Metric}
  */
-public class PCEPMetricObjectParser implements ObjectParser, ObjectSerializer {
+public final class PCEPMetricObjectParser extends CommonObjectParser implements ObjectSerializer {
 
-    public static final int CLASS = 6;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 6;
+    private static final int TYPE = 1;
 
     /*
      * lengths of fields in bytes
@@ -53,6 +52,10 @@ public class PCEPMetricObjectParser implements ObjectParser, ObjectSerializer {
 
     private static final int SIZE = METRIC_VALUE_F_LENGTH + METRIC_VALUE_F_LENGTH;
 
+    public PCEPMetricObjectParser() {
+        super(CLASS, TYPE);
+    }
+
     @Override
     public Metric 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.");
index ab51e4dd559e3599611c7840bd4c12c64b0da33a..eb1e26ed99a6812f16f81356a74d5932647f4ffa 100644 (file)
@@ -35,9 +35,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 public class PCEPMonitoringObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
-    public static final int CLASS = 19;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 19;
+    private static final int TYPE = 1;
 
     private static final int FLAGS_SIZE = 24;
     private static final int RESERVED = 1;
@@ -48,7 +47,7 @@ public class PCEPMonitoringObjectParser extends AbstractObjectWithTlvsParser<Tlv
     private static final int I_FLAG_POS = 19;
 
     public PCEPMonitoringObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
index d85b22da44f5dc506881eab208f9bdc12a381722..f0bb597d051b89bbeb10473fdb4cbdd75cc28d1e 100644 (file)
@@ -34,9 +34,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 public class PCEPNoPathObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
-    public static final int CLASS = 3;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 3;
+    private static final int TYPE = 1;
 
     /*
      * lengths of fields in bytes
@@ -50,7 +49,7 @@ public class PCEPNoPathObjectParser extends AbstractObjectWithTlvsParser<TlvsBui
     private static final int C_FLAG_OFFSET = 0;
 
     public PCEPNoPathObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
index b4351b409331cb2c42d21fd96a46ef26be922a78..771134b0136b4c13e32ba3bf1a91d331f746a25f 100644 (file)
@@ -31,11 +31,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link CNotification}
  */
-public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<CNotificationBuilder> {
+public final class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<CNotificationBuilder> {
 
-    public static final int CLASS = 12;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 12;
+    private static final int TYPE = 1;
 
     /*
      * offsets of fields
@@ -43,12 +42,13 @@ public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<C
     private static final int NT_F_OFFSET = 2;
 
     public PCEPNotificationObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
     public CNotification 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final CNotificationBuilder builder = new CNotificationBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
@@ -68,7 +68,9 @@ public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<C
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof CNotification, "Wrong instance of PCEPObject. Passed %s. Needed CNotificationObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof CNotification,
+            "Wrong instance of PCEPObject. Passed %s. Needed CNotificationObject.",
+            object.getClass());
         final CNotification notObj = (CNotification) object;
         final ByteBuf body = Unpooled.buffer();
         body.writeZero(NT_F_OFFSET);
@@ -91,7 +93,9 @@ public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<C
     }
 
     @Override
-    protected final void addVendorInformationTlvs(final CNotificationBuilder builder, final List<VendorInformationTlv> tlvs) {
+    protected final void addVendorInformationTlvs(
+        final CNotificationBuilder builder,
+        final List<VendorInformationTlv> tlvs) {
         if (!tlvs.isEmpty()) {
             builder.setTlvs(new TlvsBuilder(builder.getTlvs()).setVendorInformationTlv(tlvs).build());
         }
index 7a2a863906c19af2773c48b7d30eeb028ac88e5a..598a884ca88d78bc2563edd22e3f5f14801837ae 100644 (file)
@@ -30,21 +30,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link Of}
  */
-public class PCEPObjectiveFunctionObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
-
-    public static final int CLASS = 21;
-
-    public static final int TYPE = 1;
+public final class PCEPObjectiveFunctionObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
+    private static final int CLASS = 21;
+    private static final int TYPE = 1;
     private static final int RESERVED = 2;
 
     public PCEPObjectiveFunctionObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
     public Of 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final OfBuilder builder = new OfBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
@@ -58,7 +57,8 @@ public class PCEPObjectiveFunctionObjectParser extends AbstractObjectWithTlvsPar
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Of, "Wrong instance of PCEPObject. Passed %s. Needed OfObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof Of,
+            "Wrong instance of PCEPObject. Passed %s. Needed OfObject.", object.getClass());
         final Of specObj = (Of) object;
         final ByteBuf body = Unpooled.buffer();
         Preconditions.checkArgument(specObj.getCode() != null, "Code is mandatory");
index fad65d74c630c33c256da743c09e67c903f2b05b..2de270b21c797597038da3b82426f805903f2771 100644 (file)
@@ -41,9 +41,8 @@ import org.slf4j.LoggerFactory;
 public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
     private static final Logger LOG = LoggerFactory.getLogger(PCEPOpenObjectParser.class);
 
-    public static final int CLASS = 1;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 1;
+    private static final int TYPE = 1;
 
     /*
      * lengths of subfields inside multi-field in bits
@@ -58,7 +57,7 @@ public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<TlvsBuild
     private static final int PCEP_VERSION = 1;
 
     public PCEPOpenObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
index 02deb0802de23300e63a770daff2bfe230abf262..fabf947ba9ed1ece87b66a5827b1a2520b977053 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.protocol.pcep.parser.object;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -21,19 +21,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.Overload;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.object.OverloadBuilder;
 
-public class PCEPOverloadObjectParser implements ObjectParser, ObjectSerializer {
-
-    public static final int CLASS = 27;
-
-    public static final int TYPE = 1;
+public class PCEPOverloadObjectParser extends CommonObjectParser implements ObjectSerializer {
 
+    private static final int CLASS = 27;
+    private static final int TYPE = 1;
     private static final int RESERVED = 1;
     private static final int FLAGS = RESERVED;
     private static final int BODY_SIZE = RESERVED + FLAGS + ByteBufWriteUtil.SHORT_BYTES_LENGTH;
 
+    public PCEPOverloadObjectParser() {
+        super(CLASS, TYPE);
+    }
+
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Overload, "Wrong instance of PCEPObject. Passed %s. Needed OverloadObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof Overload,
+            "Wrong instance of PCEPObject. Passed %s. Needed OverloadObject.", object.getClass());
         final Overload overload = (Overload) object;
         final ByteBuf body = Unpooled.buffer(BODY_SIZE);
         body.writeZero(RESERVED + FLAGS);
@@ -43,11 +46,11 @@ public class PCEPOverloadObjectParser implements ObjectParser, ObjectSerializer
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final OverloadBuilder builder = new OverloadBuilder();
         buffer.readBytes(RESERVED + FLAGS);
         builder.setDuration(buffer.readUnsignedShort());
         return builder.build();
     }
-
 }
index 768945040991f2b911c62d7fcf0335d187a9bdcb..9341d61f6dc9f41b76cb45d7d5dec2e420e64b71 100644 (file)
@@ -8,13 +8,10 @@
 package org.opendaylight.protocol.pcep.parser.object;
 
 import com.google.common.base.Preconditions;
-
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-
 import java.util.ArrayList;
 import java.util.List;
-
 import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -30,27 +27,30 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link PathKey}
  */
-public class PCEPPathKeyObjectParser extends AbstractEROWithSubobjectsParser {
-
-    public static final int CLASS = 16;
+public final class PCEPPathKeyObjectParser extends AbstractEROWithSubobjectsParser {
 
-    public static final int TYPE = 1;
+    private static final int CLASS = 16;
+    private static final int TYPE = 1;
 
     public PCEPPathKeyObjectParser(final EROSubobjectRegistry subReg) {
-        super(subReg);
+        super(subReg, CLASS, TYPE);
     }
 
     @Override
     public PathKey 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final PathKeyBuilder builder = new PathKeyBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
         final List<PathKeys> pk = new ArrayList<>();
         final List<Subobject> subs = parseSubobjects(bytes);
         for (final Subobject s : subs) {
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase k = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase) s.getSubobjectType();
-            pk.add(new PathKeysBuilder().setLoose(s.isLoose()).setPceId(k.getPathKey().getPceId()).setPathKey(k.getPathKey().getPathKey()).build());
+            final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
+                .subobjects.subobject.type.PathKeyCase k = (org.opendaylight.yang.gen.v1.urn.opendaylight.params
+                .xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase) s.getSubobjectType();
+            pk.add(new PathKeysBuilder().setLoose(s.isLoose()).setPceId(k.getPathKey().getPceId())
+                .setPathKey(k.getPathKey().getPathKey()).build());
         }
         builder.setPathKeys(pk);
         return builder.build();
@@ -58,16 +58,19 @@ public class PCEPPathKeyObjectParser extends AbstractEROWithSubobjectsParser {
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof PathKey, "Wrong instance of PCEPObject. Passed %s. Needed PathKeyObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof PathKey,
+            "Wrong instance of PCEPObject. Passed %s. Needed PathKeyObject.", object.getClass());
         final PathKey pkey = (PathKey) object;
         final ByteBuf body = Unpooled.buffer();
         final List<PathKeys> pk = pkey.getPathKeys();
         final List<Subobject> subs = new ArrayList<>();
         for (final PathKeys p : pk) {
             subs.add(new SubobjectBuilder().setLoose(p.isLoose()).setSubobjectType(
-                    new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder().setPathKey(
-                            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder().setPathKey(
-                                    p.getPathKey()).setPceId(p.getPceId()).build()).build()).build());
+                new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit
+                    .route.subobjects.subobject.type.PathKeyCaseBuilder().setPathKey(
+                    new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820
+                        .explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder().setPathKey(p
+                        .getPathKey()).setPceId(p.getPceId()).build()).build()).build());
         }
         serializeSubobject(subs, body);
         ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
index 71e08bad20cb62114db9061efc0b32e5b15bd5e9..b716c216ae8fa53d92be8d449c7c06aefc8d012a 100644 (file)
@@ -21,14 +21,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  * Parser for {@link org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq} with IPv4 address
  * @see <a href="https://tools.ietf.org/html/rfc5886#section-4.2">PCC-ID-REQ Object</a>
  */
-public class PCEPPccIdReqIPv4ObjectParser extends AbstractPccIdReqObjectParser {
+public final class PCEPPccIdReqIPv4ObjectParser extends AbstractPccIdReqObjectParser {
+    private static final int IPV4_TYPE = 1;
+
+    public PCEPPccIdReqIPv4ObjectParser() {
+        super(IPV4_TYPE);
+    }
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final PccIdReqBuilder builder = new PccIdReqBuilder();
         builder.setIpAddress(new IpAddressNoZone(Ipv4Util.noZoneAddressForByteBuf(buffer)));
         return builder.build();
     }
-
 }
index 95822e3e94d06ee5fbdd03615be712ba35544b0b..397a6a5296e0089aebd5c2e70955ac6c31085774 100644 (file)
@@ -21,7 +21,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  * Parser for {@link org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq} with IPv6 address
  * @see <a href="https://tools.ietf.org/html/rfc5886#section-4.2">PCC-ID-REQ Object</a>
  */
-public class PCEPPccIdReqIPv6ObjectParser extends AbstractPccIdReqObjectParser {
+public final class PCEPPccIdReqIPv6ObjectParser extends AbstractPccIdReqObjectParser {
+    private static final int IPV6_TYPE = 2;
+
+    public PCEPPccIdReqIPv6ObjectParser() {
+        super(IPV6_TYPE);
+    }
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
@@ -30,5 +35,4 @@ public class PCEPPccIdReqIPv6ObjectParser extends AbstractPccIdReqObjectParser {
         builder.setIpAddress(new IpAddressNoZone(Ipv6Util.noZoneAddressForByteBuf(buffer)));
         return builder.build();
     }
-
 }
index d087a09aa6e9ceac80a6a2b2daab7ad24a31efc2..2833d5e5bbc585bbdb151a14f8371bf9207f1108 100644 (file)
@@ -22,6 +22,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  * @see <a href="https://tools.ietf.org/html/rfc5886#section-4.3">PCE-ID Object</a>
  */
 public class PCEPPceIdIPv4ObjectParser extends AbstractPceIdObjectParser {
+    private static final int IPV4_TYPE = 1;
+
+    public PCEPPceIdIPv4ObjectParser() {
+        super(IPV4_TYPE);
+    }
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
@@ -30,5 +35,4 @@ public class PCEPPceIdIPv4ObjectParser extends AbstractPceIdObjectParser {
         builder.setIpAddress(new IpAddressNoZone(Ipv4Util.noZoneAddressForByteBuf(buffer)));
         return builder.build();
     }
-
 }
index cd8ede8a923813e64f190806ab675ce6aee13268..3f4db2e53b1c0059ffb6165b0fb0a42c6ecd6140 100644 (file)
@@ -22,6 +22,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  * @see <a href="https://tools.ietf.org/html/rfc5886#section-4.3"></a>
  */
 public class PCEPPceIdIPv6ObjectParser extends AbstractPceIdObjectParser {
+    private static final int IPV6_TYPE = 2;
+
+    public PCEPPceIdIPv6ObjectParser() {
+        super(IPV6_TYPE);
+    }
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
@@ -30,5 +35,4 @@ public class PCEPPceIdIPv6ObjectParser extends AbstractPceIdObjectParser {
         builder.setIpAddress(new IpAddressNoZone(Ipv6Util.noZoneAddressForByteBuf(buffer)));
         return builder.build();
     }
-
 }
index 290de595a117276c65ce70b16d5b832d0d51b09a..6c672af54c39b63b1770fa769e7f0924dcdde8ce 100644 (file)
@@ -12,7 +12,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.INT_BYTES_LENGTH;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -27,21 +27,24 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  * Parser for {@link ProcTime}
  * @see <a href="https://tools.ietf.org/html/rfc5886#section-4.4">PROC-TIME Object</a>
  */
-public class PCEPProcTimeObjectParser implements ObjectParser, ObjectSerializer {
-
-    public static final int CLASS = 26;
-
-    public static final int TYPE = 1;
+public class PCEPProcTimeObjectParser extends CommonObjectParser implements ObjectSerializer {
 
+    private static final int CLASS = 26;
+    private static final int TYPE = 1;
     private static final int RESERVED = 2;
     private static final int FLAGS = 16;
     private static final int COUNT_FIELDS = 5;
     private static final int BODY_SIZE = RESERVED + FLAGS + COUNT_FIELDS * INT_BYTES_LENGTH;
     private static final int E_FLAG_POSITION = 15;
 
+    public PCEPProcTimeObjectParser() {
+        super(CLASS, TYPE);
+    }
+
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof ProcTime, "Wrong instance of PCEPObject. Passed %s. Needed ProcTimeObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof ProcTime,
+            "Wrong instance of PCEPObject. Passed %s. Needed ProcTimeObject.", object.getClass());
         final ProcTime procTime = (ProcTime) object;
         final ByteBuf body = Unpooled.buffer(BODY_SIZE);
         body.writeZero(RESERVED);
@@ -58,7 +61,8 @@ public class PCEPProcTimeObjectParser implements ObjectParser, ObjectSerializer
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final ProcTimeBuilder builder = new ProcTimeBuilder();
         buffer.skipBytes(RESERVED);
         final BitArray flagBits = BitArray.valueOf(buffer, FLAGS);
@@ -70,5 +74,4 @@ public class PCEPProcTimeObjectParser implements ObjectParser, ObjectSerializer
         builder.setVarianceProcTime(buffer.readUnsignedInt());
         return builder.build();
     }
-
 }
index f89323160cfddc703149d08150b4e1f8b9413920..c3e2ab6737d137b7314a03bf3d72b36ec6d1566b 100644 (file)
@@ -23,19 +23,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link Rro}
  */
-public class PCEPReportedRouteObjectParser extends AbstractRROWithSubobjectsParser {
+public final class PCEPReportedRouteObjectParser extends AbstractRROWithSubobjectsParser {
 
     public static final int CLASS = 8;
 
     public static final int TYPE = 1;
 
     public PCEPReportedRouteObjectParser(final RROSubobjectRegistry subobjReg) {
-        super(subobjReg);
+        super(subobjReg, CLASS, TYPE);
     }
 
     @Override
     public Rro 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final RroBuilder builder = new RroBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
@@ -45,7 +46,8 @@ public class PCEPReportedRouteObjectParser extends AbstractRROWithSubobjectsPars
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Rro, "Wrong instance of PCEPObject. Passed %s. Needed RroObject.", object.getClass());
+        Preconditions.checkArgument(object instanceof Rro,
+            "Wrong instance of PCEPObject. Passed %s. Needed RroObject.", object.getClass());
         final Rro obj = (Rro) object;
         final ByteBuf body = Unpooled.buffer();
         serializeSubobject(obj.getSubobject(), body);
index 53fd99da8edb31b9dc24ecc8d570acf2e410307a..450af143b6096838eda2667e24e7096e99e05ac3 100644 (file)
@@ -38,9 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
-    public static final int CLASS = 2;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 2;
+    private static final int TYPE = 1;
 
     /*
      * lengths of fields in bytes
@@ -91,7 +90,7 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
     private static final int E_FLAG_OFFSET = 20;
 
     public PCEPRequestParameterObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
index 0f088643ef99783fac444589ca9e6ba9a378a167..816546ebe1b55d72242e6166cefaab4e9a144efa 100644 (file)
@@ -14,7 +14,7 @@ import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.List;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -28,11 +28,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link Svec}
  */
-public class PCEPSvecObjectParser implements ObjectParser, ObjectSerializer {
+public final class PCEPSvecObjectParser extends CommonObjectParser implements ObjectSerializer {
 
-    public static final int CLASS = 11;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 11;
+    private static final int TYPE = 1;
 
     /*
      * field lengths in bytes
@@ -56,6 +55,10 @@ public class PCEPSvecObjectParser implements ObjectParser, ObjectSerializer {
      */
     private static final int MIN_SIZE = FLAGS_SIZE / Byte.SIZE + FLAGS_F_OFFSET;
 
+    public PCEPSvecObjectParser() {
+        super(CLASS, TYPE);
+    }
+
     @Override
     public Svec 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.");
index 7840f8fc1c4d8ec7f8fbff73d1b6977cd221257f..942be41d5182d6cd9bd517d729a5976d2bd11b9f 100644 (file)
@@ -30,14 +30,13 @@ public final class CrabbeInitiatedActivator extends AbstractPCEPExtensionProvide
 
         final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
         final VendorInformationTlvRegistry viTlvReg = context.getVendorInformationTlvRegistry();
-        regs.add(context.registerObjectParser(CInitiated00LspObjectParser.CLASS, CInitiated00LspObjectParser.TYPE,
-                new CInitiated00LspObjectParser(tlvReg, viTlvReg)));
+        regs.add(context.registerObjectParser(new CInitiated00LspObjectParser(tlvReg, viTlvReg)));
         regs.add(context.registerObjectSerializer(Lsp.class, new CInitiated00LspObjectParser(tlvReg, viTlvReg)));
-        regs.add(context.registerObjectParser(CInitiated00SrpObjectParser.CLASS, CInitiated00SrpObjectParser.TYPE,
-                new CInitiated00SrpObjectParser(tlvReg, viTlvReg)));
+        regs.add(context.registerObjectParser(new CInitiated00SrpObjectParser(tlvReg, viTlvReg)));
         regs.add(context.registerObjectSerializer(Srp.class, new CInitiated00SrpObjectParser(tlvReg, viTlvReg)));
 
-        regs.add(context.registerTlvParser(CInitiated00StatefulCapabilityTlvParser.TYPE, new CInitiated00StatefulCapabilityTlvParser()));
+        regs.add(context.registerTlvParser(CInitiated00StatefulCapabilityTlvParser.TYPE,
+            new CInitiated00StatefulCapabilityTlvParser()));
         regs.add(context.registerTlvSerializer(Stateful.class, new CInitiated00StatefulCapabilityTlvParser()));
 
         return regs;
index dd88355c40ec2df9641b580e0cf335ef040fe7a5..5ab10251c628736336878308d25ce428781f5e69 100644 (file)
@@ -41,9 +41,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 public class Stateful07LspObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
-    public static final int CLASS = 32;
+    private static final int CLASS = 32;
 
-    public static final int TYPE = 1;
+    private static final int TYPE = 1;
 
     /*
      * 12b extended to 16b so first 4b are restricted (belongs to LSP ID)
@@ -58,17 +58,20 @@ public class Stateful07LspObjectParser extends AbstractObjectWithTlvsParser<Tlvs
     protected static final int FLAGS_SIZE = 12;
 
     public Stateful07LspObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
     public Lsp 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.");
+        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+            "Array of bytes is mandatory. Can't be null or empty.");
         final LspBuilder builder = new LspBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
-        final int[] plspIdRaw = new int[] { bytes.readUnsignedByte(), bytes.readUnsignedByte(), bytes.getUnsignedByte(2), };
-        builder.setPlspId(new PlspId((long) ((plspIdRaw[0] << FLAGS_SIZE) | (plspIdRaw[1] << FOUR_BITS_SHIFT) | (plspIdRaw[2] >> FOUR_BITS_SHIFT))));
+        final int[] plspIdRaw
+            = new int[] { bytes.readUnsignedByte(), bytes.readUnsignedByte(), bytes.getUnsignedByte(2), };
+        builder.setPlspId(new PlspId((long) ((plspIdRaw[0] << FLAGS_SIZE) | (plspIdRaw[1] << FOUR_BITS_SHIFT)
+            | (plspIdRaw[2] >> FOUR_BITS_SHIFT))));
         parseFlags(builder, bytes);
         final TlvsBuilder b = new TlvsBuilder();
         parseTlvs(b, bytes.slice());
index b43abd57ad1d452ed1b2d47d7cc7d3c9252b339b..4b47394e43b1dccd1c2a1b93247e36039362f2dc 100644 (file)
@@ -35,9 +35,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 public class Stateful07SrpObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
-    public static final int CLASS = 33;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 33;
+    private static final int TYPE = 1;
 
     protected static final int FLAGS_SIZE = 32;
 
@@ -46,7 +45,7 @@ public class Stateful07SrpObjectParser extends AbstractObjectWithTlvsParser<Tlvs
     protected static final int MIN_SIZE = FLAGS_SIZE / Byte.SIZE + SRP_ID_SIZE;
 
     protected Stateful07SrpObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
+        super(tlvReg, viTlvReg, CLASS, TYPE);
     }
 
     @Override
index 2051871a77561dd2e911ca8f8952067922509c29..86a600f7375b4e8e7fd53442f52162231011e31f 100644 (file)
@@ -36,33 +36,38 @@ public final class StatefulActivator extends AbstractPCEPExtensionProviderActiva
         regs.add(context.registerMessageParser(Stateful07PCUpdateRequestMessageParser.TYPE,
             new Stateful07PCUpdateRequestMessageParser(objReg)));
         regs.add(context.registerMessageSerializer(Pcupd.class, new Stateful07PCUpdateRequestMessageParser(objReg)));
-        regs.add(context.registerMessageParser(Stateful07PCReportMessageParser.TYPE, new Stateful07PCReportMessageParser(objReg)));
+        regs.add(context.registerMessageParser(Stateful07PCReportMessageParser.TYPE,
+            new Stateful07PCReportMessageParser(objReg)));
         regs.add(context.registerMessageSerializer(Pcrpt.class, new Stateful07PCReportMessageParser(objReg)));
-        regs.add(context.registerMessageParser(Stateful07ErrorMessageParser.TYPE, new Stateful07ErrorMessageParser(objReg)));
+        regs.add(context.registerMessageParser(Stateful07ErrorMessageParser.TYPE,
+            new Stateful07ErrorMessageParser(objReg)));
         regs.add(context.registerMessageSerializer(Pcerr.class, new Stateful07ErrorMessageParser(objReg)));
 
         final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
         final VendorInformationTlvRegistry viTlvReg = context.getVendorInformationTlvRegistry();
-        regs.add(context.registerObjectParser(Stateful07LspObjectParser.CLASS, Stateful07LspObjectParser.TYPE,
-            new Stateful07LspObjectParser(tlvReg, viTlvReg)));
+        regs.add(context.registerObjectParser(new Stateful07LspObjectParser(tlvReg, viTlvReg)));
         regs.add(context.registerObjectSerializer(Lsp.class, new Stateful07LspObjectParser(tlvReg, viTlvReg)));
-        regs.add(context.registerObjectParser(Stateful07SrpObjectParser.CLASS, Stateful07SrpObjectParser.TYPE,
-            new Stateful07SrpObjectParser(tlvReg, viTlvReg)));
+        regs.add(context.registerObjectParser(new Stateful07SrpObjectParser(tlvReg, viTlvReg)));
         regs.add(context.registerObjectSerializer(Srp.class, new Stateful07SrpObjectParser(tlvReg, viTlvReg)));
-        regs.add(context.registerObjectParser(Stateful07OpenObjectParser.CLASS, Stateful07OpenObjectParser.TYPE,
-            new Stateful07OpenObjectParser(tlvReg, viTlvReg)));
+        regs.add(context.registerObjectParser(new Stateful07OpenObjectParser(tlvReg, viTlvReg)));
         regs.add(context.registerObjectSerializer(Open.class, new Stateful07OpenObjectParser(tlvReg, viTlvReg)));
 
-        regs.add(context.registerTlvParser(Stateful07LSPIdentifierIpv4TlvParser.TYPE, new Stateful07LSPIdentifierIpv4TlvParser()));
-        regs.add(context.registerTlvParser(Stateful07LSPIdentifierIpv6TlvParser.TYPE, new Stateful07LSPIdentifierIpv6TlvParser()));
+        regs.add(context.registerTlvParser(Stateful07LSPIdentifierIpv4TlvParser.TYPE,
+            new Stateful07LSPIdentifierIpv4TlvParser()));
+        regs.add(context.registerTlvParser(Stateful07LSPIdentifierIpv6TlvParser.TYPE,
+            new Stateful07LSPIdentifierIpv6TlvParser()));
         regs.add(context.registerTlvSerializer(LspIdentifiers.class, new Stateful07LSPIdentifierIpv4TlvParser()));
-        regs.add(context.registerTlvParser(Stateful07LspUpdateErrorTlvParser.TYPE, new Stateful07LspUpdateErrorTlvParser()));
+        regs.add(context.registerTlvParser(Stateful07LspUpdateErrorTlvParser.TYPE,
+            new Stateful07LspUpdateErrorTlvParser()));
         regs.add(context.registerTlvSerializer(LspErrorCode.class, new Stateful07LspUpdateErrorTlvParser()));
-        regs.add(context.registerTlvParser(Stateful07RSVPErrorSpecTlvParser.TYPE, new Stateful07RSVPErrorSpecTlvParser()));
+        regs.add(context.registerTlvParser(Stateful07RSVPErrorSpecTlvParser.TYPE,
+            new Stateful07RSVPErrorSpecTlvParser()));
         regs.add(context.registerTlvSerializer(RsvpErrorSpec.class, new Stateful07RSVPErrorSpecTlvParser()));
-        regs.add(context.registerTlvParser(Stateful07StatefulCapabilityTlvParser.TYPE, new Stateful07StatefulCapabilityTlvParser()));
+        regs.add(context.registerTlvParser(Stateful07StatefulCapabilityTlvParser.TYPE,
+            new Stateful07StatefulCapabilityTlvParser()));
         regs.add(context.registerTlvSerializer(Stateful.class, new Stateful07StatefulCapabilityTlvParser()));
-        regs.add(context.registerTlvParser(Stateful07LspSymbolicNameTlvParser.TYPE, new Stateful07LspSymbolicNameTlvParser()));
+        regs.add(context.registerTlvParser(Stateful07LspSymbolicNameTlvParser.TYPE,
+            new Stateful07LspSymbolicNameTlvParser()));
         regs.add(context.registerTlvSerializer(SymbolicPathName.class, new Stateful07LspSymbolicNameTlvParser()));
         regs.add(context.registerTlvParser(PathBindingTlvParser.TYPE, new PathBindingTlvParser()));
         regs.add(context.registerTlvSerializer(PathBinding.class, new PathBindingTlvParser()));
index 831d17307abffe035a82786d71ce613052d0ed83..459f5e42181ed91a04f71d6cf1febe4fe6d199f7 100644 (file)
@@ -27,12 +27,10 @@ public class SyncOptimizationsActivator extends AbstractPCEPExtensionProviderAct
 
         final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
         final VendorInformationTlvRegistry viTlvReg = context.getVendorInformationTlvRegistry();
-        regs.add(context.registerObjectParser(SyncOptimizationsLspObjectParser.CLASS, SyncOptimizationsLspObjectParser.TYPE,
-            new SyncOptimizationsLspObjectParser(tlvReg, viTlvReg)));
+        regs.add(context.registerObjectParser(new SyncOptimizationsLspObjectParser(tlvReg, viTlvReg)));
         regs.add(context.registerObjectSerializer(Lsp.class, new SyncOptimizationsLspObjectParser(tlvReg, viTlvReg)));
 
-        regs.add(context.registerObjectParser(SyncOptimizationsOpenObjectParser.CLASS, SyncOptimizationsOpenObjectParser.TYPE,
-            new SyncOptimizationsOpenObjectParser(tlvReg, viTlvReg)));
+        regs.add(context.registerObjectParser(new SyncOptimizationsOpenObjectParser(tlvReg, viTlvReg)));
         regs.add(context.registerObjectSerializer(Open.class, new SyncOptimizationsOpenObjectParser(tlvReg, viTlvReg)));
 
         regs.add(context.registerTlvParser(LspDbVersionTlvParser.TYPE, new LspDbVersionTlvParser()));
@@ -41,7 +39,8 @@ public class SyncOptimizationsActivator extends AbstractPCEPExtensionProviderAct
         regs.add(context.registerTlvParser(SpeakerEntityIdTlvParser.TYPE, new SpeakerEntityIdTlvParser()));
         regs.add(context.registerTlvSerializer(SpeakerEntityId.class, new SpeakerEntityIdTlvParser()));
 
-        regs.add(context.registerTlvParser(SyncOptimizationsCapabilityTlvParser.TYPE, new SyncOptimizationsCapabilityTlvParser()));
+        regs.add(context.registerTlvParser(SyncOptimizationsCapabilityTlvParser.TYPE,
+            new SyncOptimizationsCapabilityTlvParser()));
         regs.add(context.registerTlvSerializer(Stateful.class, new SyncOptimizationsCapabilityTlvParser()));
 
         return regs;
index 13ef8b6380871bb5bff172c5a001aaa9cad7a0b6..bbb5ce21af3243678daff556e5ad1549aed10884 100644 (file)
@@ -1044,7 +1044,8 @@ public class PCEPObjectParserTest {
 
     @Test
     public void testEmptyEroObject() throws PCEPDeserializerException {
-        final Object object = this.ctx.getObjectHandlerRegistry().parseObject(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE, new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
+        final Object object = this.ctx.getObjectHandlerRegistry().parseObject(7, 1,
+            new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
         assertNotNull(object);
         assertTrue(object instanceof Ero);
         final Ero eroObject = (Ero) object;
index de17feb5d3ff6bcebbcf8e5df811de09aea10251..08db27af49b5263244c9dc19b5f76bab7adfe16b 100644 (file)
@@ -12,7 +12,6 @@ import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
 import org.opendaylight.protocol.pcep.parser.object.AbstractVendorInformationObjectParser;
-import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.EnterpriseSpecificInformation;
 
@@ -20,6 +19,10 @@ public class TestVendorInformationObjectParser extends AbstractVendorInformation
 
     private static final EnterpriseNumber TEST_ENTERPRISE_NUMBER = new EnterpriseNumber(0L);
 
+    public TestVendorInformationObjectParser() {
+        super(0, 0);
+    }
+
     @Override
     public void serializeEnterpriseSpecificInformation(final EnterpriseSpecificInformation enterpriseSpecificInformation,
             final ByteBuf buffer) {
@@ -35,5 +38,4 @@ public class TestVendorInformationObjectParser extends AbstractVendorInformation
     public EnterpriseNumber getEnterpriseNumber() {
         return TEST_ENTERPRISE_NUMBER;
     }
-
 }
index ea12231295606ea1160e32b8dfc66f15345c1d7c..1d161c13e01978eef87d04b7ddda0a848c9fb999 100644 (file)
@@ -18,8 +18,7 @@ public class PCCActivator extends AbstractPCEPExtensionProviderActivator {
     @Override
     protected List<AutoCloseable> startImpl(final PCEPExtensionProviderContext context) {
         final List<AutoCloseable> regs = new ArrayList<>();
-        regs.add(context.registerObjectParser(PCCEndPointIpv4ObjectParser.CLASS, PCCEndPointIpv4ObjectParser.TYPE,
-                new PCCEndPointIpv4ObjectParser()));
+        regs.add(context.registerObjectParser(new PCCEndPointIpv4ObjectParser()));
         return regs;
     }
 
index 7ca5e67b8ad1d0a3e0dc9a12051a60296b440163..de031a1b8e73bd76d6455c96b53c0ee6ccc09d0a 100644 (file)
@@ -99,8 +99,7 @@ public class SegmentRoutingActivator extends AbstractPCEPExtensionProviderActiva
         /* Objects */
         final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
         final VendorInformationTlvRegistry viTlvRegistry = context.getVendorInformationTlvRegistry();
-        regs.add(context.registerObjectParser(PcepOpenObjectWithSpcTlvParser.CLASS,
-                PcepOpenObjectWithSpcTlvParser.TYPE, new PcepOpenObjectWithSpcTlvParser(tlvReg, viTlvRegistry)));
+        regs.add(context.registerObjectParser(new PcepOpenObjectWithSpcTlvParser(tlvReg, viTlvRegistry)));
         regs.add(context.registerObjectSerializer(Open.class, new PcepOpenObjectWithSpcTlvParser(tlvReg, viTlvRegistry)));
 
         return regs;
index 7a4a4a8297b382face76b4039bcfc01a4bf4b200..edfdc400f75547d62dd2fbd56604a6de89e86f6f 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractObjectWithTlvsParser<T> implements ObjectParser, ObjectSerializer {
+public abstract class AbstractObjectWithTlvsParser<T> extends CommonObjectParser implements ObjectSerializer {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractObjectWithTlvsParser.class);
 
@@ -29,7 +29,9 @@ public abstract class AbstractObjectWithTlvsParser<T> implements ObjectParser, O
 
     private final VendorInformationTlvRegistry viTlvReg;
 
-    protected AbstractObjectWithTlvsParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+    protected AbstractObjectWithTlvsParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg,
+        final int objectClass, final int objectType) {
+        super(objectClass, objectType);
         this.tlvReg = requireNonNull(tlvReg);
         this.viTlvReg = requireNonNull(viTlvReg);
     }
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/CommonObjectParser.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/CommonObjectParser.java
new file mode 100644 (file)
index 0000000..56663f7
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.spi;
+
+public abstract class CommonObjectParser implements ObjectParser {
+    private final int objectClass;
+    private final int objectType;
+
+    public CommonObjectParser(final int objectClass, final int objectType) {
+        this.objectClass = objectClass;
+        this.objectType = objectType;
+    }
+
+    @Override
+    public final int getObjectClass() {
+        return this.objectClass;
+    }
+
+    @Override
+    public final int getObjectType() {
+        return this.objectType;
+    }
+}
index bf480209bec114f4a5fed0e204999e750f8490e1..0df546b8b4b8853cecef29fcff1158e54453e9c7 100644 (file)
@@ -8,9 +8,11 @@
 package org.opendaylight.protocol.pcep.spi;
 
 import io.netty.buffer.ByteBuf;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
 
+/**
+ * Explicit Route Object Parser.
+ */
 public interface EROSubobjectParser {
     Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException;
 }
index 2ef32ca4f17e8bfec26e3d6af340ac3b25dd7b44..e331fec80109937a3612f1740fbaeb83009006f9 100644 (file)
@@ -8,26 +8,29 @@
 package org.opendaylight.protocol.pcep.spi;
 
 import io.netty.buffer.ByteBuf;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
 
+/**
+ * Explicit Route Object Registry.
+ */
 public interface EROSubobjectRegistry {
     /**
      * Finds parser for given subobject type in the registry. Delegates parsing to found parser.
      *
      * @param subobjectType subobject type, key in parser registry
-     * @param buffer subobject wrapped in ByteBuf
-     * @param loose ERO specific common field
+     * @param buffer        subobject wrapped in ByteBuf
+     * @param loose         ERO specific common field
      * @return null if the parser for this subobject could not be found
      * @throws PCEPDeserializerException if the parsing did not succeed
      */
-    Subobject parseSubobject(final int subobjectType, final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException;
+    Subobject parseSubobject(final int subobjectType, final ByteBuf buffer, final boolean loose)
+        throws PCEPDeserializerException;
 
     /**
      * Find serializer for given subobject. Delegates parsing to found serializer.
      *
      * @param subobject to be parsed
-     * @param buffer buffer where the serialized subobject will be parsed
+     * @param buffer    buffer where the serialized subobject will be parsed
      */
     void serializeSubobject(final Subobject subobject, final ByteBuf buffer);
 }
index 40f0eb2c09c16b522a8e8d8c8569fa045037596e..7d8dba7f564daf8e4d6ec78b2167de3b2a4d9e9f 100644 (file)
@@ -8,10 +8,11 @@
 package org.opendaylight.protocol.pcep.spi;
 
 import io.netty.buffer.ByteBuf;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
 
+/**
+ * Explicit Route Object Serializer.
+ */
 public interface EROSubobjectSerializer {
-
     void serializeSubobject(final Subobject subobject, final ByteBuf buffer);
 }
index 0312482c08eb726da88c9a3946f817fae16bcff4..69378dda3dbd9c65ea78dbc4a70dbcffd3c5e640 100644 (file)
@@ -14,4 +14,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 
 public interface ObjectParser {
     Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException;
+
+    int getObjectClass();
+
+    int getObjectType();
 }
index 7a343e0b6f4d30f4b42f61af6ee44f3255dc2b7d..9e8ffc3260a9581982926547f4d91956208f0ef5 100644 (file)
@@ -28,6 +28,9 @@ public interface PCEPExtensionProviderContext extends PCEPExtensionConsumerConte
 
     AutoCloseable registerMessageSerializer(Class<? extends Message> msgClass, MessageSerializer serializer);
 
+    AutoCloseable registerObjectParser(ObjectParser parser);
+
+    @Deprecated
     AutoCloseable registerObjectParser(int objectClass, int objectType, ObjectParser parser);
 
     AutoCloseable registerObjectSerializer(Class<? extends Object> objClass, ObjectSerializer serializer);
index 942bbc5478ebfaf94190cc75acb05d3bb9f0f317..6a19be81a2d394500390a41fa8e18bf7988a9e12 100644 (file)
@@ -11,6 +11,9 @@ import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobject;
 
+/**
+ * Reported Route Object Parser.
+ */
 public interface RROSubobjectParser {
     Subobject parseSubobject(ByteBuf buffer) throws PCEPDeserializerException;
 }
index fbc3c425eb6e22e707a50105969b6e27b58146e8..4a9372a52b1e6e0d741ad108ab58a67d03bb7ccd 100644 (file)
@@ -10,6 +10,9 @@ package org.opendaylight.protocol.pcep.spi;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobject;
 
+/**
+ * Reported Route Object Registry.
+ */
 public interface RROSubobjectRegistry {
     /**
      * Finds parser for given subobject type in the registry. Delegates parsing to found parser.
index 093f8af0555559881e61a05a5ad2a3e8be602b37..e728ade9d361e296584aa692cd4df2ed984616a2 100644 (file)
@@ -11,7 +11,9 @@ import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobject;
 
+/**
+ * Reported Route Object Serializer.
+ */
 public interface RROSubobjectSerializer {
-
     void serializeSubobject(final Subobject subobject, final ByteBuf buffer);
 }
index baf31761c58fdf415ffee6401beb8893283638aa..99b3982ba9eefcce0b13f6e6dd0663a580995c35 100644 (file)
@@ -132,6 +132,11 @@ public class SimplePCEPExtensionProviderContext implements PCEPExtensionProvider
         return this.objReg.registerObjectParser(objectClass, objectType, parser);
     }
 
+    @Override
+    public final AutoCloseable registerObjectParser(final ObjectParser parser) {
+        return this.objReg.registerObjectParser(parser.getObjectClass(), parser.getObjectType(), parser);
+    }
+
     @Override
     public final AutoCloseable registerObjectSerializer(final Class<? extends Object> objClass, final ObjectSerializer serializer) {
         return this.objReg.registerObjectSerializer(objClass, serializer);
index 16594189dad0a48ff6a719801f5e81d9d133986a..fc1f7e0bcb7433f2dbde1533db2f6f777124b328 100644 (file)
@@ -47,7 +47,7 @@ public class AbstractObjectWithTlvsTest {
     private class Abs extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
         protected Abs(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
-            super(tlvReg, viTlvReg);
+            super(tlvReg, viTlvReg, 0, 0);
         }
 
         @Override
index e00edae059a3c4ebde6ee0fcfb0abd60a53643ff..e9f853e30e9aa26d029f42bb2a89fd2a512cbaa9 100644 (file)
@@ -68,6 +68,7 @@ public class RegistryTest {
 
     @Mock
     ObjectParser objectParser;
+
     @Mock
     ObjectSerializer objectSerializer;
 
@@ -117,6 +118,8 @@ public class RegistryTest {
         Mockito.doReturn(this.viTlv).when(this.tlvParser).parseTlv(Mockito.any(ByteBuf.class));
         Mockito.doNothing().when(this.tlvSerializer).serializeTlv(Mockito.any(Tlv.class), Mockito.any(ByteBuf.class));
 
+        Mockito.doReturn(5).when(this.objectParser).getObjectClass();
+        Mockito.doReturn(1).when(this.objectParser).getObjectType();
         Mockito.doReturn(new OpenBuilder().build()).when(this.objectParser).parseObject(Mockito.any(ObjectHeader.class), Mockito.any(ByteBuf.class));
         Mockito.doNothing().when(this.objectSerializer).serializeObject(Mockito.any(Object.class), Mockito.any(ByteBuf.class));
 
@@ -149,7 +152,7 @@ public class RegistryTest {
         this.regs.add(this.ctx.registerTlvParser(1, this.tlvParser));
         this.regs.add(this.ctx.registerTlvSerializer(OfList.class, this.tlvSerializer));
 
-        this.regs.add(this.ctx.registerObjectParser(5, 1, this.objectParser));
+        this.regs.add(this.ctx.registerObjectParser(this.objectParser));
         this.regs.add(this.ctx.registerObjectSerializer(Rp.class, this.objectSerializer));
 
         this.regs.add(this.ctx.registerMessageParser(6, this.msgParser));