Package com.yahoo.document.annotation
Class AnnotationTypeRegistry
java.lang.Object
com.yahoo.document.annotation.AnnotationTypeRegistry
A registry of annotation types. This can be set up programmatically or from config.
- Author:
- Einar M R Rosenvinge
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all registered annotation types.getType
(int id) Returns an annotation type with the given id.Returns an annotation type with the given name.getTypes()
Returns an unmodifiable of all types registered.void
register
(AnnotationType type) Register a new annotation type.boolean
unregister
(int id) Unregisters the type given by the argument.boolean
unregister
(AnnotationType type) Unregisters the type given by the argument.boolean
unregister
(String name) Unregisters the type given by the argument.
-
Constructor Details
-
AnnotationTypeRegistry
public AnnotationTypeRegistry()Creates a new empty registry.
-
-
Method Details
-
register
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
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
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
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
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
Returns an unmodifiable of all types registered. -
clear
public void clear()Clears all registered annotation types.
-