Interface Description
- All Known Implementing Classes:
AnnotationDescription, ClassDescription, MethodDescription, PackageDescription, ParameterDescription
public sealed interface Description
permits AnnotationDescription<T>, ClassDescription, MethodDescription, PackageDescription, ParameterDescription
The common interface of all Description types.
A Description is, as the name says, a description of a class, method or parameter, similar to how
java.lang.reflect works.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends Annotation>
Tannotation(Class<T> type) Gets theAnnotationof this element for the specified type.Gets allAnnotations this element is annotated withdefault <T extends Annotation>
Optional<T> findAnnotation(Class<T> type) Gets theAnnotationof this element for the specified type if such an annotation is presentdefault booleanhasAnnotation(Class<? extends Annotation> type) Checks whether this element has anAnnotationof the specified type.
-
Method Details
-
annotations
Collection<AnnotationDescription<?>> annotations()Gets allAnnotations this element is annotated with- Returns:
- a possibly-empty
Collectionof allAnnotations this element is annotated with.
-
findAnnotation
Gets theAnnotationof this element for the specified type if such an annotation is present- Parameters:
type- the type of the annotation to get- Returns:
- an
Optionalholding theAnnotationif present at this element or else an emptyOptional
-
annotation
Gets theAnnotationof this element for the specified type. Throws if no matching annotation is found.- Parameters:
type- the type of the annotation to get- Returns:
- an
Optionalholding theAnnotation - Throws:
NoSuchElementException- if no element was found- See Also:
-
hasAnnotation
Checks whether this element has anAnnotationof the specified type.- Parameters:
type- the type of the annotation- Returns:
trueif the annotation is present elsefalse
-