Interface AccessContractValidator

  • All Superinterfaces:
    GenericContractValidator<AccessContractModel>
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface AccessContractValidator
    extends GenericContractValidator<AccessContractModel>
    Used to validate contracts (any class that extends AbstractContractModel) and to apply acceptance rules. Bellow the example of usage :
     
     private static GenericContractValidator checkDuplicateInDatabaseValidator() {
        return (contract, contractName) -> {
            GenericRejectionCause rejection = null;
            boolean exist = ... exists in database?;
            if (exist) {
               rejection = GenericRejectionCause.rejectDuplicatedInDatabase(contractName);
            }
            return (rejection == null) ? Optional.empty() : Optional.of(rejection);
        };
     }
     
     
    The call the method like this to validate the contract c: GenericRejectionCause rejection = checkDuplicateInDatabaseValidator().validate(c, c.getName()); Check if rejection is present then do the resolution