@Override public ZippedFlow<A, B> filter(Predicate<? super Tuple<A, B>> predicate) { return create(tupleFlow.filter(predicate)); }
@Override public ZippedFlow<A, B> filter(Predicate<? super Tuple<A, B>> predicate) { return create(tupleFlow.filter(predicate)); }
private Flow<PlasticMethod> matchEventHandlerMethods(PlasticClass plasticClass) { return F.flow(plasticClass.getMethods()).filter(new Predicate<PlasticMethod>() { public boolean accept(PlasticMethod method) { return "getClientId".equalsIgnoreCase(method.getDescription().methodName); } }); } }
private Flow<PlasticMethod> matchAllMethodsNotOverriddenFromBaseClass(final PlasticClass plasticClass) { return F.flow(plasticClass.getMethods()).filter(new Predicate<PlasticMethod>() { public boolean accept(PlasticMethod method) { return !method.isOverride() && !lifecycleMethods.contains(method.getDescription()); } }); } }
private Flow<PlasticMethod> findResetMethods(PlasticClass plasticClass) { return F.flow(plasticClass.getMethods()).filter(METHOD_MATCHER).each(METHOD_VALIDATOR); } }
private Flow<PlasticMethod> matchLifecycleMethods(PlasticClass plasticClass) { return F.flow(plasticClass.getMethods()).filter(MATCHER).each(VALIDATE); } }
public ToDoItem toValue(String clientValue) { final long id = Long.parseLong(clientValue); return F.flow(items).filter(new Predicate<ToDoItem>() { public boolean accept(ToDoItem element) { return element.getId() == id; } }).first(); }
@Test public void nonempty_flow() { Set<Integer> set = F.range(1, 10).filter(evenp).toSet(); assertTrue(set.containsAll(Arrays.asList(2, 4, 6, 8))); } }
@Test(expectedExceptions = UnsupportedOperationException.class) public void remove_on_flow_iterator_is_not_supported() { Flow<Integer> flow = F.flow(1, 2, 3).filter(evenp); Iterator<Integer> it = flow.iterator(); assertTrue(it.hasNext()); assertEquals(it.next(), new Integer(2)); it.remove(); }
@Test public void filter_empty_is_the_empty_list() { List<Integer> input = Arrays.asList(); List<Integer> output = F.flow(input).filter(evenp).toList(); assertSame(output, Collections.EMPTY_LIST); }
@Test public void filter() { List<Integer> input = Arrays.asList(1, 2, 3, 4, 5, 6, 7); List<Integer> output = F.flow(input).filter(evenp).toList(); assertListsEquals(output, 2, 4, 6); }
@Test public void suffix_predicate() { Flow<String> names = F.flow("Ted", "Charly", "Fred", "Anna"); assertFlowValues(names.filter(F.endsWith("red")), "Fred"); }
@Test public void case_insensitive_prefix_predicate() { Flow<String> names = F.flow("Howard", "Henry", "Anna", "Hubert"); assertFlowValues(names.filter(F.startsWithIgnoringCase("h")), "Howard", "Henry", "Hubert"); }
@Test public void case_insensitive_suffix_predicate() { Flow<String> names = F.flow("Ted", "Charly", "Fred", "Anna"); assertFlowValues(names.filter(F.endsWithIgnoringCase("RED")), "Fred"); }
@Test public void filtered_series() { Flow<Integer> series = F.series(1, 1); assertFlowValues(series.filter(evenp).take(4), 2, 4, 6, 8); }
@Test public void eql_predicate() { List<Integer> input = Arrays.asList(1, 2, 3, 4, 5, 6, 7); List<Integer> output = F.flow(input).filter(F.eql(4)).toList(); assertListsEquals(output, 4); }
@Test public void drop_exact_size_of_flow_is_empty() { assertTrue(F.range(1, 10).filter(evenp).drop(4).isEmpty()); }
@Test public void combine_predicate_with_and() { List<Integer> input = Arrays.asList(1, 2, 3, 4, 5, 6, 7); List<Integer> output = F.flow(input).filter(F.and(F.gt(2), F.lt(5))).toList(); assertListsEquals(output, 3, 4); }
@Test public void combine_predicate_with_or() { List<Integer> input = Arrays.asList(1, 2, 3, 4, 5, 6, 7); List<Integer> output = F.flow(input).filter(F.or(F.lt(3), F.gt(5))).toList(); assertListsEquals(output, 1, 2, 6, 7); }
@Test public void count_of_a_filtered_flow() { Flow<String> flow = F.flow("Mary", "had", "a", "little", "lamb"); assertEquals(flow.filter(F.isNull()).count(), 0); assertEquals(flow.removeNulls().count(), 5); }