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.UtilsNested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasOwner
HasOwner.Functions, HasOwner.PredicatesNested 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) intgetIndex()getOwner()getType()booleanisAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue, if this element is annotated with an annotation matching the given predicate.booleanisAnnotatedWith(Class<? extends Annotation> annotationType) Returnstrue, if this element is annotated with the given annotation type.booleanisAnnotatedWith(String annotationTypeName) booleanisMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue, if this element is meta-annotated with an annotation matching the given predicate.booleanisMetaAnnotatedWith(Class<? extends Annotation> annotationType) Returnstrue, if this element is meta-annotated with the given annotation type.booleanisMetaAnnotatedWith(String annotationTypeName) toString()<A extends Annotation>
Optional<A>tryGetAnnotationOfType(Class<A> type) tryGetAnnotationOfType(String typeName)
-
Method Details
-
getOwner
- Specified by:
getOwnerin interfaceHasOwner<JavaCodeUnit>- Returns:
- The "owner" of this object, compare
HasOwner
-
getIndex
-
getType
-
getRawType
- Specified by:
getRawTypein interfaceHasType- Returns:
- The raw type of this object. This is effectively the same as calling
HasType.getType().toErasure(). E.g. given aJavaParameterizedTypejava.util.List<String>the raw type (i.e. type erasure) would be theJavaClassjava.util.List. - See Also:
-
isAnnotatedWith
Description copied from interface:CanBeAnnotatedReturnstrue, if this element is annotated with the given annotation type.- Specified by:
isAnnotatedWithin interfaceCanBeAnnotated- Parameters:
annotationType- The type of the annotation to check for
-
isAnnotatedWith
- Specified by:
isAnnotatedWithin interfaceCanBeAnnotated- Parameters:
annotationTypeName- Fully qualified class name of a specific type ofAnnotation- See Also:
-
isAnnotatedWith
Description copied from interface:CanBeAnnotatedReturnstrue, if this element is annotated with an annotation matching the given predicate.- Specified by:
isAnnotatedWithin interfaceCanBeAnnotated- Parameters:
predicate- Qualifies matching annotations
-
isMetaAnnotatedWith
Description copied from interface:CanBeAnnotatedReturnstrue, 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
trueif this element is directly annotated with the given annotation type.- Specified by:
isMetaAnnotatedWithin interfaceCanBeAnnotated- Parameters:
annotationType- The type of the annotation to check for
-
isMetaAnnotatedWith
- Specified by:
isMetaAnnotatedWithin interfaceCanBeAnnotated- Parameters:
annotationTypeName- Fully qualified class name of a specific type ofAnnotation- See Also:
-
isMetaAnnotatedWith
Description copied from interface:CanBeAnnotatedReturnstrue, 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
trueif this element is directly annotated with an annotation matching the given predicate.- Specified by:
isMetaAnnotatedWithin interfaceCanBeAnnotated- Parameters:
predicate- Qualifies matching annotations
-
getAnnotations
- Specified by:
getAnnotationsin interfaceHasAnnotations<JavaParameter>
-
getAnnotationOfType
- Specified by:
getAnnotationOfTypein interfaceHasAnnotations<JavaParameter>- Type Parameters:
A- The type of theAnnotationto retrieve- Parameters:
type- TheClassof theAnnotationto retrieve.- Returns:
- The
Annotationof the given type. Will throw anIllegalArgumentExceptionif no matchingAnnotationis present. - See Also:
-
getAnnotationOfType
- Specified by:
getAnnotationOfTypein interfaceHasAnnotations<JavaParameter>- Parameters:
typeName- The fully qualified class name of theAnnotationtype to retrieve.- Returns:
- The
JavaAnnotationmatching the given type. Will throw anIllegalArgumentExceptionif no matchingAnnotationis present. - See Also:
-
tryGetAnnotationOfType
- Specified by:
tryGetAnnotationOfTypein interfaceHasAnnotations<JavaParameter>- Type Parameters:
A- The type of theAnnotationto retrieve- Parameters:
type- TheClassof theAnnotationto retrieve.- Returns:
- The
Annotationof the given type orOptional.empty()if there is noAnnotationwith the respective annotation type. - See Also:
-
tryGetAnnotationOfType
- Specified by:
tryGetAnnotationOfTypein interfaceHasAnnotations<JavaParameter>- Parameters:
typeName- The fully qualified class name of theAnnotationtype to retrieve.- Returns:
- The
JavaAnnotationmatching the given type orOptional.empty()if there is noAnnotationwith the respective annotation type. - See Also:
-
getDescription
- Specified by:
getDescriptionin interfaceHasDescription
-
toString
-