8164781: Pattern.asPredicate specification is incomplete

Updated specification to reflect usage of find()

Reviewed-by: psandoz
This commit is contained in:
Vivek Theeyarath 2018-04-09 10:39:29 -07:00
parent 10201f5b2f
commit 824df1c125
2 changed files with 16 additions and 2 deletions

View file

@ -5809,10 +5809,21 @@ NEXT: while (i <= last) {
static final Node lastAccept = new LastNode(); static final Node lastAccept = new LastNode();
/** /**
* Creates a predicate which can be used to match a string. * Creates a predicate that tests if this pattern is found in a given input
* string.
* *
* @return The predicate which can be used for matching on a string * @apiNote
* This method creates a predicate that behaves as if it creates a matcher
* from the input sequence and then calls {@code find}, for example a
* predicate of the form:
* <pre>{@code
* s -> matcher(s).find();
* }</pre>
*
* @return The predicate which can be used for finding a match on a
* subsequence of a string
* @since 1.8 * @since 1.8
* @see Matcher#find
*/ */
public Predicate<String> asPredicate() { public Predicate<String> asPredicate() {
return s -> matcher(s).find(); return s -> matcher(s).find();

View file

@ -4683,6 +4683,9 @@ public class RegExTest {
if (p.test("1234")) { if (p.test("1234")) {
failCount++; failCount++;
} }
if (!p.test("word1234")) {
failCount++;
}
report("Pattern.asPredicate"); report("Pattern.asPredicate");
} }