MCPcopy Index your code
hub / github.com/antlr/codebuff / AndPredicate

Class AndPredicate

output/java_guava/1.4.17/Predicates.java:412–451  ·  view source on GitHub ↗

@see Predicates#and(Iterable)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected