Package com.tngtech.archunit.core.domain
Class JavaCodeUnit
java.lang.Object
com.tngtech.archunit.core.domain.JavaMember
com.tngtech.archunit.core.domain.JavaCodeUnit
- All Implemented Interfaces:
HasDescription
,CanBeAnnotated
,HasAnnotations<JavaMember>
,HasDescriptor
,HasModifiers
,HasName
,HasName.AndFullName
,HasOwner<JavaClass>
,HasParameterTypes
,HasReturnType
,HasSourceCodeLocation
,HasThrowsClause<JavaCodeUnit>
,HasTypeParameters<JavaCodeUnit>
- Direct Known Subclasses:
JavaConstructor
,JavaMethod
,JavaStaticInitializer
public abstract class JavaCodeUnit extends JavaMember implements HasParameterTypes, HasReturnType, HasTypeParameters<JavaCodeUnit>, HasThrowsClause<JavaCodeUnit>
Represents a unit of code containing accesses to other units of code. A unit of code can be
- a method
- a constructor
- a static initializer
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JavaCodeUnit.Functions
static class
JavaCodeUnit.Predicates
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
-
Method Summary
Methods inherited from class com.tngtech.archunit.core.domain.JavaMember
getAccessesToSelf, getAnnotationOfType, getDescriptor, getModifiers, getName, getOwner, getReverseDependencies, getSourceCodeLocation, isAnnotatedWith, isAnnotatedWith, isAnnotatedWith, isMetaAnnotatedWith, isMetaAnnotatedWith, isMetaAnnotatedWith, reflect, toString, tryGetAnnotationOfType
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
-
Method Details
-
getFullName
- Specified by:
getFullName
in interfaceHasName.AndFullName
- Returns:
- The full name of this
JavaCodeUnit
, i.e. a string containing${declaringClass}.${name}(${parameterTypes})
-
getRawParameterTypes
- Specified by:
getRawParameterTypes
in interfaceHasParameterTypes
- Returns:
- the raw parameter types of this object, e.g.
for a method
this would be thevoid someMethod(String first, int second) {..}
JavaClasses
equivalent to[String.class, int.class]
,
for a method
this would be the erasure of the generic type variable<T> void someMethod(T generic) {..}
T
, i.e. theJavaClass
equivalent toObject.class
.
Note that for non-generic cases this returns the same asHasParameterTypes.getParameterTypes()
.
-
getParameterTypes
- Specified by:
getParameterTypes
in interfaceHasParameterTypes
- Returns:
- the raw parameter types of this object, e.g.
for a method
this would be thevoid someMethod(String first, int second) {..}
JavaClasses
equivalent to[String.class, int.class]
,
for a method
this would be the<T> void someMethod(T generic) {..}
JavaTypeVariable
T
.
Note that for non-generic cases this returns the same asHasParameterTypes.getRawParameterTypes()
.
-
getThrowsClause
- Specified by:
getThrowsClause
in interfaceHasThrowsClause<JavaCodeUnit>
-
getExceptionTypes
- Returns:
- The types thrown by this method, similar to
Method.getExceptionTypes()
-
getReturnType
- Specified by:
getReturnType
in interfaceHasReturnType
-
getRawReturnType
- Specified by:
getRawReturnType
in interfaceHasReturnType
-
getFieldAccesses
-
getMethodCallsFromSelf
-
getConstructorCallsFromSelf
-
getReferencedClassObjects
-
getInstanceofChecks
-
getCallsFromSelf
-
getAccessesFromSelf
-
isConstructor
-
getAnnotations
- Specified by:
getAnnotations
in interfaceHasAnnotations<JavaMember>
- Overrides:
getAnnotations
in classJavaMember
-
getAnnotationOfType
- Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaMember>
- Overrides:
getAnnotationOfType
in classJavaMember
-
tryGetAnnotationOfType
public Optional<? extends JavaAnnotation<? extends JavaCodeUnit>> tryGetAnnotationOfType(java.lang.String typeName)- Specified by:
tryGetAnnotationOfType
in interfaceHasAnnotations<JavaMember>
- Overrides:
tryGetAnnotationOfType
in classJavaMember
-
getTypeParameters
@PublicAPI(usage=ACCESS) public java.util.List<? extends JavaTypeVariable<? extends JavaCodeUnit>> getTypeParameters()- Specified by:
getTypeParameters
in interfaceHasTypeParameters<JavaCodeUnit>
- Returns:
- the type parameters of this object, e.g. for any generic method
this would return the<A, B> B someMethod(A a) {..}
JavaTypeVariables
[A, B]
.
If this object is non-generic, e.g. a method
an empty list will be returned.void someMethod() {..}
-