Class CheckerString
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<String,
CheckerString>, String>
CheckerString is a specialized checker for validating and performing assertions on String values.
It provides a fluent API for common string validations such as checking for emptiness, blankness, length constraints, content, format, and more.
-
Field Summary
Fields inherited from class util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CheckerString
(String string, String name) Constructs a newCheckerString
with the specified string and name. -
Method Summary
Modifier and TypeMethodDescriptionstatic CheckerString
Creates a new CheckerString instance for the given string with a default name.static CheckerString
Creates a new CheckerString instance for the given string and name.Checks if the string contains the specified sequence of char values.Checks if the string ends with the specified suffix.Checks if the string contains any special characters (e.g., !inRange
(int min, int max) Checks if the string length is within the specified range (exclusive).isBlank()
Checks if the string is blank (empty or contains only whitespace).isDigit()
Checks if the string consists only of digits.isDNI()
Checks if the string is a valid Spanish DNI (8 digits followed by an uppercase letter).isEmpty()
Checks if the string is empty.isEqualsIgnoreCase
(String anotherString) Checks if the string equals another string, ignoring case considerations.isIPv4()
Checks if the string is a valid IPv4 address.isIPv6()
Checks if the string is a valid IPv6 address.Checks if the string is a palindrome (reads the same forwards and backwards).Checks if the string matches the given regular expression.max
(int max) Checks if the string length is less than the specified maximum.min
(int min) Checks if the string length is greater than the specified minimum.protected CheckerString
self()
Returns this instance (for fluent API usage).startsWith
(String prefix) Checks if the string starts with the specified prefix.Methods inherited from class util.AbstractChecker
checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, show, showNotThrownException, showThrownException, stop
-
Constructor Details
-
CheckerString
-
-
Method Details
-
check
Creates a new CheckerString instance for the given string and name.- Parameters:
string
- the string value to be checkedname
- the name to identify the string in error messages- Returns:
- a CheckerString instance for further validations
-
check
Creates a new CheckerString instance for the given string with a default name.- Parameters:
string
- the string value to be checked- Returns:
- a CheckerString instance for further validations
-
self
Returns this instance (for fluent API usage).- Specified by:
self
in classAbstractChecker<String,
CheckerString> - Returns:
- this CheckerString instance
-
isEmpty
Checks if the string is empty.- Returns:
- this CheckerString instance for chaining
-
isBlank
Checks if the string is blank (empty or contains only whitespace).- Returns:
- this CheckerString instance for chaining
-
min
Checks if the string length is greater than the specified minimum.- Parameters:
min
- the minimum length (exclusive)- Returns:
- this CheckerString instance for chaining
-
max
Checks if the string length is less than the specified maximum.- Parameters:
max
- the maximum length (exclusive)- Returns:
- this CheckerString instance for chaining
-
inRange
Checks if the string length is within the specified range (exclusive).- Parameters:
min
- the minimum length (exclusive)max
- the maximum length (exclusive)- Returns:
- this CheckerString instance for chaining
-
isEqualsIgnoreCase
Checks if the string equals another string, ignoring case considerations.- Parameters:
anotherString
- the string to compare with, ignoring case- Returns:
- this CheckerString instance for chaining
-
contains
Checks if the string contains the specified sequence of char values.- Parameters:
s
- the sequence to search for- Returns:
- this CheckerString instance for chaining
-
startsWith
Checks if the string starts with the specified prefix.- Parameters:
prefix
- the prefix to look for- Returns:
- this CheckerString instance for chaining
-
endsWith
Checks if the string ends with the specified suffix.- Parameters:
suffix
- the suffix to look for- Returns:
- this CheckerString instance for chaining
-
matches
Checks if the string matches the given regular expression.- Parameters:
regex
- the regular expression to match- Returns:
- this CheckerString instance for chaining
-
isDigit
Checks if the string consists only of digits.- Returns:
- this CheckerString instance for chaining
-
isDNI
Checks if the string is a valid Spanish DNI (8 digits followed by an uppercase letter).- Returns:
- this CheckerString instance for chaining
-
isIPv4
Checks if the string is a valid IPv4 address.- Returns:
- this CheckerString instance for chaining
-
isIPv6
Checks if the string is a valid IPv6 address.- Returns:
- this CheckerString instance for chaining
-
hasSpecialCharacters
Checks if the string contains any special characters (e.g., !@#$%^&* etc.).- Returns:
- this CheckerString instance for chaining
-
isPalindrome
Checks if the string is a palindrome (reads the same forwards and backwards).- Returns:
- this CheckerString instance for chaining
-