diff options
Diffstat (limited to 'guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Predicates.java')
-rw-r--r-- | guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Predicates.java | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Predicates.java b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Predicates.java index 04f088e..366ca0d 100644 --- a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Predicates.java +++ b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Predicates.java @@ -34,10 +34,6 @@ import javax.annotation.Nullable; * <p>All methods returns serializable predicates as long as they're given * serializable parameters. * - * <p>See the Guava User Guide article on <a href= - * "http://code.google.com/p/guava-libraries/wiki/FunctionalExplained">the - * use of {@code Predicate}</a>. - * * @author Kevin Bourrillion * @since 2.0 (imported from Google Collections Library) */ @@ -230,7 +226,7 @@ public final class Predicates { return o != null; } }; - + @SuppressWarnings("unchecked") // these Object predicates work for any T <T> Predicate<T> withNarrowedType() { return (Predicate<T>) this; @@ -245,7 +241,7 @@ public final class Predicates { this.predicate = checkNotNull(predicate); } @Override - public boolean apply(@Nullable T t) { + public boolean apply(T t) { return !predicate.apply(t); } @Override public int hashCode() { @@ -274,8 +270,7 @@ public final class Predicates { this.components = components; } @Override - public boolean apply(@Nullable T t) { - // Avoid using the Iterator to avoid generating garbage (issue 820). + public boolean apply(T t) { for (int i = 0; i < components.size(); i++) { if (!components.get(i).apply(t)) { return false; @@ -284,7 +279,7 @@ public final class Predicates { return true; } @Override public int hashCode() { - // add a random number to avoid collisions with OrPredicate + // 0x12472c2c is a random number to help avoid collisions with OrPredicate return components.hashCode() + 0x12472c2c; } @Override public boolean equals(@Nullable Object obj) { @@ -308,8 +303,7 @@ public final class Predicates { this.components = components; } @Override - public boolean apply(@Nullable T t) { - // Avoid using the Iterator to avoid generating garbage (issue 820). + public boolean apply(T t) { for (int i = 0; i < components.size(); i++) { if (components.get(i).apply(t)) { return true; @@ -318,7 +312,7 @@ public final class Predicates { return false; } @Override public int hashCode() { - // add a random number to avoid collisions with AndPredicate + // 0x053c91cf is a random number to help avoid collisions with AndPredicate return components.hashCode() + 0x053c91cf; } @Override public boolean equals(@Nullable Object obj) { @@ -371,7 +365,7 @@ public final class Predicates { } @Override - public boolean apply(@Nullable T t) { + public boolean apply(T t) { try { return target.contains(t); } catch (NullPointerException e) { @@ -411,7 +405,7 @@ public final class Predicates { } @Override - public boolean apply(@Nullable A a) { + public boolean apply(A a) { return p.apply(f.apply(a)); } |