@see Predicates#and(Iterable)
| 410 | |
| 411 | /** @see Predicates#and(Iterable) */ |
| 412 | private static class AndPredicate<T> implements Predicate<T>, Serializable { |
| 413 | |
| 414 | private final List<? extends Predicate<? super T>> components; |
| 415 | private AndPredicate(List<? extends Predicate<? super T>> components) { |
| 416 | this.components = components; |
| 417 | } |
| 418 | |
| 419 | @Override |
| 420 | public boolean apply(@Nullable T t) { |
| 421 | // Avoid using the Iterator to avoid generating garbage (issue 820). |
| 422 | for (int i = 0; i < components.size(); i++) { |
| 423 | if (!components.get(i).apply(t)) { |
| 424 | return false; |
| 425 | } |
| 426 | } |
| 427 | return true; |
| 428 | } |
| 429 | |
| 430 | @Override |
| 431 | public int hashCode() { |
| 432 | // add a random number to avoid collisions with OrPredicate |
| 433 | return components.hashCode() + 0x12472c2c; |
| 434 | } |
| 435 | |
| 436 | @Override |
| 437 | public boolean equals(@Nullable Object obj) { |
| 438 | if (obj instanceof AndPredicate) { |
| 439 | AndPredicate<?> that = (AndPredicate<?>) obj; |
| 440 | return components.equals(that.components); |
| 441 | } |
| 442 | return false; |
| 443 | } |
| 444 | |
| 445 | @Override |
| 446 | public String toString() { |
| 447 | return "Predicates.and(" + COMMA_JOINER.join(components) + ")"; |
| 448 | } |
| 449 | |
| 450 | private static final long serialVersionUID = 0; |
| 451 | } |
| 452 | |
| 453 | /** @see Predicates#or(Iterable) */ |
| 454 |
nothing calls this directly
no outgoing calls
no test coverage detected