@Test public void testGenerateFilter() throws Exception { SxpBindingFilter bindingFilter = SxpBindingFilter.generateFilter(getAclFilter(FilterType.Inbound), "TEST"); assertEquals("TEST", bindingFilter.getIdentifier()); assertEquals(new org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.filter.rev150911.sxp.filter.SxpFilterBuilder( getAclFilter(FilterType.Inbound)).build(), bindingFilter.getSxpFilter()); bindingFilter = SxpBindingFilter.generateFilter(getPrefixListFilter(FilterType.Inbound), "TEST1"); assertEquals("TEST1", bindingFilter.getIdentifier()); assertEquals(new org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.filter.rev150911.sxp.filter.SxpFilterBuilder( getPrefixListFilter(FilterType.Inbound)).build(), bindingFilter.getSxpFilter()); bindingFilter = SxpBindingFilter.generateFilter(getPeerSequenceFilter(FilterType.Inbound), "TEST2"); assertEquals("TEST2", bindingFilter.getIdentifier()); assertEquals(new org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.filter.rev150911.sxp.filter.SxpFilterBuilder( getPeerSequenceFilter(FilterType.Inbound)).build(), bindingFilter.getSxpFilter()); SxpFilter filter = null; try { SxpBindingFilter.generateFilter(filter, null); fail(); } catch (IllegalArgumentException e) { } try { SxpBindingFilter.generateFilter(getAclFilter(FilterType.Outbound), null); fail(); } catch (IllegalArgumentException e) { } try { SxpBindingFilter.generateFilter(getPrefixListFilter(FilterType.Outbound), null); fail(); } catch (IllegalArgumentException e) { } try { SxpBindingFilter.generateFilter(getPeerSequenceFilter(FilterType.Outbound), null); fail(); } catch (IllegalArgumentException e) { } try { SxpBindingFilter.generateFilter(filter, "NAME"); fail(); } catch (IllegalArgumentException e) { } try { SxpFilter f = null; SxpBindingFilter.generateFilter(f, "NAME"); fail(); } catch (IllegalArgumentException e) { } }
public static <T extends SxpFilterFields> SxpBindingFilter<?, ? extends SxpFilterFields> generateFilter(T filter, String peerGroupName) { if (peerGroupName == null) { throw new IllegalArgumentException("PeerGroup name cannot be null"); } if (filter == null) { throw new IllegalArgumentException("Filter cannot be null"); } if (filter.getFilterEntries() instanceof AclFilterEntries) { return new AclFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PrefixListFilterEntries) { return new PrefixListFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PeerSequenceFilterEntries) { return new PeerSequenceFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.PeerSequence).build(), peerGroupName); } throw new IllegalArgumentException("Undefined filter type " + filter); }
SxpBindingFilter implements Function<SxpBindingFields, Boolean>, Predicate<SxpBindingFields> { public static <T extends SxpFilterFields> SxpBindingFilter<?, ? extends SxpFilterFields> generateFilter(T filter, String peerGroupName) { if (peerGroupName == null) { throw new IllegalArgumentException("PeerGroup name cannot be null"); } if (filter == null) { throw new IllegalArgumentException("Filter cannot be null"); } if (filter.getFilterEntries() instanceof AclFilterEntries) { return new AclFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PrefixListFilterEntries) { return new PrefixListFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PeerSequenceFilterEntries) { return new PeerSequenceFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.PeerSequence).build(), peerGroupName); } throw new IllegalArgumentException("Undefined filter type " + filter); } }
SxpBindingFilter implements Function<SxpBindingFields, Boolean>, Predicate<SxpBindingFields> { public static <T extends SxpFilterFields> SxpBindingFilter<?, ? extends SxpFilterFields> generateFilter(T filter, String peerGroupName) { if (peerGroupName == null) { throw new IllegalArgumentException("PeerGroup name cannot be null"); } if (filter == null) { throw new IllegalArgumentException("Filter cannot be null"); } if (filter.getFilterEntries() instanceof AclFilterEntries) { return new AclFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PrefixListFilterEntries) { return new PrefixListFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PeerSequenceFilterEntries) { return new PeerSequenceFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.PeerSequence).build(), peerGroupName); } throw new IllegalArgumentException("Undefined filter type " + filter); } private  SxpBindingFilter(String identifier); protected  SxpBindingFilter(R filter, String identifier); }
SxpBindingFilter implements Function<SxpBindingFields, Boolean>, Predicate<SxpBindingFields> { public static <T extends SxpFilterFields> SxpBindingFilter<?, ? extends SxpFilterFields> generateFilter(T filter, String peerGroupName) { if (peerGroupName == null) { throw new IllegalArgumentException("PeerGroup name cannot be null"); } if (filter == null) { throw new IllegalArgumentException("Filter cannot be null"); } if (filter.getFilterEntries() instanceof AclFilterEntries) { return new AclFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PrefixListFilterEntries) { return new PrefixListFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PeerSequenceFilterEntries) { return new PeerSequenceFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.PeerSequence).build(), peerGroupName); } throw new IllegalArgumentException("Undefined filter type " + filter); } private  SxpBindingFilter(String identifier); protected  SxpBindingFilter(R filter, String identifier); R getSxpFilter(); String getIdentifier(); @Override Boolean apply(SxpBindingFields binding); @Override boolean test(SxpBindingFields binding); static SxpBindingFilter<?, ? extends SxpFilterFields> generateFilter(T filter,
            String peerGroupName); static SxpBindingFilter<?, ? extends SxpDomainFilterFields> generateFilter(
            T filter, String domainName); @Override boolean equals(Object o); @Override int hashCode(); static SxpBindingFilter<?, ? extends SxpFilterFields> mergeFilters(
            final Collection<SxpBindingFilter<?, ? extends SxpFilterFields>> values); static boolean checkInCompatibility(F filter1, F filter2); static SxpBindingFilter<?, ? extends SxpDomainFilterFields> mergeFilters(
            List<SxpBindingFilter<?, ? extends SxpDomainFilterFields>> values); }
SxpBindingFilter implements Function<SxpBindingFields, Boolean>, Predicate<SxpBindingFields> { public static <T extends SxpFilterFields> SxpBindingFilter<?, ? extends SxpFilterFields> generateFilter(T filter, String peerGroupName) { if (peerGroupName == null) { throw new IllegalArgumentException("PeerGroup name cannot be null"); } if (filter == null) { throw new IllegalArgumentException("Filter cannot be null"); } if (filter.getFilterEntries() instanceof AclFilterEntries) { return new AclFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PrefixListFilterEntries) { return new PrefixListFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.AccessOrPrefixList).build(), peerGroupName); } else if (filter.getFilterEntries() instanceof PeerSequenceFilterEntries) { return new PeerSequenceFilter<>( new SxpFilterBuilder(filter).setFilterSpecific(FilterSpecific.PeerSequence).build(), peerGroupName); } throw new IllegalArgumentException("Undefined filter type " + filter); } private  SxpBindingFilter(String identifier); protected  SxpBindingFilter(R filter, String identifier); R getSxpFilter(); String getIdentifier(); @Override Boolean apply(SxpBindingFields binding); @Override boolean test(SxpBindingFields binding); static SxpBindingFilter<?, ? extends SxpFilterFields> generateFilter(T filter,
            String peerGroupName); static SxpBindingFilter<?, ? extends SxpDomainFilterFields> generateFilter(
            T filter, String domainName); @Override boolean equals(Object o); @Override int hashCode(); static SxpBindingFilter<?, ? extends SxpFilterFields> mergeFilters(
            final Collection<SxpBindingFilter<?, ? extends SxpFilterFields>> values); static boolean checkInCompatibility(F filter1, F filter2); static SxpBindingFilter<?, ? extends SxpDomainFilterFields> mergeFilters(
            List<SxpBindingFilter<?, ? extends SxpDomainFilterFields>> values);  }