@Test public void rejectWith() { ImmutableCollection<Integer> integers = this.classUnderTest(); Assert.assertEquals( this.<Integer>newMutable().withAll(integers).reject(IntegerPredicates.isOdd()), integers.rejectWith(Predicates2.in(), iList(1, 3, 5, 7, 9))); }
@Test public void partitionWith() { ImmutableCollection<Integer> integers = this.classUnderTest(); PartitionImmutableCollection<Integer> partition = integers.partitionWith(Predicates2.in(), integers.select(IntegerPredicates.isOdd())); Assert.assertEquals(integers.select(IntegerPredicates.isOdd()), partition.getSelected()); Assert.assertEquals(integers.select(IntegerPredicates.isEven()), partition.getRejected()); }
@Test public void selectAndRejectWithOver100() { ArrayList<Integer> list = new ArrayList<Integer>(Interval.oneTo(101)); Twin<MutableList<Integer>> result = ArrayListIterate.selectAndRejectWith(list, Predicates2.in(), Lists.immutable.of(1)); Verify.assertSize(1, result.getOne()); Verify.assertSize(100, result.getTwo()); }
@Test public void selectAndRejectWith() { ArrayList<Integer> list = this.getIntegerList(); Twin<MutableList<Integer>> result = ArrayListIterate.selectAndRejectWith(list, Predicates2.in(), Lists.immutable.of(1)); Verify.assertSize(1, result.getOne()); Verify.assertSize(4, result.getTwo()); }
@Test public void partitionWith_value() { MutableMap<String, Integer> map = this.newMapWithKeysValues("1", 1, "2", 2, "3", 3); PartitionMutableCollection<Integer> partition = map.partitionWith(Predicates2.in(), map.select(IntegerPredicates.isEven())); Assert.assertEquals(this.expectSelect(map.size()), partition.getSelected().toSet()); Assert.assertEquals(this.expectReject(map.size()), partition.getRejected().toSet()); }
public boolean containsAllArguments(Object... elements) { return ArrayIterate.allSatisfyWith(elements, Predicates2.in(), this); }
public boolean containsAllIterable(Iterable<?> source) { return Iterate.allSatisfyWith(source, Predicates2.in(), this); }