Class StringPredicateBuilder
- java.lang.Object
-
- org.solidcoding.validation.predicates.StringPredicateBuilder
-
- All Implemented Interfaces:
Predicate<String>,GenericPredicate<String>
public final class StringPredicateBuilder extends Object
-
-
Method Summary
All Methods Static Methods Instance 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 ChainingPredicate<Integer,Predicate<String>>hasALengthBetween(int length)static Predicate<String>hasALengthOf(int length)static Predicate<String>is(String value)Check if the actual value is equal to the given one.static Predicate<String>is(Predicate<String> rule)static Predicate<String>isAlphabetic()Adds a check if all characters are in fact digits.static Predicate<String>isNotAlphabetic()Adds a check if any character is in fact not alphabetic.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.booleantest(T value)Predicate<T>where(Predicate<T> rule)
-
-
-
Method Detail
-
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.
-
is
public static Predicate<String> is(String value)
Check if the actual value is equal to the given one.- Parameters:
value- the exact expected value.- Returns:
- StringPredicate to continue adding rules.
-
is
public static Predicate<String> is(Predicate<String> rule)
- Parameters:
rule- the custom predicate to test against the String.- Returns:
- StringPredicate to continue adding rules.
-
hasALengthBetween
public static ChainingPredicate<Integer,Predicate<String>> hasALengthBetween(int length)
- Parameters:
length- the exact length of the String.- Returns:
- StringPredicate to continue adding rules.
-
hasALengthOf
public static Predicate<String> hasALengthOf(int length)
- Parameters:
length- the exact length of the String.- Returns:
- StringPredicate to continue adding rules.
-
isNumeric
public static Predicate<String> isNumeric()
Adds a check if all characters are in fact digits.- Returns:
- StringPredicate to continue adding rules.
-
isNotNumeric
public static Predicate<String> isNotNumeric()
Adds a check if any character is in fact not a digit.- Returns:
- StringPredicate to continue adding rules.
-
isAlphabetic
public static Predicate<String> isAlphabetic()
Adds a check if all characters are in fact digits.- Returns:
- StringPredicate to continue adding rules.
-
isNotAlphabetic
public static Predicate<String> isNotAlphabetic()
Adds a check if any character is in fact not alphabetic.- Returns:
- StringPredicate to continue adding rules.
-
where
public Predicate<T> where(Predicate<T> rule)
- Specified by:
wherein interfaceGenericPredicate<T>- Parameters:
rule- the custom predicate to test against properties of T.- Returns:
- ObjectPredicate to continue adding rules.
-
-