use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev200120.cluster.id.set.ClusterIdSet 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.rev200120.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.odl.bgp._default.policy.rev200120.cluster.id.set.ClusterIdSet in project bgpcep by opendaylight.
the class MatchClusterIdSetHandler method loadSets.
private ClusterIdSet loadSets(final String key) throws ExecutionException, InterruptedException {
final ReadOnlyTransaction tr = this.dataBroker.newReadOnlyTransaction();
final Optional<ClusterIdSet> result = tr.read(LogicalDatastoreType.CONFIGURATION, CLUSTERS_ID_SETS_IID.child(ClusterIdSet.class, new ClusterIdSetKey(key))).get();
return result.orNull();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev200120.cluster.id.set.ClusterIdSet 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;
}
Aggregations