Package net.sf.okapi.common.annotation
Class Annotations
- java.lang.Object
-
- net.sf.okapi.common.annotation.Annotations
-
- All Implemented Interfaces:
Iterable<IAnnotation>
public class Annotations extends Object implements Iterable<IAnnotation>
Provides annotation mechanism to the resources.
-
-
Constructor Summary
Constructors Constructor Description Annotations()
Creates a new Annotations object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all the annotations in this object.Annotations
clone()
Clones this Annotations object.<A extends IAnnotation>
Aget(Class<A> annotationType)
Gets the annotation for a given type.Set<Class<? extends IAnnotation>>
getAnnotationsTypes()
boolean
isEmpty()
Iterator<IAnnotation>
iterator()
<A extends IAnnotation>
Aremove(Class<A> annotationType)
Removes the annotation of a given type.<T extends IAnnotation>
voidset(T annotation)
Sets an annotation.-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
set
public <T extends IAnnotation> void set(T annotation)
Sets an annotation.- Type Parameters:
T
- the annotation type.- Parameters:
annotation
- The annotation object to set.
-
get
public <A extends IAnnotation> A get(Class<A> annotationType)
Gets the annotation for a given type.- Type Parameters:
A
- the annotation type- Parameters:
annotationType
- Type of the annotation to retrieve.- Returns:
- The found annotation, or null if no annotation of the given type was found.
-
clear
public void clear()
Removes all the annotations in this object.
-
remove
public <A extends IAnnotation> A remove(Class<A> annotationType)
Removes the annotation of a given type.- Type Parameters:
A
- the annotation type- Parameters:
annotationType
- Type of the annotation to remove.- Returns:
- The removed annotation, or null if no annotation of the given type was found.
-
clone
public Annotations clone()
Clones this Annotations object.Important: the annotations themselves are not cloned, only the map holding them is new.
-
iterator
public Iterator<IAnnotation> iterator()
- Specified by:
iterator
in interfaceIterable<IAnnotation>
-
getAnnotationsTypes
public Set<Class<? extends IAnnotation>> getAnnotationsTypes()
-
isEmpty
public boolean isEmpty()
-
-