Package fr.gouv.vitam.functional.administration.core.profile

# Interface ProfileValidator

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 ProfileValidator
Used to validate profiles and to apply acceptance rules. Bellow the example of usage :

     private static ProfileValidator checkDuplicateInDatabaseValidator() {
        return (profile, profileIdentifier) -> {
            GenericRejectionCause rejection = null;
            boolean exist = ... exists in database?;
            if (exist) {
               rejection = GenericRejectionCause.rejectDuplicatedInDatabase(profileIdentifier);
            }
            return (rejection == null) ? Optional.empty() : Optional.of(rejection);
        };
     }

The call the method like this to validate the profile p: GenericRejectionCause rejection = checkDuplicateInDatabaseValidator().validate(p, p.getName()); Check if rejection is present then do the resolution

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static class`
  `ProfileValidator.RejectionCause`
  Rejection Cause

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Optional<ProfileValidator.RejectionCause>`
  `validate(ProfileModel profile)`
  Validate a profile object

- ## Method Details

  - ### validate

    Optional<ProfileValidator.RejectionCause> validate(ProfileModel profile)
    Validate a profile object
    Parameters:
      `profile` - to validate
    Returns:
      empty optional if OK, Else return the rejection cause