Home | History | Annotate | Download | only in base

Lines Matching refs:Predicate

46   private static final Predicate<Integer> TRUE = Predicates.alwaysTrue();
47 private static final Predicate<Integer> FALSE = Predicates.alwaysFalse();
48 private static final Predicate<Integer> NEVER_REACHED =
49 new Predicate<Integer>() {
52 fail("This predicate should never have been evaluated");
57 /** Instantiable predicate with reasonable hashCode() and equals() methods. */
58 static class IsOdd implements Predicate<Integer>, Serializable {
76 * Generates a new Predicate per call.
78 * <p>Creating a new Predicate each time helps catch cases where code is
128 * Tests for Predicates.not(predicate).
275 Collection<Predicate<Integer>> empty = Arrays.asList();
302 Predicate[] array = {Predicates.alwaysFalse()};
303 Predicate<Object> predicate = Predicates.and(array);
304 assertFalse(predicate.apply(1));
306 assertFalse(predicate.apply(1));
311 List list = new ArrayList<Predicate>();
312 Predicate<Object> predicate = Predicates.and(list);
313 assertTrue(predicate.apply(1));
315 assertTrue(predicate.apply(1));
320 final List list = new ArrayList<Predicate>();
321 Iterable iterable = new Iterable<Predicate>() {
323 public Iterator<Predicate> iterator() {
327 Predicate<Object> predicate = Predicates.and(iterable);
328 assertTrue(predicate.apply(1));
330 assertTrue(predicate.apply(1));
382 Predicate<Integer> falseOrFalse = Predicates.or(FALSE, FALSE);
383 Predicate<Integer> falseOrTrue = Predicates.or(FALSE, TRUE);
384 Predicate<Integer> trueOrAnything = Predicates.or(TRUE, NEVER_REACHED);
436 Predicate<Integer> vacuouslyFalse =
437 Predicates.or(Collections.<Predicate<Integer>>emptyList());
438 Predicate<Integer> troo = Predicates.or(Collections.singletonList(TRUE));
441 * Predicate<Integer>, so the call is safe.
443 Predicate<Integer> trueAndFalse = Predicates.or(Arrays.asList(TRUE, FALSE));
465 Predicate<Integer> pre = Predicates.or(Arrays.asList(TRUE, FALSE));
466 Predicate<Integer> post = SerializableTester.reserializeAndAssert(pre);
472 Predicate[] array = {Predicates.alwaysFalse()};
473 Predicate<Object> predicate = Predicates.or(array);
474 assertFalse(predicate.apply(1));
476 assertFalse(predicate.apply(1));
481 List list = new ArrayList<Predicate>();
482 Predicate<Object> predicate = Predicates.or(list);
483 assertFalse(predicate.apply(1));
485 assertFalse(predicate.apply(1));
490 final List list = new ArrayList<Predicate>();
491 Iterable iterable = new Iterable<Predicate>() {
493 public Iterator<Predicate> iterator() {
497 Predicate<Object> predicate = Predicates.or(iterable);
498 assertFalse(predicate.apply(1));
500 assertFalse(predicate.apply(1));
508 Predicate
529 Predicate<Integer> isNull = Predicates.equalTo(null);
556 Predicate<Object> isInteger = Predicates.instanceOf(Integer.class);
566 Predicate<Object> isNumber = Predicates.instanceOf(Number.class);
576 Predicate<Object> isComparable = Predicates.instanceOf(Comparable.class);
602 Predicate<Class<?>> isInteger = Predicates.assignableFrom(Integer.class);
615 Predicate<Class<?>> isNumber = Predicates.assignableFrom(Number.class);
623 Predicate<Class<?>> isComparable =
643 Predicate<Class<?>> predicate =
645 Predicate<Class<?>> reserialized =
646 SerializableTester.reserializeAndAssert(predicate);
648 assertEvalsLike(predicate, reserialized, Integer.class);
649 assertEvalsLike(predicate, reserialized, Float.class);
650 assertEvalsLike(predicate, reserialized, null);
658 Predicate<Integer> isNull = Predicates.isNull();
672 Predicate<String> pre = Predicates.isNull();
673 Predicate<String> post = SerializableTester.reserializeAndAssert(pre);
679 Predicate<Integer> notNull = Predicates.notNull();
698 Predicate<Integer> isOneOrFive = Predicates.in(nums);
734 Predicate<Integer> isFalse = Predicates.in(nums);
748 Predicate<Integer> isThree = Predicates.in(nums);
758 Predicate<Number> p1 = Predicates.in(nums);
759 Predicate<Object> p2 = Predicates.<Object>in(nums);
761 // Predicate<Integer> p3 = Predicates.in(nums);
762 // Predicate<Integer> p4 = Predicates.<Integer>in(nums);
774 // Eclipse says Predicate<Integer>; javac says Predicate<Object>.
775 Predicate<? super Integer> nasty = Predicates.not(Predicates.and(
783 Predicate<? super Integer> stillNasty =
801 Predicate<String> equalsFoo = Predicates.equalTo("Foo");
802 Predicate<String> equalsBar = Predicates.equalTo("Bar");
803 Predicate<String> trimEqualsFoo = Predicates.compose(equalsFoo, trim);
822 Predicate<String> equalsFoo = Predicates.equalTo("Foo");
823 Predicate<String> trimEqualsFoo = Predicates.compose(equalsFoo, trim);
836 Predicate<CharSequence> isFoobar =
844 Predicate<CharSequence> isFoobar =
854 Predicate<CharSequence> isWooString = Predicates.containsPattern("Woo");
862 Predicate<CharSequence> isWooPattern =
870 Predicate<CharSequence> pre = Predicates.containsPattern("foo");
871 Predicate<CharSequence> post = SerializableTester.reserializeAndAssert(pre);
890 Predicate<? super Integer> expected, Predicate<? super Integer> actual) {
896 Predicate<Integer> p1 = Predicates.isNull();
897 Predicate<Integer> p2 = isOdd();
917 private static void assertEvalsToTrue(Predicate<? super Integer> predicate) {
918 assertTrue(predicate.apply(0));
919 assertTrue(predicate.apply(1));
920 assertTrue(predicate.apply(null));
923 private static void assertEvalsToFalse(Predicate<? super Integer> predicate) {
924 assertFalse(predicate.apply(0));
925 assertFalse(predicate.apply(1));
926 assertFalse(predicate.apply(null));
929 private static void assertEvalsLikeOdd(Predicate<? super Integer> predicate) {
930 assertEvalsLike(isOdd(), predicate);
934 Predicate<? super Integer> expected,
935 Predicate<? super Integer> actual) {
942 Predicate<? super T> expected,
943 Predicate<? super T> actual,
971 private static void checkSerialization(Predicate<? super Integer> predicate) {
972 Predicate<? super Integer> reserialized =
973 SerializableTester.reserializeAndAssert(predicate);
974 assertEvalsLike(predicate, reserialized);