Interface Setting.Validator<T>

Type Parameters:
T - the type of the Setting
Enclosing class:
Setting<T>
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 static interface Setting.Validator<T>
Represents a validator for a setting. The validate(Object) method is invoked early in the update setting process with the value of this setting for a fail-fast validation. Later on, the validate(Object, Map) and validate(Object, Map, boolean) methods are invoked with the value of this setting and a map from the settings specified by settings()} to their values. All these values come from the same Settings instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Iterator<Setting<?>>
    The settings on which the validity of this setting depends.
    void
    validate(T value)
    Validate this setting's value in isolation.
    default void
    validate(T value, Map<Setting<?>,Object> settings)
    Validate this setting against its dependencies, specified by settings().
    default void
    validate(T value, Map<Setting<?>,Object> settings, boolean isPresent)
    Validate this setting against its dependencies, specified by settings().
  • Method Details

    • validate

      void validate(T value)
      Validate this setting's value in isolation.
      Parameters:
      value - the value of this setting
    • validate

      default void validate(T value, Map<Setting<?>,Object> settings)
      Validate this setting against its dependencies, specified by settings(). The default implementation does nothing, accepting any value as valid as long as it passes the validation in validate(Object).
      Parameters:
      value - the value of this setting
      settings - a map from the settings specified by settings()} to their values
    • validate

      default void validate(T value, Map<Setting<?>,Object> settings, boolean isPresent)
      Validate this setting against its dependencies, specified by settings(). This method allows validation logic to evaluate whether the setting will be present in the Settings after the update. The default implementation does nothing, accepting any value as valid as long as it passes the validation in validate(Object).
      Parameters:
      value - the value of this setting
      settings - a map from the settings specified by settings()} to their values
      isPresent - boolean indicating if this setting is present
    • settings

      default Iterator<Setting<?>> settings()
      The settings on which the validity of this setting depends. The values of the specified settings are passed to validate(Object, Map). By default this returns an empty iterator, indicating that this setting does not depend on any other settings.
      Returns:
      the settings on which the validity of this setting depends.