public interface PatternMatcher
Pattern
for use cases that just
require basic matching. Calling the matches method should be mostly equivalent to calling
Matcher.find()
. It supports most common capabilities of the normal
java regular expressions. Unsupported features are:
^
and $
This class is an internal implementation detail only intended for use within spectator. It is subject to change without notice.
Modifier and Type | Method and Description |
---|---|
default boolean |
alwaysMatches()
Returns true if this matcher will match any string.
|
static PatternMatcher |
compile(String pattern)
Compile a pattern string and return a matcher that can be used to check if string values
match the pattern.
|
default PatternMatcher |
ignoreCase()
Returns a new matcher that matches the same pattern only ignoring the case of the input
string.
|
default boolean |
isEndAnchored()
Returns true if the pattern is anchored to the end of the string.
|
default boolean |
isStartAnchored()
Returns true if the pattern is anchored to the start of the string.
|
boolean |
matches(String str)
Returns true if the passed in string matches the pattern.
|
static boolean |
matches(String pattern,
String value)
Helper function to check if a string value matches the provided pattern.
|
default int |
minLength()
The minimum possible length of a matching string.
|
default boolean |
neverMatches()
Returns true if this matcher will not match any string.
|
default String |
prefix()
Returns a fixed string prefix for the pattern if one is available.
|
default String |
toSqlPattern()
Returns a pattern that can be used with a SQL LIKE clause or null if this expression
cannot be expressed as a SQL pattern.
|
boolean matches(String str)
default String prefix()
default int minLength()
default boolean isStartAnchored()
default boolean isEndAnchored()
default boolean alwaysMatches()
default boolean neverMatches()
default PatternMatcher ignoreCase()
default String toSqlPattern()
static PatternMatcher compile(String pattern)
static boolean matches(String pattern, String value)
compile(String)
to get an instance of a matcher that can be reused.pattern
- Pattern to use for creating the matcher instance.value
- Value to check against the pattern.