mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8184692: add Pattern.asMatchPredicate
Reviewed-by: psandoz, rriggs
This commit is contained in:
parent
9da125c2a2
commit
97979a53a1
2 changed files with 44 additions and 3 deletions
|
@ -5821,14 +5821,34 @@ NEXT: while (i <= last) {
|
|||
* }</pre>
|
||||
*
|
||||
* @return The predicate which can be used for finding a match on a
|
||||
* subsequence of a string
|
||||
* subsequence of a string
|
||||
* @since 1.8
|
||||
* @see Matcher#find
|
||||
* @see Matcher#find
|
||||
*/
|
||||
public Predicate<String> asPredicate() {
|
||||
return s -> matcher(s).find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a predicate that tests if this pattern matches a given input string.
|
||||
*
|
||||
* @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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue