Package com.tngtech.archunit.core.domain
Class JavaParameter
java.lang.Object
com.tngtech.archunit.core.domain.JavaParameter
- All Implemented Interfaces:
HasDescription
,CanBeAnnotated
,HasAnnotations<JavaParameter>
,HasOwner<JavaCodeUnit>
,HasType
@PublicAPI(usage=ACCESS)
public final class JavaParameter
extends Object
implements HasType, HasOwner<JavaCodeUnit>, HasAnnotations<JavaParameter>
A parameter of a
JavaCodeUnit
, i.e. encapsulates the raw parameter type, the (possibly) generic
parameter type and any annotations this parameter has.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.CanBeAnnotated
CanBeAnnotated.Predicates, CanBeAnnotated.Utils
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasOwner
HasOwner.Functions, HasOwner.Predicates
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasType
HasType.Functions, HasType.Predicates
-
Method Summary
Modifier and TypeMethodDescription<A extends Annotation>
AgetAnnotationOfType
(Class<A> type) getAnnotationOfType
(String typeName) int
getIndex()
getOwner()
getType()
boolean
isAnnotatedWith
(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue
, if this element is annotated with an annotation matching the given predicate.boolean
isAnnotatedWith
(Class<? extends Annotation> annotationType) Returnstrue
, if this element is annotated with the given annotation type.boolean
isAnnotatedWith
(String annotationTypeName) boolean
isMetaAnnotatedWith
(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue
, if this element is meta-annotated with an annotation matching the given predicate.boolean
isMetaAnnotatedWith
(Class<? extends Annotation> annotationType) Returnstrue
, if this element is meta-annotated with the given annotation type.boolean
isMetaAnnotatedWith
(String annotationTypeName) toString()
<A extends Annotation>
Optional<A>tryGetAnnotationOfType
(Class<A> type) tryGetAnnotationOfType
(String typeName)
-
Method Details
-
getOwner
- Specified by:
getOwner
in interfaceHasOwner<JavaCodeUnit>
- Returns:
- The "owner" of this object, compare
HasOwner
-
getIndex
-
getType
-
getRawType
- Specified by:
getRawType
in interfaceHasType
-
isAnnotatedWith
Description copied from interface:CanBeAnnotated
Returnstrue
, if this element is annotated with the given annotation type.- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
annotationType
- The type of the annotation to check for
-
isAnnotatedWith
- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
annotationTypeName
- Fully qualified class name of a specific type ofAnnotation
- See Also:
-
isAnnotatedWith
Description copied from interface:CanBeAnnotated
Returnstrue
, if this element is annotated with an annotation matching the given predicate.- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
predicate
- Qualifies matching annotations
-
isMetaAnnotatedWith
Description copied from interface:CanBeAnnotated
Returnstrue
, if this element is meta-annotated with the given annotation type. A meta-annotation is an annotation that is declared on another annotation.This method also returns
true
if this element is directly annotated with the given annotation type.- Specified by:
isMetaAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
annotationType
- The type of the annotation to check for
-
isMetaAnnotatedWith
- Specified by:
isMetaAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
annotationTypeName
- Fully qualified class name of a specific type ofAnnotation
- See Also:
-
isMetaAnnotatedWith
Description copied from interface:CanBeAnnotated
Returnstrue
, if this element is meta-annotated with an annotation matching the given predicate. A meta-annotation is an annotation that is declared on another annotation.This method also returns
true
if this element is directly annotated with an annotation matching the given predicate.- Specified by:
isMetaAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
predicate
- Qualifies matching annotations
-
getAnnotations
- Specified by:
getAnnotations
in interfaceHasAnnotations<JavaParameter>
-
getAnnotationOfType
- Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaParameter>
- Type Parameters:
A
- The type of theAnnotation
to retrieve- Parameters:
type
- TheClass
of theAnnotation
to retrieve.- Returns:
- The
Annotation
of the given type. Will throw anIllegalArgumentException
if no matchingAnnotation
is present. - See Also:
-
getAnnotationOfType
- Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaParameter>
- Parameters:
typeName
- The fully qualified class name of theAnnotation
type to retrieve.- Returns:
- The
JavaAnnotation
matching the given type. Will throw anIllegalArgumentException
if no matchingAnnotation
is present. - See Also:
-
tryGetAnnotationOfType
- Specified by:
tryGetAnnotationOfType
in interfaceHasAnnotations<JavaParameter>
- Type Parameters:
A
- The type of theAnnotation
to retrieve- Parameters:
type
- TheClass
of theAnnotation
to retrieve.- Returns:
- The
Annotation
of the given type orOptional.empty()
if there is noAnnotation
with the respective annotation type. - See Also:
-
tryGetAnnotationOfType
- Specified by:
tryGetAnnotationOfType
in interfaceHasAnnotations<JavaParameter>
- Parameters:
typeName
- The fully qualified class name of theAnnotation
type to retrieve.- Returns:
- The
JavaAnnotation
matching the given type orOptional.empty()
if there is noAnnotation
with the respective annotation type. - See Also:
-
getDescription
- Specified by:
getDescription
in interfaceHasDescription
-
toString
-