Package com.tngtech.archunit.core.domain
Class JavaMember
java.lang.Object
com.tngtech.archunit.core.domain.JavaMember
- All Implemented Interfaces:
HasDescription
,CanBeAnnotated
,HasAnnotations<JavaMember>
,HasDescriptor
,HasModifiers
,HasName
,HasName.AndFullName
,HasOwner<JavaClass>
,HasSourceCodeLocation
- Direct Known Subclasses:
JavaCodeUnit
,JavaField
@PublicAPI(usage=ACCESS)
public abstract class JavaMember
extends Object
implements HasName.AndFullName, HasDescriptor, HasAnnotations<JavaMember>, HasModifiers, HasOwner<JavaClass>, HasSourceCodeLocation
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.CanBeAnnotated
CanBeAnnotated.Utils
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasName
HasName.AndFullName, HasName.Utils
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasName.AndFullName
HasName.AndFullName.Functions
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasOwner
HasOwner.Functions
-
Method Summary
Modifier and TypeMethodDescriptionabstract Set<? extends JavaAccess<?>>
<A extends Annotation>
AgetAnnotationOfType
(Class<A> type) Returns theAnnotation
of this member of the givenAnnotation
type.JavaAnnotation<? extends JavaMember>
getAnnotationOfType
(String typeName) Set<? extends JavaAnnotation<? extends JavaMember>>
getName()
getOwner()
protected com.tngtech.archunit.core.domain.ReverseDependencies
boolean
isAnnotatedWith
(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue
, if this element is annotated with an annotation matching the given predicate.boolean
isAnnotatedWith
(Class<? extends Annotation> type) Returnstrue
, if this element is annotated with the given annotation type.boolean
isAnnotatedWith
(String typeName) 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> type) Returnstrue
, if this element is meta-annotated with the given annotation type.boolean
isMetaAnnotatedWith
(String typeName) abstract Member
reflect()
toString()
<A extends Annotation>
Optional<A>tryGetAnnotationOfType
(Class<A> type) Optional<? extends JavaAnnotation<? extends JavaMember>>
tryGetAnnotationOfType
(String typeName) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.tngtech.archunit.base.HasDescription
getDescription
Methods inherited from interface com.tngtech.archunit.core.domain.properties.HasName.AndFullName
getFullName
-
Method Details
-
getAnnotations
@PublicAPI(usage=ACCESS) public Set<? extends JavaAnnotation<? extends JavaMember>> getAnnotations()- Specified by:
getAnnotations
in interfaceHasAnnotations<JavaMember>
-
getAnnotationOfType
Returns theAnnotation
of this member of the givenAnnotation
type.- Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaMember>
- 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. - Throws:
IllegalArgumentException
- if there is no annotation of the respective reflection type- See Also:
-
getAnnotationOfType
@PublicAPI(usage=ACCESS) public JavaAnnotation<? extends JavaMember> getAnnotationOfType(String typeName) - Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaMember>
- 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
@PublicAPI(usage=ACCESS) public <A extends Annotation> Optional<A> tryGetAnnotationOfType(Class<A> type) - Specified by:
tryGetAnnotationOfType
in interfaceHasAnnotations<JavaMember>
- 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
@PublicAPI(usage=ACCESS) public Optional<? extends JavaAnnotation<? extends JavaMember>> tryGetAnnotationOfType(String typeName) - Specified by:
tryGetAnnotationOfType
in interfaceHasAnnotations<JavaMember>
- 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:
-
isAnnotatedWith
Description copied from interface:CanBeAnnotated
Returnstrue
, if this element is annotated with the given annotation type.- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
type
- The type of the annotation to check for
-
isAnnotatedWith
- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
typeName
- Fully qualified class name of a specific type ofAnnotation
- See Also:
-
isAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) 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:
type
- The type of the annotation to check for
-
isMetaAnnotatedWith
- Specified by:
isMetaAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
typeName
- Fully qualified class name of a specific type ofAnnotation
- See Also:
-
isMetaAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) 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
-
getOwner
-
getSourceCodeLocation
- Specified by:
getSourceCodeLocation
in interfaceHasSourceCodeLocation
- Returns:
- The
SourceCodeLocation
of this object, i.e. how to locate the respective object within the set of source files.
-
getModifiers
- Specified by:
getModifiers
in interfaceHasModifiers
-
getName
-
getDescriptor
- Specified by:
getDescriptor
in interfaceHasDescriptor
-
getAccessesToSelf
-
reflect
Resolves the respectiveMember
from the classpath.
NOTE: This method will throw an exception, if the owningClass
or any of its dependencies can't be found on the classpath.- Returns:
- The
Member
equivalent to thisJavaMember
-
getReverseDependencies
protected com.tngtech.archunit.core.domain.ReverseDependencies getReverseDependencies() -
toString
-