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());
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;
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
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);
}
}
@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}),
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());
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);
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);
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));
}
}
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;
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);
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);
}
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;
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) {
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);
}
}
}
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;
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);
}
}
-
}
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;
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);
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);
}
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;
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 {
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;
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);
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: <= "
}
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);
}
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;
/**
* 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);
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;
/**
* 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.
*/
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.");
/**
* 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
private static final int FLAGS_F_LENGTH = 1;
public PCEPCloseObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
- super(tlvReg, viTlvReg);
+ super(tlvReg, viTlvReg, CLASS, TYPE);
}
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;
/**
* 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 {
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;
/**
* 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 {
/**
* 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());
@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);
}
@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());
}
*/
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());
@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);
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;
/**
* 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 {
/**
* 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
@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);
*/
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());
@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);
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;
/**
* 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);
@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);
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;
/**
* 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());
@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);
*/
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
private static final int RESERVED = 1;
public PCEPLspaObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
- super(tlvReg, viTlvReg);
+ super(tlvReg, viTlvReg, CLASS, TYPE);
}
@Override
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;
/**
* 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
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.");
*/
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;
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
*/
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
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
/**
* 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
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());
@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);
}
@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());
}
/**
* 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());
@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");
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
private static final int PCEP_VERSION = 1;
public PCEPOpenObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
- super(tlvReg, viTlvReg);
+ super(tlvReg, viTlvReg, CLASS, TYPE);
}
@Override
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;
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);
@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();
}
-
}
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;
/**
* 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();
@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);
* 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();
}
-
}
* 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 {
builder.setIpAddress(new IpAddressNoZone(Ipv6Util.noZoneAddressForByteBuf(buffer)));
return builder.build();
}
-
}
* @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 {
builder.setIpAddress(new IpAddressNoZone(Ipv4Util.noZoneAddressForByteBuf(buffer)));
return builder.build();
}
-
}
* @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 {
builder.setIpAddress(new IpAddressNoZone(Ipv6Util.noZoneAddressForByteBuf(buffer)));
return builder.build();
}
-
}
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;
* 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);
@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);
builder.setVarianceProcTime(buffer.readUnsignedInt());
return builder.build();
}
-
}
/**
* 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());
@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);
*/
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
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
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;
/**
* 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
*/
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.");
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;
*/
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)
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());
*/
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;
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
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()));
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()));
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;
@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;
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;
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) {
public EnterpriseNumber getEnterpriseNumber() {
return TEST_ENTERPRISE_NUMBER;
}
-
}
@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;
}
/* 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;
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);
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);
}
--- /dev/null
+/*
+ * 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;
+ }
+}
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;
}
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);
}
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);
}
public interface ObjectParser {
Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException;
+
+ int getObjectClass();
+
+ int getObjectType();
}
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);
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;
}
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.
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);
}
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);
private class Abs extends AbstractObjectWithTlvsParser<TlvsBuilder> {
protected Abs(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
- super(tlvReg, viTlvReg);
+ super(tlvReg, viTlvReg, 0, 0);
}
@Override
@Mock
ObjectParser objectParser;
+
@Mock
ObjectSerializer objectSerializer;
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));
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));