T - public interface GenericContractValidator<T extends AbstractContractModel>
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| Modifier and Type | Interface and Description |
|---|---|
static class |
GenericContractValidator.GenericRejectionCause
Generic Rejection Cause inner class
|
| Modifier and Type | Method and Description |
|---|---|
Optional<GenericContractValidator.GenericRejectionCause> |
validate(T contract,
String contractName)
Validate a contract object
|
Optional<GenericContractValidator.GenericRejectionCause> validate(T contract, String contractName)
contract - to validatecontractName - Copyright © 2020 Vitam. All rights reserved.