X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pcep%2Fspi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fpcep%2Fspi%2FAbstractObjectWithTlvsParser.java;h=f6999e16ece31bc8a7c36fc4695708a00400ccdd;hb=1f18c032706004ce9bf0fcc648090ec5211b945a;hp=816f1d59f2927ea1f07866e952008c494979cd62;hpb=0b2c48e5063a5a53d9c09dfd14bdaf86b02352ca;p=bgpcep.git diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java index 816f1d59f2..f6999e16ec 100644 --- a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java +++ b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java @@ -7,31 +7,33 @@ */ package org.opendaylight.protocol.pcep.spi; -import com.google.common.base.Optional; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; import java.util.List; +import java.util.Optional; 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.Tlv; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class AbstractObjectWithTlvsParser implements ObjectParser, ObjectSerializer { +public abstract class AbstractObjectWithTlvsParser extends CommonObjectParser implements ObjectSerializer { private static final Logger LOG = LoggerFactory.getLogger(AbstractObjectWithTlvsParser.class); - public static final int PADDED_TO = 4; - private final TlvRegistry tlvReg; private final VendorInformationTlvRegistry viTlvReg; - protected AbstractObjectWithTlvsParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) { - this.tlvReg = Preconditions.checkNotNull(tlvReg); - this.viTlvReg = Preconditions.checkNotNull(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); } protected final void parseTlvs(final T builder, final ByteBuf bytes) throws PCEPDeserializerException { @@ -70,7 +72,7 @@ public abstract class AbstractObjectWithTlvsParser implements ObjectParser, O } protected final void serializeTlv(final Tlv tlv, final ByteBuf buffer) { - Preconditions.checkNotNull(tlv, "PCEP TLV is mandatory."); + requireNonNull(tlv, "PCEP TLV is mandatory."); LOG.trace("Serializing PCEP TLV {}", tlv); this.tlvReg.serializeTlv(tlv, buffer); LOG.trace("Serialized PCEP TLV : {}.", ByteBufUtil.hexDump(buffer));