Enum CustomAnnotationRegistry

java.lang.Object
java.lang.Enum<CustomAnnotationRegistry>
com.mrivanplays.annotationconfig.core.annotations.custom.CustomAnnotationRegistry
All Implemented Interfaces:
Serializable, Comparable<CustomAnnotationRegistry>, java.lang.constant.Constable

Represents a registry for custom annotations.
Since:
2.0.0
Author:
MrIvanPlays
  • Enum Constant Details

  • Method Details

    • values

      public static CustomAnnotationRegistry[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static CustomAnnotationRegistry valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • register

      public <T extends Annotation> void register(Class<T> annotation, AnnotationValidator<T> validator)
      Binds the specified AnnotationValidator validator to the specified annotation.
      Type Parameters:
      T - annotation type
      Parameters:
      annotation - the annotation you want this validator to be bound to
      validator - the bind validator
      Throws:
      IllegalArgumentException - if the annotation already has a validator.
    • unregister

      public void unregister(Class<? extends Annotation> annotation)
      Removes the bound to the specified annotation AnnotationValidator if there is any.
      Parameters:
      annotation - the annotation you want to remove the validator of
      Throws:
      IllegalArgumentException - if no validator was present for the specified annotation
    • hasValidator

      public boolean hasValidator(Class<? extends Annotation> annotation)
      Returns whether the specified annotation has a validator.
      Parameters:
      annotation - the annotation you want to check for validator
      Returns:
      true if there is a validator, false otherwise
    • isEmpty

      public boolean isEmpty()
      Returns whether the registry contains any validators.
      Returns:
      true if empty, false otherwise.
    • getValidator

      public Optional<AnnotationValidator<? extends Annotation>> getValidator(Class<? extends Annotation> annotationClass)
      Returns the AnnotationValidator bound to the specified annotationClass.
      Parameters:
      annotationClass - the annotation of which you want the validator
      Returns:
      annotation validator optional, which can be empty