Package org.solidcoding.validation.api
Interface ContinuingValidator<T>
-
public interface ContinuingValidator<T>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ContinuingValidator<T>and(Rule<T> rule)<R> ReturningValidator<R>andThen(Supplier<R> supplier)Same as validate(); but returns a custom object in the form of a supplier.StringgetMessage()TorElseReturn(Function<String,T> other)TorElseReturn(T other)<E extends RuntimeException>
booleanorElseThrow(Function<String,E> throwableFunction)booleanvalidate()
-
-
-
Method Detail
-
getMessage
String getMessage()
- Returns:
- the failure message;
-
and
ContinuingValidator<T> and(Rule<T> rule)
-
validate
boolean validate()
- Returns:
- boolean true if all rules pass. False if at least one rule fails.
-
andThen
<R> ReturningValidator<R> andThen(Supplier<R> supplier)
Same as validate(); but returns a custom object in the form of a supplier.- Type Parameters:
R- the type you wish to return.- Parameters:
supplier- the supplier which encapsulated the return type.- Returns:
- R in the form of a supplier.
-
orElseThrow
<E extends RuntimeException> boolean orElseThrow(Function<String,E> throwableFunction)
- Type Parameters:
E- the bound of the Exception that needs to be thrown when a rule is broken.- Parameters:
throwableFunction- the function defining the Exception that needs to be thrown when a rule is broken. The String is the stored failure message of the validation.- Returns:
- true if all rules pass.
-
orElseReturn
T orElseReturn(T other)
- Parameters:
other- the backup/default return type if the validation fails.- Returns:
- T the return type.
-
-