Class AnnotationTypeRegistry


  • public class AnnotationTypeRegistry
    extends Object
    A registry of annotation types. This can be set up programmatically or from config.
    Author:
    Einar M R Rosenvinge
    • Constructor Detail

      • AnnotationTypeRegistry

        public AnnotationTypeRegistry()
        Creates a new empty registry.
    • Method Detail

      • register

        public void register​(AnnotationType type)
        Register a new annotation type. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code.
        Parameters:
        type - the type to register
        Throws:
        IllegalArgumentException - if a type is already registered with this name or this id, and it is non-equal to the argument.
      • unregister

        public boolean unregister​(String name)
        Unregisters the type given by the argument. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code.
        Parameters:
        name - the name of the type to unregister
        Returns:
        true if the type was successfully unregistered, false otherwise (it was not present)
      • unregister

        public boolean unregister​(int id)
        Unregisters the type given by the argument. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code.
        Parameters:
        id - the id of the type to unregister
        Returns:
        true if the type was successfully unregistered, false otherwise (it was not present)
      • unregister

        public boolean unregister​(AnnotationType type)
        Unregisters the type given by the argument. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code.
        Parameters:
        type - the AnnotationType to unregister
        Returns:
        true if the type was successfully unregistered, false otherwise (it was not present)
        Throws:
        IllegalArgumentException - if the ID and name of this annotation type are present, but they do not belong together.
      • getType

        public AnnotationType getType​(String name)
        Returns an annotation type with the given name.
        Parameters:
        name - the name of the annotation type to return
        Returns:
        an AnnotationType with the given name, or null if it is not registered
      • getType

        public AnnotationType getType​(int id)
        Returns an annotation type with the given id.
        Parameters:
        id - the id of the annotation type to return
        Returns:
        an AnnotationType with the given id, or null if it is not registered
      • clear

        public void clear()
        Clears all registered annotation types.