use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.
the class MatchClusterIdSetHandler method matchClusterIdCondition.
private boolean matchClusterIdCondition(final ClusterIdentifier localClusterId, final ClusterId clusterId, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.match.cluster.id.set.condition.grouping.MatchClusterIdSetCondition matchClusterIdSetCondition) {
final ClusterIdSet clusterIdSet = this.sets.getUnchecked(StringUtils.substringBetween(matchClusterIdSetCondition.getClusterIdSet(), "=\"", "\""));
if (clusterIdSet == null) {
return false;
}
final MatchSetOptionsType matchOption = matchClusterIdSetCondition.getMatchSetOptions();
if (clusterId != null) {
List<ClusterIdentifier> newList = new ArrayList<>();
if (clusterIdSet.getClusterId() != null) {
newList.addAll(clusterIdSet.getClusterId());
}
if (clusterIdSet.getLocal() != null) {
newList.add(localClusterId);
}
final List<ClusterIdentifier> matchClusterList = clusterId.getCluster();
if (matchOption.equals(MatchSetOptionsType.ALL)) {
return matchClusterList.containsAll(newList) && newList.containsAll(matchClusterList);
}
final boolean noneInCommon = Collections.disjoint(matchClusterList, newList);
if (matchOption.equals(MatchSetOptionsType.ANY)) {
return !noneInCommon;
} else if (matchOption.equals(MatchSetOptionsType.INVERT)) {
return noneInCommon;
}
} else if (matchOption.equals(MatchSetOptionsType.INVERT)) {
return true;
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.
the class ExportAttributeTestUtil method createClusterIdInput.
private static ClusterId createClusterIdInput() {
final ClusterIdentifier cluster1 = new ClusterIdentifier(new Ipv4Address("1.1.1.1"));
final ClusterIdentifier cluster2 = new ClusterIdentifier(new Ipv4Address("1.1.1.2"));
return new ClusterIdBuilder().setCluster(Arrays.asList(cluster1, cluster2)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.
the class SetClusterIdPrependHandler method prependClusterId.
private Attributes prependClusterId(final Attributes attributes, final ClusterIdentifier clusterId) {
final AttributesBuilder newAtt = new AttributesBuilder(attributes);
final List<ClusterIdentifier> newClusterList = new ArrayList<>();
newClusterList.add(clusterId);
if (attributes.getClusterId() != null && !attributes.getClusterId().getCluster().isEmpty()) {
final List<ClusterIdentifier> oldList = attributes.getClusterId().getCluster();
newClusterList.addAll(oldList);
}
return newAtt.setClusterId(new ClusterIdBuilder().setCluster(newClusterList).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.
the class ClusterIdAttributeParserTest method testParseEmptyAttribute.
@Test
public void testParseEmptyAttribute() {
final Attributes clusterId = new AttributesBuilder().setClusterId(new ClusterIdBuilder().build()).build();
final ByteBuf output = Unpooled.buffer();
this.parser.serializeAttribute(clusterId, output);
assertEquals(Unpooled.buffer(), output);
}
Aggregations