Package com.tngtech.archunit.core.domain
Class JavaMethod
java.lang.Object
com.tngtech.archunit.core.domain.JavaMember
com.tngtech.archunit.core.domain.JavaCodeUnit
com.tngtech.archunit.core.domain.JavaMethod
- All Implemented Interfaces:
HasDescription
,CanBeAnnotated
,HasAnnotations<JavaMember>
,HasDescriptor
,HasModifiers
,HasName
,HasName.AndFullName
,HasOwner<JavaClass>
,HasParameterTypes
,HasReturnType
,HasSourceCodeLocation
,HasThrowsClause<JavaCodeUnit>
,HasTypeParameters<JavaCodeUnit>
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tngtech.archunit.core.domain.JavaCodeUnit
JavaCodeUnit.Functions, 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
Modifier and TypeMethodDescriptiongetAnnotationOfType
(String typeName) Returns the default value of this annotation method, if the method is an annotation method and has a declared default.boolean
isMethod()
reflect()
tryGetAnnotationOfType
(String typeName) Methods inherited from class com.tngtech.archunit.core.domain.JavaCodeUnit
getAccessesFromSelf, getCallsFromSelf, getCodeUnitReferencesFromSelf, getConstructorCallsFromSelf, getConstructorReferencesFromSelf, getExceptionTypes, getFieldAccesses, getFullName, getInstanceofChecks, getMethodCallsFromSelf, getMethodReferencesFromSelf, getParameterAnnotations, getParameters, getParameterTypes, getRawParameterTypes, getRawReturnType, getReferencedClassObjects, getReturnType, getTryCatchBlocks, isConstructor
Methods inherited from class com.tngtech.archunit.core.domain.JavaMember
getAnnotationOfType, getDescriptor, getModifiers, getName, getOwner, getReverseDependencies, getSourceCodeLocation, isAnnotatedWith, isAnnotatedWith, isAnnotatedWith, isMetaAnnotatedWith, isMetaAnnotatedWith, isMetaAnnotatedWith, toString, tryGetAnnotationOfType
-
Method Details
-
getTypeParameters
- Specified by:
getTypeParameters
in interfaceHasTypeParameters<JavaCodeUnit>
- Overrides:
getTypeParameters
in classJavaCodeUnit
- 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() {..}
-
getThrowsClause
- Specified by:
getThrowsClause
in interfaceHasThrowsClause<JavaCodeUnit>
- Specified by:
getThrowsClause
in classJavaCodeUnit
-
getDefaultValue
Returns the default value of this annotation method, if the method is an annotation method and has a declared default. It's analogue toMethod.getDefaultValue()
, but returns Optional.absent() instead of null.- Returns:
- Optional.of(defaultValue) if applicable, otherwise Optional.absent()
-
isMethod
- Overrides:
isMethod
in classJavaCodeUnit
-
getCallsOfSelf
- Specified by:
getCallsOfSelf
in classJavaCodeUnit
-
getReferencesToSelf
-
getAccessesToSelf
- Specified by:
getAccessesToSelf
in classJavaMember
-
getAnnotations
- Specified by:
getAnnotations
in interfaceHasAnnotations<JavaMember>
- Overrides:
getAnnotations
in classJavaCodeUnit
-
getAnnotationOfType
- Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaMember>
- Overrides:
getAnnotationOfType
in classJavaCodeUnit
- 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<JavaMember>
- Overrides:
tryGetAnnotationOfType
in classJavaCodeUnit
- 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:
-
reflect
Description copied from class:JavaMember
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.- Specified by:
reflect
in classJavaMember
- Returns:
- The
Member
equivalent to thisJavaMember
-
getDescription
-