Class StringPredicate
- java.lang.Object
-
- org.solidcoding.validation.predicates.ObjectPredicate<String>
-
- org.solidcoding.validation.predicates.StringPredicate
-
- All Implemented Interfaces:
Predicate<String>,PredicateAppender<String>
public final class StringPredicate extends ObjectPredicate<String>
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Predicate<String>contains(CharSequence value, CharSequence... values)Checks whether the given charSequences are present anywhere in the value.static Predicate<String>doesNotContain(CharSequence value, CharSequence... values)Checks whether the given charSequences are present anywhere in the value.static ConstraintAppender<Integer,Predicate<String>>hasALengthBetween(int length)static Predicate<String>hasALengthOf(int length)static Predicate<String>isAlphabetic()Adds a check if all characters are in fact digits.static Predicate<String>isEqualTo(String value)Check if the actual value is equal to the given one.static Predicate<String>isNotAlphabetic()Adds a check if any character is in fact not alphabetic.static Predicate<String>isNotNull()Checks whether the actual value is present.*static Predicate<String>isNotNumeric()Adds a check if any character is in fact not a digit.static Predicate<String>isNumeric()Adds a check if all characters are in fact digits.-
Methods inherited from class org.solidcoding.validation.predicates.ObjectPredicate
isA, isAn, isEqualTo, test
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.solidcoding.validation.predicates.PredicateAppender
that, that, where, where
-
-
-
-
Method Detail
-
isNotNull
public static Predicate<String> isNotNull()
Checks whether the actual value is present.*- Returns:
- Predicate to continue adding rules.
-
contains
public static Predicate<String> contains(CharSequence value, CharSequence... values)
Checks whether the given charSequences are present anywhere in the value.- Parameters:
value- the exact value that needs to be present in the original value.values- the optional exact values that needs to be present in the original value.- Returns:
- Predicate to continue adding rules.
-
doesNotContain
public static Predicate<String> doesNotContain(CharSequence value, CharSequence... values)
Checks whether the given charSequences are present anywhere in the value.- Parameters:
value- the exact value that may not be present in the original value.values- the optional exact values that may not be present in the original value.- Returns:
- Predicate to continue adding rules.
-
isEqualTo
public static Predicate<String> isEqualTo(String value)
Check if the actual value is equal to the given one.- Parameters:
value- the exact expected value.- Returns:
- Predicate to continue adding rules.
-
hasALengthOf
public static Predicate<String> hasALengthOf(int length)
- Parameters:
length- the exact length of the String.- Returns:
- Predicate to continue adding rules.
-
isNumeric
public static Predicate<String> isNumeric()
Adds a check if all characters are in fact digits.- Returns:
- Predicate to continue adding rules.
-
isNotNumeric
public static Predicate<String> isNotNumeric()
Adds a check if any character is in fact not a digit.- Returns:
- Predicate to continue adding rules.
-
isAlphabetic
public static Predicate<String> isAlphabetic()
Adds a check if all characters are in fact digits.- Returns:
- Predicate to continue adding rules.
-
isNotAlphabetic
public static Predicate<String> isNotAlphabetic()
Adds a check if any character is in fact not alphabetic.- Returns:
- Predicate to continue adding rules.
-
hasALengthBetween
public static ConstraintAppender<Integer,Predicate<String>> hasALengthBetween(int length)
- Parameters:
length- the exact length of the String.- Returns:
- ChainingPredicate to continue adding rules.
-
-