Class AnnotationTypeRegistry


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

      Constructors 
      Constructor Description
      AnnotationTypeRegistry()
      Creates a new empty registry.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears all registered annotation types.
      AnnotationType getType​(int id)
      Returns an annotation type with the given id.
      AnnotationType getType​(java.lang.String name)
      Returns an annotation type with the given name.
      java.util.Map<java.lang.String,​AnnotationType> getTypes()
      Returns an unmodifiable Map of all types registered.
      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.
      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.
      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.
      boolean unregister​(java.lang.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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:
        java.lang.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​(java.lang.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:
        java.lang.IllegalArgumentException - if the ID and name of this annotation type are present, but they do not belong together.
      • getType

        public AnnotationType getType​(java.lang.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
      • getTypes

        public java.util.Map<java.lang.String,​AnnotationType> getTypes()
        Returns an unmodifiable Map of all types registered.
        Returns:
        an unmodifiable Map of all types registered.
      • clear

        public void clear()
        Clears all registered annotation types.