Interface ConfigValidator<T,A extends Annotation>


public interface ConfigValidator<T,A extends Annotation>
A config validator is used to read a custom validation annotation from a config field and validate the value so it for example matches an int range. Validators are applied when a config is read from a file. They are not applied if a server sends a config and they'll not validate the default value.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the class of the annotation type used by this validator.
    default List<String>
    comment(A validator)
    Returns a list of comment lines that will be added to the values specified in @Config.
    Gets the class of the type that this validator can validate.
    validate(T value, A validator)
    Validates a value.
  • Method Details

    • type

      Class<T> type()
      Gets the class of the type that this validator can validate.
    • annotation

      Class<A> annotation()
      Gets the class of the annotation type used by this validator.
    • validate

      Optional<T> validate(T value, A validator)
      Validates a value. For a correct value this should return an empty Optional. For an incorrect value this should return an Optional containing the corrected value.
    • comment

      default List<String> comment(A validator)
      Returns a list of comment lines that will be added to the values specified in @Config.