1 package io.fd.honeycomb.lisp.translate.read.trait;
3 import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
4 import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
5 import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
7 import java.util.function.Predicate;
8 import javax.annotation.Nonnull;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMapping;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMapping;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtable;
13 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
14 import io.fd.vpp.jvpp.core.dto.LispEidTableDetails;
17 * Trait providing predicates to filter mappings to respective subtables
19 public interface MappingFilterProvider {
21 Predicate<LispEidTableDetails> BRIDGE_DOMAIN_MAPPINGS_ONLY =
22 (LispEidTableDetails detail) -> detail.eidType == MAC.getValue();
24 Predicate<LispEidTableDetails> VRF_MAPPINGS_ONLY =
25 (LispEidTableDetails detail) -> detail.eidType == IPV4.getValue() || detail.eidType == IPV6.getValue();
27 default Predicate<LispEidTableDetails> subtableFilterForLocalMappings(
28 @Nonnull final InstanceIdentifier<LocalMapping> identifier) {
30 if (identifier.firstIdentifierOf(VrfSubtable.class) != null) {
31 return VRF_MAPPINGS_ONLY;
32 } else if (identifier.firstIdentifierOf(BridgeDomainSubtable.class) != null) {
33 return BRIDGE_DOMAIN_MAPPINGS_ONLY;
35 throw new IllegalArgumentException("Cannot determine mappings predicate for " + identifier);
39 default Predicate<LispEidTableDetails> subtableFilterForRemoteMappings(
40 @Nonnull final InstanceIdentifier<RemoteMapping> identifier) {
42 if (identifier.firstIdentifierOf(VrfSubtable.class) != null) {
43 return VRF_MAPPINGS_ONLY;
44 } else if (identifier.firstIdentifierOf(BridgeDomainSubtable.class) != null) {
45 return BRIDGE_DOMAIN_MAPPINGS_ONLY;
47 throw new IllegalArgumentException("Cannot determine mappings predicate for " + identifier);