public interface ILcdAnnotatedElement
An annotated element is an entity to which annotations can be attached. An annotation is
an object of a class that implements ILcdAnnotation
. For any given annotation class,
there can be at most one annotation instance attached to an annotated element. As such,
an annotated element serves as a map from annotation class to
annotation instance.
A primary example of annotations is their usage in the LuciadLightspeed meta model.
TLcdDataModel
, TLcdDataType
and TLcdDataProperty
implement this interface. As such, custom meta data can be attached to instances of these
classes. This makes the meta model extensible. A simple example of such custom meta data is
the TLcdISO19103MeasureAnnotation
. This annotation asserts that
values of the properties to which it is added are of the ISO measure stored in the annotation.
Note that annotations are modeled similar to the way annotations have
been added to Java classes (see also java.lang.annotation.Annotation
). In contract with
Java AnnotatedElement
, ILcdAnnotatedElement
supports
the addition and removal of annotations.
Note that an annotated element is not guaranteed to be thread safe. It is up to the implementation to decide to support this or not.
Modifier and Type | Method and Description |
---|---|
<T extends ILcdAnnotation> |
addAnnotation(ILcdAnnotation aAnnotation)
Adds the given annotation to this element.
|
<T extends ILcdAnnotation> |
getAnnotation(Class<T> aAnnotationClass)
Returns the element's annotation for the specified class if such an annotation is present,
else null.
|
Collection<ILcdAnnotation> |
getAnnotations()
Returns all annotations present on this element as an unmodifiable collection.
|
boolean |
isAnnotationPresent(Class<? extends ILcdAnnotation> aAnnotationClass)
Returns true if an annotation for the specified class is present on this element,
else false.
|
<T extends ILcdAnnotation> |
removeAnnotation(Class<T> aAnnotationClass)
Removes the annotation of the given class from this element.
|
<T extends ILcdAnnotation> T getAnnotation(Class<T> aAnnotationClass)
Returns the element's annotation for the specified class if such an annotation is present, else null.
Note that the exact annotation class needs to be passed as parameter.
In other words, in case the element
is only annotated with instances of subclasses of the given annotation class,
null
is returned.
aAnnotationClass
- - the Class object corresponding to the annotation typeboolean isAnnotationPresent(Class<? extends ILcdAnnotation> aAnnotationClass)
Returns true if an annotation for the specified class is present on this element, else false. This method is designed primarily for convenient access to marker annotations.
Note that the exact annotation class needs to be passed as parameter.
In other words, in case the element
is only annotated with instances of subclasses of the given annotation class,
false
is returned.
aAnnotationClass
- the Class object corresponding to the annotation classCollection<ILcdAnnotation> getAnnotations()
<T extends ILcdAnnotation> T addAnnotation(ILcdAnnotation aAnnotation)
aAnnotation
- the annotation to add<T extends ILcdAnnotation> T removeAnnotation(Class<T> aAnnotationClass)
Removes the annotation of the given class from this element.
Note that the exact annotation class needs to be passed as parameter.
In other words, in case the element
is only annotated with instances of subclasses of the given annotation class,
nothing is removed and null
is returned.
aAnnotationClass
- the class of annotation to remove