org.solidcoding.validation.api.ContinuingValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solidcoding-validation Show documentation
Show all versions of solidcoding-validation Show documentation
A small package that enables validation of (business) rules through a fluent API.
package org.solidcoding.validation.api;
import java.util.function.Function;
import java.util.function.Supplier;
public interface ContinuingValidator extends ThrowingValidator {
/**
* @return the failure message;
*/
String getMessage();
ContinuingValidator and(Rule rule);
/**
* @return boolean true if all rules pass. False if at least one rule fails.
*/
boolean validate();
/**
* Same as validate(); but returns a custom object in the form of a supplier.
*
* @param supplier the supplier which encapsulated the return type.
* @param the type you wish to return.
* @return R in the form of a supplier.
*/
ReturningValidator andThen(Supplier supplier);
/**
* Same as validate(); but returns a custom object in the form of a supplier.
*
* @param runnable the runnable process which should be started after successful validation.
* @return R in the form of a supplier.
*/
VoidValidator andThen(Runnable runnable);
/**
* @param other the backup/default return type if the validation fails.
* @return T the return type.
*/
T orElseReturn(T other);
/**
* @param other the backup/default return type if the validation fails with the optional message that is contained in the Validator.
* @return T the return type.
*/
T orElseReturn(Function other);
}