Interface AnnotationValidator<T extends Annotation>

Type Parameters:
T - annotation type

public interface AnnotationValidator<T extends Annotation>
Represents a validator of a custom annotation.
Since:
2.0.0
Author:
MrIvanPlays
  • Method Summary

    Modifier and Type
    Method
    Description
    validate(T annotation, Object value, CustomOptions options, Field field)
    AnnotationConfig calls this method whenever it finds the custom annotation this validator is bound to in order to determine whether the inputted value is valid for the custom annotation with which the inputted Field field was annotated.
    default Object
    AnnotationConfig calls this method whenever it finds the custom annotation this validator is bound to in order to write the value to a config.
  • Method Details

    • validate

      ValidationResponse validate(T annotation, Object value, CustomOptions options, Field field)
      AnnotationConfig calls this method whenever it finds the custom annotation this validator is bound to in order to determine whether the inputted value is valid for the custom annotation with which the inputted Field field was annotated.
      Parameters:
      annotation - the annotation this validator validates
      value - the value AnnotationConfig received
      options - the custom options for the config resolver
      field - the annotated field
      Returns:
      validation response
      See Also:
    • writeValue

      default Object writeValue(Object value)
      AnnotationConfig calls this method whenever it finds the custom annotation this validator is bound to in order to write the value to a config. Method is optional to implement, if it is not implemented, or returns null, AnnotationConfig will write the value in the default way it can.

      If the returned value is an object, for which there is a registered FieldTypeSerializer, it will serialize it accordingly.

      Parameters:
      value - the value to write
      Returns:
      an easier serializable value