Package com.karuslabs.elementary.junit
Class Labels
java.lang.Object
com.karuslabs.elementary.junit.Labels
Utilities to find and manipulate elements annotated with
@Label in an
annotation processing round when used in conjunction with ToolsExtension.-
Constructor Summary
ConstructorsConstructorDescriptionLabels(RoundEnvironment environment) Creates aLabelsfor the given annotation processing round. -
Method Summary
Modifier and TypeMethodDescriptionall()Returns all elements annotated with@Labelin this annotation processing round.Returns an element annotated with the given label in the annotation processing round.Returns elements annotated with@Labeland the given get.groups()Returns all elements annotated with@Labelin this annotation processing round.iterator()Returns an iterator over theElements annotated with@Label.single()Returns an element if this annotation processing round contains exactly a single element annotated with@Label.intsize()Returns the number of elements annotated with@Labelin this annotation processing round.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Labels
Creates aLabelsfor the given annotation processing round.- Parameters:
environment- the round's environment
-
-
Method Details
-
get
Returns an element annotated with the given label in the annotation processing round.- Parameters:
label- the index of the element- Returns:
- the element at the given index
- Throws:
NoSuchElementException- if no element with the given label exists
-
single
Returns an element if this annotation processing round contains exactly a single element annotated with@Label.- Returns:
- the only element annotated with
@Label; otherwisenull - Throws:
IllegalStateException- if there is no elements or more than 1 elements
-
group
Returns elements annotated with@Labeland the given get.- Parameters:
group- the get- Returns:
- the annotated elements
- Throws:
NoSuchElementException- if no elements with the given group exists
-
all
Returns all elements annotated with@Labelin this annotation processing round.- Returns:
- the annotated elements
-
groups
Returns all elements annotated with@Labelin this annotation processing round.- Returns:
- the annotated elements
-
iterator
Returns an iterator over theElements annotated with@Label. -
size
public int size()Returns the number of elements annotated with@Labelin this annotation processing round.- Returns:
- the number of elements
-