Interface FieldsCombinationValidator<E extends EntityType<E>>

  • All Superinterfaces:
    ChangeValidator

    public interface FieldsCombinationValidator<E extends EntityType<E>>
    extends ChangeValidator
    A validator that verifies that the resulting state of several fields is legal, no matter whether some of them are already set or being modified by the command. For instance, if a validator validates that the value of field 'B' is greater than the value of field 'A', it is going to be called when either 'B' or 'A' (or both) are being changed.
    • Method Detail

      • validatedFields

        java.util.stream.Stream<EntityField<E,​?>> validatedFields()
        Returns:
        the list of fields whose combination is being validated
      • validate

        ValidationError validate​(FieldsValueMap<E> fieldsValueMap)
        Implements the validation and return an error if there is.
        Parameters:
        fieldsValueMap - the map containing the fields specified by validatedFields(). If a field is being modified by the command, its new value is going to be in the map, otherwise the existing value would be passed.
        Returns:
        validation error if there is or null if OK
      • fetchFields

        default java.util.stream.Stream<EntityField<?,​?>> fetchFields()
        Returns:
        a list of fields to fetch.
      • validateWhen

        default java.util.function.Predicate<CurrentEntityState> validateWhen()
        Returns:
        Predicate when should validate fields.