@see Predicates#contains(Pattern)
| 686 | /** @see Predicates#contains(Pattern) */ |
| 687 | |
| 688 | @GwtIncompatible // Only used by other GWT-incompatible code. |
| 689 | private static class ContainsPatternPredicate implements Predicate<CharSequence>, Serializable { |
| 690 | final Pattern pattern; |
| 691 | |
| 692 | ContainsPatternPredicate(Pattern pattern) { |
| 693 | this.pattern = checkNotNull(pattern); |
| 694 | } |
| 695 | |
| 696 | @Override |
| 697 | public boolean apply(CharSequence t) { |
| 698 | return pattern.matcher(t).find(); |
| 699 | } |
| 700 | |
| 701 | @Override |
| 702 | public int hashCode() { |
| 703 | // Pattern uses Object.hashCode, so we have to reach |
| 704 | // inside to build a hashCode consistent with equals. |
| 705 | return Objects.hashCode(pattern.pattern(), pattern.flags()); |
| 706 | } |
| 707 | |
| 708 | @Override |
| 709 | public boolean equals(@Nullable Object obj) { |
| 710 | if (obj instanceof ContainsPatternPredicate) { |
| 711 | ContainsPatternPredicate that = (ContainsPatternPredicate) obj; |
| 712 | |
| 713 | // Pattern uses Object (identity) equality, so we have to reach |
| 714 | // inside to compare individual fields. |
| 715 | return Objects.equal(pattern.pattern(), that.pattern.pattern()) |
| 716 | && pattern.flags() == that.pattern.flags(); |
| 717 | } |
| 718 | return false; |
| 719 | } |
| 720 | |
| 721 | @Override |
| 722 | public String toString() { |
| 723 | String patternString = MoreObjects.toStringHelper(pattern).add("pattern", pattern.pattern()).add("pattern.flags", pattern.flags()).toString(); |
| 724 | return "Predicates.contains(" + patternString + ")"; |
| 725 | } |
| 726 | |
| 727 | private static final long serialVersionUID = 0; |
| 728 | } |
| 729 | |
| 730 | /** @see Predicates#containsPattern(String) */ |
| 731 |
nothing calls this directly
no outgoing calls
no test coverage detected