@Test public void partitionShouldReturnPartitionedCollectionsFor4IntCollection() { Pair<Collection<Integer>, Collection<Integer>> collections = partition(ImmutableList.of(1, 2, 3, 4), new Predicate<Integer>() { @Override public boolean apply(Integer input) { return input > 2; } }); Set<Integer> satisfied = ImmutableSet.copyOf(collections.getLeft()); Set<Integer> unsatisfied = ImmutableSet.copyOf(collections.getRight()); assertNotNull(unsatisfied); assertEquals(unsatisfied.size(), 2); assertTrue(unsatisfied.containsAll(ImmutableSet.of(1, 2)), "Right set should contain elements 1 and 2."); assertNotNull(satisfied); assertEquals(satisfied.size(), 2); assertTrue(satisfied.containsAll(ImmutableSet.of(3, 4)), "Left set should contain elements 3 and 4."); }
public static <E> Pair<Collection<E>, Collection<E>> partition(Collection<E> unpartitioned, Predicate<? super E> predicate) { return pair(filter(checkNotNull(unpartitioned), checkNotNull(predicate)), filter(unpartitioned, not(predicate))); }
Collections3 { public static <E> Pair<Collection<E>, Collection<E>> partition(Collection<E> unpartitioned, Predicate<? super E> predicate) { return pair(filter(checkNotNull(unpartitioned), checkNotNull(predicate)), filter(unpartitioned, not(predicate))); } }
Collections3 { public static <E> Pair<Collection<E>, Collection<E>> partition(Collection<E> unpartitioned, Predicate<? super E> predicate) { return pair(filter(checkNotNull(unpartitioned), checkNotNull(predicate)), filter(unpartitioned, not(predicate))); } private  Collections3(); }
Collections3 { public static <E> Pair<Collection<E>, Collection<E>> partition(Collection<E> unpartitioned, Predicate<? super E> predicate) { return pair(filter(checkNotNull(unpartitioned), checkNotNull(predicate)), filter(unpartitioned, not(predicate))); } private  Collections3(); static Pair<Collection<E>, Collection<E>> partition(Collection<E> unpartitioned,
                                                                   Predicate<? super E> predicate); static Optional<T> findFirstInstanceOf(Collection<? super T> coll, Class<T> cls); static T maxNullSafe(Collection<? extends T> coll, Comparator<? super T> comp); static T maxNullSafe(Collection<? extends T> coll); }
Collections3 { public static <E> Pair<Collection<E>, Collection<E>> partition(Collection<E> unpartitioned, Predicate<? super E> predicate) { return pair(filter(checkNotNull(unpartitioned), checkNotNull(predicate)), filter(unpartitioned, not(predicate))); } private  Collections3(); static Pair<Collection<E>, Collection<E>> partition(Collection<E> unpartitioned,
                                                                   Predicate<? super E> predicate); static Optional<T> findFirstInstanceOf(Collection<? super T> coll, Class<T> cls); static T maxNullSafe(Collection<? extends T> coll, Comparator<? super T> comp); static T maxNullSafe(Collection<? extends T> coll);  }