@Test public void testOperatorMustPassAll() { filter1.setFieldName(WebPage.Field.OUTLINKS.toString()); filter1.setMapKey(new Utf8("example")); filter1.setFilterOp(FilterOp.EQUALS); filter1.setFilterIfMissing(true); filter1.getOperands().add(new Utf8("http: filter2.setFieldName(WebPage.Field.OUTLINKS.toString()); filter2.setFilterOp(FilterOp.EQUALS); filter2.setFilterIfMissing(true); filter2.getOperands().add(new Utf8("http: WebPage page = WebPage.newBuilder().build(); page.getOutlinks().put(new Utf8("example"), new Utf8("http: filterList = new FilterList<>(Operator.MUST_PASS_ALL, fList); assertTrue(filterList.filter("irrelevant", page)); }
@Override public boolean filter(K key, T persistent) { boolean filtered = false; switch (operator.toString()) { case "MUST_PASS_ALL": for (Filter<K, T> filter: filters) { if (!filter.filter(key, persistent)) { return !filtered; } } break; case "MUST_PASS_ONE": for (Filter<K, T> filter: filters) { if (filter.filter(key, persistent)) { return !filtered; } } break; default: throw new IllegalStateException(operator + " not yet implemented!"); } return filtered; }
FilterList implements Filter<K, T> { @Override public boolean filter(K key, T persistent) { boolean filtered = false; switch (operator.toString()) { case "MUST_PASS_ALL": for (Filter<K, T> filter: filters) { if (!filter.filter(key, persistent)) { return !filtered; } } break; case "MUST_PASS_ONE": for (Filter<K, T> filter: filters) { if (filter.filter(key, persistent)) { return !filtered; } } break; default: throw new IllegalStateException(operator + " not yet implemented!"); } return filtered; } }
FilterList implements Filter<K, T> { @Override public boolean filter(K key, T persistent) { boolean filtered = false; switch (operator.toString()) { case "MUST_PASS_ALL": for (Filter<K, T> filter: filters) { if (!filter.filter(key, persistent)) { return !filtered; } } break; case "MUST_PASS_ONE": for (Filter<K, T> filter: filters) { if (filter.filter(key, persistent)) { return !filtered; } } break; default: throw new IllegalStateException(operator + " not yet implemented!"); } return filtered; } FilterList();  FilterList(final List<Filter<K, T>> rowFilters);  FilterList(final Operator operator);  FilterList(final Operator operator, final List<Filter<K, T>> rowFilters); }
FilterList implements Filter<K, T> { @Override public boolean filter(K key, T persistent) { boolean filtered = false; switch (operator.toString()) { case "MUST_PASS_ALL": for (Filter<K, T> filter: filters) { if (!filter.filter(key, persistent)) { return !filtered; } } break; case "MUST_PASS_ONE": for (Filter<K, T> filter: filters) { if (filter.filter(key, persistent)) { return !filtered; } } break; default: throw new IllegalStateException(operator + " not yet implemented!"); } return filtered; } FilterList();  FilterList(final List<Filter<K, T>> rowFilters);  FilterList(final Operator operator);  FilterList(final Operator operator, final List<Filter<K, T>> rowFilters); List<Filter<K, T>> getFilters(); Operator getOperator(); void addFilter(Filter<K, T> filter); @Override void readFields(DataInput in); @Override void write(DataOutput out); @Override boolean filter(K key, T persistent); }
FilterList implements Filter<K, T> { @Override public boolean filter(K key, T persistent) { boolean filtered = false; switch (operator.toString()) { case "MUST_PASS_ALL": for (Filter<K, T> filter: filters) { if (!filter.filter(key, persistent)) { return !filtered; } } break; case "MUST_PASS_ONE": for (Filter<K, T> filter: filters) { if (filter.filter(key, persistent)) { return !filtered; } } break; default: throw new IllegalStateException(operator + " not yet implemented!"); } return filtered; } FilterList();  FilterList(final List<Filter<K, T>> rowFilters);  FilterList(final Operator operator);  FilterList(final Operator operator, final List<Filter<K, T>> rowFilters); List<Filter<K, T>> getFilters(); Operator getOperator(); void addFilter(Filter<K, T> filter); @Override void readFields(DataInput in); @Override void write(DataOutput out); @Override boolean filter(K key, T persistent);  }