final ByteBuf serializedBuffer = Unpooled.buffer();
parser.serializeAttribute(pa.build(), serializedBuffer);
- assertArrayEquals(new byte[]{ (byte)192, 16, 8, (byte)128, 6, 0, 72, 0, 1, 2, 3,
- (byte)192, 16, 8, (byte)128, 7, 0, 0, 0, 0, 0, 3,
- (byte)192, 16, 8, (byte)128, 8, 0, 35, 4, 2, 8, 7,
- (byte)192, 16, 8, (byte)128, 9, 0, 0, 0, 0, 0, 63 }, ByteArray.readAllBytes(serializedBuffer));
+ assertArrayEquals(new byte[]{ (byte)192, 16, 32, (byte)128, 6, 0, 72, 0, 1, 2, 3,
+ (byte)128, 7, 0, 0, 0, 0, 0, 3,
+ (byte)128, 8, 0, 35, 4, 2, 8, 7,
+ (byte)128, 9, 0, 0, 0, 0, 0, 63 }, ByteArray.readAllBytes(serializedBuffer));
try {
parser.parseAttribute(Unpooled.copiedBuffer(new byte[] { 11, 11, 21, 45, 5, 4, 3, 1 }), pa);
}
// this sub-TLV contains eight 32-bit IEEE floating point numbers
final List<UnreservedBandwidth> ubList = linkAttributes.getUnreservedBandwidth();
- if (ubList != null && !ubList.isEmpty()) {
+ if (ubList != null) {
final ByteBuf unreservedBandwithBuf = Unpooled.buffer();
for (final UnreservedBandwidth unreservedBandwidth : ubList) {
unreservedBandwithBuf.writeBytes(unreservedBandwidth.getBandwidth().getValue());
TlvUtil.writeTLV(METRIC, Unpooled.copyMedium(linkAttributes.getMetric().getValue().intValue()), byteAggregator);
}
final List<SrlgId> srlgList = linkAttributes.getSharedRiskLinkGroups();
- if (srlgList != null && !srlgList.isEmpty()) {
+ if (srlgList != null) {
final ByteBuf sharedRLGBuf = Unpooled.buffer();
for (final SrlgId srlgId : srlgList) {
sharedRLGBuf.writeInt(srlgId.getValue().intValue());
LOG.trace("Started serializing Node Attributes");
final NodeAttributes nodeAttributes = nodeAttributesCase.getNodeAttributes();
final List<TopologyIdentifier> topList = nodeAttributes.getTopologyIdentifier();
- if (topList != null && !topList.isEmpty()) {
+ if (topList != null) {
final ByteBuf mpIdBuf = Unpooled.buffer();
for (final TopologyIdentifier topologyIdentifier : topList) {
mpIdBuf.writeShort(topologyIdentifier.getValue());
TlvUtil.writeTLV(DYNAMIC_HOSTNAME, Unpooled.wrappedBuffer(Charsets.UTF_8.encode(nodeAttributes.getDynamicHostname())), byteAggregator);
}
final List<IsisAreaIdentifier> isisList = nodeAttributes.getIsisAreaId();
- if (isisList != null && !isisList.isEmpty()) {
+ if (isisList != null) {
for (final IsisAreaIdentifier isisAreaIdentifier : isisList) {
TlvUtil.writeTLV(ISIS_AREA_IDENTIFIER, Unpooled.wrappedBuffer(isisAreaIdentifier.getValue()), byteAggregator);
}
TlvUtil.writeTLV(ROUTE_TAG, routeTagsBuf, byteAggregator);
}
final List<ExtendedRouteTag> routeTagList = prefixAtrributes.getExtendedTags();
- if (routeTagList != null && !routeTagList.isEmpty()) {
+ if (routeTagList != null) {
final ByteBuf extendedBuf = Unpooled.buffer();
for (final ExtendedRouteTag extendedRouteTag : routeTagList) {
extendedBuf.writeBytes(extendedRouteTag.getValue());
@Override
public void serializeParameter(final BgpParameters parameter, final ByteBuf byteAggregator) {
- if (parameter.getOptionalCapabilities() != null && !parameter.getOptionalCapabilities().isEmpty()) {
- LOG.trace("Started serializing BGP Capability: {}", parameter.getOptionalCapabilities());
+ if (parameter.getOptionalCapabilities() != null) {
final ByteBuf buffer = Unpooled.buffer();
for (final OptionalCapabilities optionalCapa : parameter.getOptionalCapabilities()) {
+ LOG.trace("Started serializing BGP Capability: {}", optionalCapa);
serializeOptionalCapability(optionalCapa, buffer);
}
ParameterUtil.formatParameter(TYPE, buffer, byteAggregator);
Preconditions.checkArgument(attribute instanceof PathAttributes, "Attribute parameter is not a PathAttribute object.");
final PathAttributes pathAttributes = (PathAttributes) attribute;
final List<Communities> communities = pathAttributes.getCommunities();
- if (communities == null || communities.isEmpty()) {
+ if (communities == null) {
return;
}
final ByteBuf communitiesBuffer = Unpooled.buffer();
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
Preconditions.checkArgument(attribute instanceof PathAttributes, "Attribute parameter is not a PathAttribute object.");
final List<ExtendedCommunities> communitiesList = ((PathAttributes) attribute).getExtendedCommunities();
- if (communitiesList == null || communitiesList.isEmpty()) {
+ if (communitiesList == null) {
return;
}
+ final ByteBuf extendedCommunitiesBuffer = Unpooled.buffer();
for (final ExtendedCommunities extendedCommunities : communitiesList) {
- final ByteBuf extendedCommunitiesBuffer = Unpooled.buffer();
serializeHeader(extendedCommunities, extendedCommunitiesBuffer);
serializeExtendedCommunity(extendedCommunities, extendedCommunitiesBuffer);
- AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE, extendedCommunitiesBuffer, byteAggregator);
}
+ AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE, extendedCommunitiesBuffer, byteAggregator);
}
protected void serializeHeader(final ExtendedCommunities extendedCommunities, final ByteBuf extendedCommunitiesBuffer) {
final ByteBuf serializedBuffer = Unpooled.buffer();
parser.serializeAttribute(pa.build(), serializedBuffer);
- assertArrayEquals(new byte[]{ (byte)192, 16, 8, 0, 5, 0, 54, 0, 0, 1, 76,
- (byte)192, 16, 8, 40, 5, 0, 54, 0, 0, 1, 76,
- (byte)192, 16, 8, 1, 2, 0, 35, 4, 2, 8, 7,
- (byte)192, 16, 8, 0, 3, 0, 24, 4, 2, 8, 7,
- (byte)192, 16, 8, 41, 6, 12, 51, 2, 5, 21, 45,
- (byte)192, 16, 8, 3, 6, 21, 45, 5, 4, 3, 1,
- (byte)192, 16, 8, 43, 6, 21, 45, 5, 4, 3, 1 }, ByteArray.readAllBytes(serializedBuffer));
+ assertArrayEquals(new byte[]{ (byte)192, 16, 56, 0, 5, 0, 54, 0, 0, 1, 76,
+ 40, 5, 0, 54, 0, 0, 1, 76,
+ 1, 2, 0, 35, 4, 2, 8, 7,
+ 0, 3, 0, 24, 4, 2, 8, 7,
+ 41, 6, 12, 51, 2, 5, 21, 45,
+ 3, 6, 21, 45, 5, 4, 3, 1,
+ 43, 6, 21, 45, 5, 4, 3, 1 }, ByteArray.readAllBytes(serializedBuffer));
try {
parser.parseAttribute(Unpooled.copiedBuffer(new byte[] { 11, 11, 21, 45, 5, 4, 3, 1 }), pa);
serializeObject(req.getEro(), buffer);
serializeObject(req.getLspa(), buffer);
serializeObject(req.getBandwidth(), buffer);
- if (req.getMetrics() != null && !req.getMetrics().isEmpty()) {
+ if (req.getMetrics() != null) {
for (final Metrics m : req.getMetrics()) {
serializeObject(m.getMetric(), buffer);
}
serializeObject(p.getEro(), buffer);
serializeObject(p.getLspa(), buffer);
serializeObject(p.getBandwidth(), buffer);
- if (p.getMetrics() != null && !p.getMetrics().isEmpty()) {
+ if (p.getMetrics() != null) {
for (final Metrics m : p.getMetrics()) {
serializeObject(m.getMetric(), buffer);
}
serializeObject(p.getEro(), buffer);
serializeObject(p.getLspa(), buffer);
serializeObject(p.getBandwidth(), buffer);
- if (p.getMetrics() != null && !p.getMetrics().isEmpty()) {
+ if (p.getMetrics() != null) {
for (final Metrics m : p.getMetrics()) {
serializeObject(m.getMetric(), buffer);
}
}
@Override
- public void serializeMessage(Message message, ByteBuf out) {
+ public void serializeMessage(final Message message, final ByteBuf out) {
Preconditions.checkArgument(message instanceof Pcmonreq, "Wrong instance of Message. Passed instance of %s. Need Pcmonreq.", message.getClass());
final PcreqMessage msg = ((Pcmonreq) message).getPcreqMessage();
if (msg.getMonitoringRequest() == null) {
if (msg.getSvec() != null) {
serializeSvec(msg, buffer);
}
- if (msg.getRequests() != null && !msg.getRequests().isEmpty()) {
+ if (msg.getRequests() != null) {
serializeRequest(msg, buffer);
}
MessageUtil.formatMessage(TYPE, buffer, out);
}
@Override
- protected Message validate(List<Object> objects, List<Message> errors) throws PCEPDeserializerException {
+ protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
if (objects == null) {
throw new IllegalArgumentException("Passed list can't be null.");
}
mBuilder.setSvec(svecs);
}
final List<Requests> requests = getRequests(objects, errors);
- if (requests != null && !requests.isEmpty()) {
+ if (requests != null) {
mBuilder.setRequests(requests);
} else {
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.<Rp>absent()));
}
protected final void serializeSubobject(final List<Subobject> subobjects, final ByteBuf buffer) {
- if(subobjects != null && !subobjects.isEmpty()) {
+ if(subobjects != null) {
for (final Subobject subobject : subobjects) {
this.subobjReg.serializeSubobject(subobject, buffer);
}
}
protected static PCEPErrors validateSrEroSubobjects(final Ero ero) {
- if (ero.getSubobject() != null && !ero.getSubobject().isEmpty()) {
+ if (ero.getSubobject() != null) {
for (final Subobject subobject : ero.getSubobject()) {
if (!(subobject.getSubobjectType() instanceof SrEroSubobject)) {
return PCEPErrors.NON_IDENTICAL_ERO_SUBOBJECTS;
}
protected final void serializeVendorInformationObjects(final List<VendorInformationObject> viObjects, final ByteBuf buffer) {
- if (viObjects != null && !viObjects.isEmpty()) {
+ if (viObjects != null) {
for (final VendorInformationObject viObject : viObjects) {
this.viRegistry.serializeVendorInformationObject(viObject, buffer);
}
protected abstract void addVendorInformationTlvs(final T builder, final List<VendorInformationTlv> tlvs);
protected final void serializeVendorInformationTlvs(final List<VendorInformationTlv> tlvs, final ByteBuf buffer) {
- if (tlvs != null && !tlvs.isEmpty()) {
+ if (tlvs != null) {
for (final VendorInformationTlv tlv : tlvs) {
LOG.trace("Serializing VENDOR-INFORMATION TLV {}", tlv);
this.viTlvReg.serializeVendorInformationTlv(tlv, buffer);