@Test public void testFilter() throws Exception { sequenceEntries.add(getPeerEntry(FilterEntryType.Deny, MaskRangeOperator.Ge, 150)); sequenceEntries.add(getPeerEntry(FilterEntryType.Deny, MaskRangeOperator.Eq, 15)); sequenceEntries.add(getPeerEntry(FilterEntryType.Deny, MaskRangeOperator.Le, 3)); sequenceEntries.add(getPeerEntry(FilterEntryType.Permit, MaskRangeOperator.Eq, 5)); sequenceEntries.add(getPeerEntry(FilterEntryType.Permit, MaskRangeOperator.Ge, 10)); assertFalse(filter.apply(getBinding(5))); assertFalse(filter.apply(getBinding(10))); assertFalse(filter.apply(getBinding(50))); assertTrue(filter.apply(getBinding(0))); assertTrue(filter.apply(getBinding(15))); assertTrue(filter.apply(getBinding(150))); assertTrue(filter.apply(getBinding(200))); assertTrue(filter.apply(getBinding(3))); }
@Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; }
PeerSequenceFilter extends SxpBindingFilter<PeerSequenceFilterEntries, T> { @Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; } }
PeerSequenceFilter extends SxpBindingFilter<PeerSequenceFilterEntries, T> { @Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; } protected  PeerSequenceFilter(T filter, String peerGroupName); }
PeerSequenceFilter extends SxpBindingFilter<PeerSequenceFilterEntries, T> { @Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; } protected  PeerSequenceFilter(T filter, String peerGroupName);  }
PeerSequenceFilter extends SxpBindingFilter<PeerSequenceFilterEntries, T> { @Override protected boolean filter(PeerSequenceFilterEntries filterEntries, SxpBindingFields binding) { if (filterEntries.getPeerSequenceEntry() == null || filterEntries.getPeerSequenceEntry().isEmpty() || binding.getPeerSequence() == null || binding.getPeerSequence().getPeer() == null) { return true; } int peerSeqLength = MasterDBBindingComparator.getPeerSequenceLength(binding); for (PeerSequenceEntry psEntry : filterEntries.getPeerSequenceEntry()) { boolean entryMatch = false; switch (psEntry.getPeerSequenceRange()) { case Ge: entryMatch = peerSeqLength >= psEntry.getPeerSequenceLength(); break; case Le: entryMatch = peerSeqLength <= psEntry.getPeerSequenceLength(); break; case Eq: entryMatch = peerSeqLength == psEntry.getPeerSequenceLength(); break; } if (entryMatch) { return FilterEntryType.Deny.equals(psEntry.getEntryType()); } } return true; } protected  PeerSequenceFilter(T filter, String peerGroupName);   }