< prev index next >
src/java.base/share/classes/java/util/regex/Pattern.java
Print this page
@@ -5817,10 +5817,30 @@
public Predicate<String> asPredicate() {
return s -> matcher(s).find();
}
/**
+ * Creates a predicate that tests if a given input string argument,
+ * an input sequence, matches this pattern.
+ *
+ * @apiNote
+ * This method creates a predicate that behaves as if it creates a matcher
+ * from the input sequence and then calls {@code matches}, for example a
+ * predicate of the form:
+ * <pre>{@code
+ * s -> matcher(s).matches();
+ * }</pre>
+ *
+ * @return The predicate which can be used for matching an input string
+ * against this pattern.
+ * @since 11
+ * @see Matcher#matches
+ */
+ public Predicate<String> asMatchPredicate() {
+ return s -> matcher(s).matches();
+ }
+ /**
* Creates a stream from the given input sequence around matches of this
* pattern.
*
* <p> The stream returned by this method contains each substring of the
* input sequence that is terminated by another subsequence that matches
< prev index next >