Package org.solidcoding.validation
Class EndingValidator<T,R>
- java.lang.Object
-
- org.solidcoding.validation.EndingValidator<T,R>
-
- All Implemented Interfaces:
ReturningValidator<R>
public class EndingValidator<T,R> extends Object implements ReturningValidator<R>
-
-
Constructor Summary
Constructors Constructor Description EndingValidator(Supplier<R> supplier, Validator<T> businessRuleValidator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RorElseReturn(R other)<E extends RuntimeException>
RorElseThrow(E throwable)
-
-
-
Method Detail
-
orElseThrow
public <E extends RuntimeException> R orElseThrow(E throwable)
- Specified by:
orElseThrowin interfaceReturningValidator<T>- Type Parameters:
E- the bound of the Exception that needs to be thrown when a rule is broken.- Parameters:
throwable- the Exception that needs to be thrown when a rule is broken.- Returns:
- R the return type
-
orElseReturn
public R orElseReturn(R other)
- Specified by:
orElseReturnin interfaceReturningValidator<T>- Parameters:
other- the backup/default return type if the validation fails.- Returns:
- R the return type.
-
-