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 ClassesNested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.CanBeAnnotated
CanBeAnnotated.UtilsNested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasName
HasName.AndFullName, HasName.UtilsNested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasName.AndFullName
HasName.AndFullName.FunctionsNested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasOwner
HasOwner.Functions -
Method Summary
Modifier and TypeMethodDescriptionabstract Set<? extends JavaAccess<?>>Similar toJavaType.getAllInvolvedRawTypes(), this method returns all raw types involved in thismember'ssignature.<A extends Annotation>
AgetAnnotationOfType(Class<A> type) Returns theAnnotationof this member of the givenAnnotationtype.JavaAnnotation<? extends JavaMember>getAnnotationOfType(String typeName) Set<? extends JavaAnnotation<? extends JavaMember>>getName()getOwner()protected com.tngtech.archunit.core.domain.ReverseDependenciesbooleanisAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue, if this element is annotated with an annotation matching the given predicate.booleanisAnnotatedWith(Class<? extends Annotation> type) Returnstrue, if this element is annotated with the given annotation type.booleanisAnnotatedWith(String typeName) booleanisMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue, if this element is meta-annotated with an annotation matching the given predicate.booleanisMetaAnnotatedWith(Class<? extends Annotation> type) Returnstrue, if this element is meta-annotated with the given annotation type.booleanisMetaAnnotatedWith(String typeName) abstract Memberreflect()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, waitMethods inherited from interface com.tngtech.archunit.base.HasDescription
getDescriptionMethods inherited from interface com.tngtech.archunit.core.domain.properties.HasName.AndFullName
getFullName
-
Method Details
-
getAllInvolvedRawTypes
Similar toJavaType.getAllInvolvedRawTypes(), this method returns all raw types involved in thismember'ssignature. For more concrete details refer toJavaField.getAllInvolvedRawTypes()andJavaCodeUnit.getAllInvolvedRawTypes().- Returns:
- All raw types involved in the signature of this member
-
getAnnotations
@PublicAPI(usage=ACCESS) public Set<? extends JavaAnnotation<? extends JavaMember>> getAnnotations()- Specified by:
getAnnotationsin interfaceHasAnnotations<JavaMember>
-
getAnnotationOfType
Returns theAnnotationof this member of the givenAnnotationtype.- Specified by:
getAnnotationOfTypein interfaceHasAnnotations<JavaMember>- 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. - 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:
getAnnotationOfTypein interfaceHasAnnotations<JavaMember>- 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
@PublicAPI(usage=ACCESS) public <A extends Annotation> Optional<A> tryGetAnnotationOfType(Class<A> type) - Specified by:
tryGetAnnotationOfTypein interfaceHasAnnotations<JavaMember>- 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
@PublicAPI(usage=ACCESS) public Optional<? extends JavaAnnotation<? extends JavaMember>> tryGetAnnotationOfType(String typeName) - Specified by:
tryGetAnnotationOfTypein interfaceHasAnnotations<JavaMember>- 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:
-
isAnnotatedWith
Description copied from interface:CanBeAnnotatedReturnstrue, if this element is annotated with the given annotation type.- Specified by:
isAnnotatedWithin interfaceCanBeAnnotated- Parameters:
type- The type of the annotation to check for
-
isAnnotatedWith
- Specified by:
isAnnotatedWithin 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: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:
type- The type of the annotation to check for
-
isMetaAnnotatedWith
- Specified by:
isMetaAnnotatedWithin 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: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
-
getOwner
-
getSourceCodeLocation
- Specified by:
getSourceCodeLocationin interfaceHasSourceCodeLocation- Returns:
- The
SourceCodeLocationof this object, i.e. how to locate the respective object within the set of source files.
-
getModifiers
- Specified by:
getModifiersin interfaceHasModifiers
-
getName
-
getDescriptor
- Specified by:
getDescriptorin interfaceHasDescriptor
-
getAccessesToSelf
-
reflect
Resolves the respectiveMemberfrom the classpath.
NOTE: This method will throw an exception, if the owningClassor any of its dependencies can't be found on the classpath.- Returns:
- The
Memberequivalent to thisJavaMember
-
getReverseDependencies
protected com.tngtech.archunit.core.domain.ReverseDependencies getReverseDependencies() -
toString
-