Class StringFilter
- java.lang.Object
-
- com.github.siroshun09.mccommand.common.filter.AbstractFilter<String>
-
- com.github.siroshun09.mccommand.common.filter.StringFilter
-
public final class StringFilter extends AbstractFilter<String>
-
-
Field Summary
Fields Modifier and Type Field Description static StringFilter
IS_EMPTY
The filter if theString
is empty.static StringFilter
IS_NOT_EMPTY
The filter if theString
is not empty.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @NotNull StringFilter
create(@NotNull Predicate<String> predicate)
Creates theStringFilter
.static @NotNull StringFilter
endsWith(@NotNull String suffix)
static @NotNull StringFilter
endsWithIgnoreCase(@NotNull String suffix)
static @NotNull StringFilter
lengthRange(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int min, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int max)
Creates a filter to check the length ofString
.static @NotNull StringFilter
maxLength(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int max)
Creates a filter to check the length ofString
.static @NotNull StringFilter
minLength(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int min)
Creates a filter to check the length ofString
.static @NotNull StringFilter
regex(@NotNull String regex)
Create a filter using a regular expression.static @NotNull StringFilter
regex(@NotNull Pattern pattern)
Create a filter using aPattern
.static @NotNull StringFilter
startsWith(@NotNull String prefix)
static @NotNull StringFilter
startsWithIgnoreCase(@NotNull String prefix)
-
Methods inherited from class com.github.siroshun09.mccommand.common.filter.AbstractFilter
test
-
-
-
-
Field Detail
-
IS_EMPTY
public static final StringFilter IS_EMPTY
The filter if theString
is empty.
-
IS_NOT_EMPTY
public static final StringFilter IS_NOT_EMPTY
The filter if theString
is not empty.
-
-
Method Detail
-
create
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter create(@NotNull @NotNull Predicate<String> predicate)
Creates theStringFilter
.- Parameters:
predicate
- the predicate to test theString
- Returns:
- the
StringFilter
-
startsWith
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter startsWith(@NotNull @NotNull String prefix)
- Parameters:
prefix
- the prefix- Returns:
- the
StringFilter
-
startsWithIgnoreCase
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter startsWithIgnoreCase(@NotNull @NotNull String prefix)
Creates a filter to check if theString
starts with the specifiedString
.This filter is not case-sensitive.
- Parameters:
prefix
- the prefix- Returns:
- the
StringFilter
-
endsWith
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter endsWith(@NotNull @NotNull String suffix)
- Parameters:
suffix
- the suffix- Returns:
- the
StringFilter
-
endsWithIgnoreCase
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter endsWithIgnoreCase(@NotNull @NotNull String suffix)
Creates a filter to check if theString
ends with the specifiedString
.This filter is not case-sensitive.
- Parameters:
suffix
- the suffix- Returns:
- the
StringFilter
-
lengthRange
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter lengthRange(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int min, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int max) throws IllegalArgumentException
Creates a filter to check the length ofString
.- Parameters:
min
- minimum lengthmax
- maximum length- Returns:
- the
StringFilter
- Throws:
IllegalArgumentException
- if the minimum or maximum value is less than zero or if the minimum value is greater than the maximum value
-
maxLength
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter maxLength(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int max)
Creates a filter to check the length ofString
.- Parameters:
max
- maximum length- Returns:
- the
StringFilter
- Throws:
IllegalArgumentException
- if the maximum value is less than zero
-
minLength
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter minLength(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int min)
Creates a filter to check the length ofString
.- Parameters:
min
- minimum length- Returns:
- the
StringFilter
- Throws:
IllegalArgumentException
- if the minimum value is less than zero
-
regex
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter regex(@NotNull @NotNull String regex)
Create a filter using a regular expression.- Parameters:
regex
- the regex- Returns:
- the
StringFilter
-
regex
@Contract(value="_ -> new", pure=true) @NotNull public static @NotNull StringFilter regex(@NotNull @NotNull Pattern pattern)
Create a filter using aPattern
.- Parameters:
pattern
- the pattern- Returns:
- the
StringFilter
-
-