Package com.tngtech.archunit.core.domain
Class JavaClass
- java.lang.Object
-
- com.tngtech.archunit.core.domain.JavaClass
-
- All Implemented Interfaces:
HasDescription
,CanBeAnnotated
,HasAnnotations<JavaClass>
,HasModifiers
,HasName
,HasName.AndFullName
,HasSourceCodeLocation
public class JavaClass extends java.lang.Object implements HasName.AndFullName, HasAnnotations<JavaClass>, HasModifiers, HasSourceCodeLocation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JavaClass.Functions
static class
JavaClass.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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Set<JavaAccess<?>>
getAccessesFromSelf()
java.util.Set<JavaAccess<?>>
getAccessesToSelf()
java.util.Set<JavaAccess<?>>
getAllAccessesFromSelf()
java.util.Set<JavaClass>
getAllClassesSelfIsAssignableTo()
java.util.Set<JavaConstructor>
getAllConstructors()
java.util.Set<JavaField>
getAllFields()
java.util.Set<JavaClass>
getAllInterfaces()
java.util.Set<JavaMember>
getAllMembers()
java.util.Set<JavaMethod>
getAllMethods()
java.util.Set<JavaClass>
getAllSubClasses()
java.util.List<JavaClass>
getAllSuperClasses()
<A extends java.lang.annotation.Annotation>
AgetAnnotationOfType(java.lang.Class<A> type)
JavaAnnotation<JavaClass>
getAnnotationOfType(java.lang.String typeName)
java.util.Set<JavaAnnotation<JavaClass>>
getAnnotations()
java.util.Set<JavaAnnotation<?>>
getAnnotationsWithTypeOfSelf()
java.util.Set<JavaCall<?>>
getCallsFromSelf()
Returns all calls of this class to methods or constructors.java.util.List<JavaClass>
getClassHierarchy()
java.util.Set<JavaCodeUnit>
getCodeUnits()
JavaCodeUnit
getCodeUnitWithParameterTypeNames(java.lang.String name, java.lang.String... parameters)
Same asgetCodeUnitWithParameterTypes(String, Class[])
, but with parameter signature specified as full class namesJavaCodeUnit
getCodeUnitWithParameterTypeNames(java.lang.String name, java.util.List<java.lang.String> parameters)
JavaCodeUnit
getCodeUnitWithParameterTypes(java.lang.String name, java.lang.Class<?>... parameters)
JavaCodeUnit
getCodeUnitWithParameterTypes(java.lang.String name, java.util.List<java.lang.Class<?>> parameters)
JavaClass
getComponentType()
This is a convenience method fortryGetComponentType()
in cases where clients know that this type is certainly an array type and thus the component type present.JavaConstructor
getConstructor()
JavaConstructor
getConstructor(java.lang.Class<?>... parameters)
JavaConstructor
getConstructor(java.lang.String... parameters)
java.util.Set<JavaConstructorCall>
getConstructorCallsFromSelf()
java.util.Set<JavaConstructorCall>
getConstructorCallsToSelf()
java.util.Set<JavaConstructor>
getConstructors()
java.util.Set<JavaConstructor>
getConstructorsWithParameterTypeOfSelf()
java.util.Set<ThrowsDeclaration<JavaConstructor>>
getConstructorsWithThrowsDeclarationTypeOfSelf()
java.lang.String
getDescription()
java.util.Set<Dependency>
getDirectDependenciesFromSelf()
Returns all dependencies originating directly from this class (i.e.java.util.Set<Dependency>
getDirectDependenciesToSelf()
LikegetDirectDependenciesFromSelf()
, but instead returns all dependencies where this class is target.Optional<JavaClass>
getEnclosingClass()
JavaEnumConstant
getEnumConstant(java.lang.String name)
java.util.Set<JavaEnumConstant>
getEnumConstants()
JavaField
getField(java.lang.String name)
java.util.Set<JavaFieldAccess>
getFieldAccessesFromSelf()
java.util.Set<JavaFieldAccess>
getFieldAccessesToSelf()
java.util.Set<JavaField>
getFields()
java.util.Set<JavaField>
getFieldsWithTypeOfSelf()
java.lang.String
getFullName()
java.util.Set<JavaClass>
getInterfaces()
java.util.Set<JavaMember>
getMembers()
JavaMethod
getMethod(java.lang.String name)
JavaMethod
getMethod(java.lang.String name, java.lang.Class<?>... parameters)
JavaMethod
getMethod(java.lang.String name, java.lang.String... parameters)
java.util.Set<JavaMethodCall>
getMethodCallsFromSelf()
java.util.Set<JavaMethodCall>
getMethodCallsToSelf()
java.util.Set<JavaMethod>
getMethods()
java.util.Set<JavaMethod>
getMethodsWithParameterTypeOfSelf()
java.util.Set<JavaMethod>
getMethodsWithReturnTypeOfSelf()
java.util.Set<ThrowsDeclaration<JavaMethod>>
getMethodThrowsDeclarationsWithTypeOfSelf()
java.util.Set<JavaModifier>
getModifiers()
java.lang.String
getName()
JavaPackage
getPackage()
java.lang.String
getPackageName()
java.lang.String
getSimpleName()
Optional<Source>
getSource()
SourceCodeLocation
getSourceCodeLocation()
Optional<JavaStaticInitializer>
getStaticInitializer()
java.util.Set<JavaClass>
getSubClasses()
Optional<JavaClass>
getSuperClass()
boolean
isAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate)
boolean
isAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
boolean
isAnnotatedWith(java.lang.String annotationTypeName)
boolean
isAnonymous()
Deprecated.useisAnonymousClass()
insteadboolean
isAnonymousClass()
An anonymous class is an inner class that is automatically derived from a class creation expression with a declared class body, e.g.boolean
isArray()
boolean
isAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
boolean
isAssignableFrom(java.lang.Class<?> type)
boolean
isAssignableFrom(java.lang.String typeName)
boolean
isAssignableTo(DescribedPredicate<? super JavaClass> predicate)
boolean
isAssignableTo(java.lang.Class<?> type)
boolean
isAssignableTo(java.lang.String typeName)
boolean
isEnum()
boolean
isEquivalentTo(java.lang.Class<?> clazz)
boolean
isInnerClass()
An inner class is a nested class that is not explicitly or implicitly declared static.
Example:boolean
isInterface()
boolean
isLocalClass()
A local class is a nested class that is not a member of any class and that has a name.
Example:boolean
isMemberClass()
A member class is a class whose declaration is directly enclosed in the body of another class or interface declaration.
Example:boolean
isMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate)
boolean
isMetaAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> type)
boolean
isMetaAnnotatedWith(java.lang.String typeName)
boolean
isNestedClass()
A nested class is any class whose declaration occurs within the body of another class or interface.
Example:boolean
isPrimitive()
boolean
isTopLevelClass()
A top level class is a class that is not a nested class, i.e.static java.util.List<java.lang.String>
namesOf(java.lang.Class<?>... paramTypes)
static java.util.List<java.lang.String>
namesOf(java.util.List<java.lang.Class<?>> paramTypes)
java.lang.Class<?>
reflect()
Resolves the respectiveClass
from the classpath.
NOTE: This method will throw an exception, if the respectiveClass
or any of its dependencies can't be found on the classpath.java.lang.String
toString()
<A extends java.lang.annotation.Annotation>
Optional<A>tryGetAnnotationOfType(java.lang.Class<A> type)
Optional<JavaAnnotation<JavaClass>>
tryGetAnnotationOfType(java.lang.String typeName)
Same astryGetAnnotationOfType(Class)
, but takes the type name.Optional<JavaEnumConstant>
tryGetEnumConstant(java.lang.String name)
Optional<JavaField>
tryGetField(java.lang.String name)
Optional<JavaMethod>
tryGetMethod(java.lang.String name)
Optional<JavaMethod>
tryGetMethod(java.lang.String name, java.lang.Class<?>... parameters)
Optional<JavaMethod>
tryGetMethod(java.lang.String name, java.lang.String... parameters)
-
-
-
Method Detail
-
getSource
@PublicAPI(usage=ACCESS) public Optional<Source> getSource()
-
getSourceCodeLocation
@PublicAPI(usage=ACCESS) public SourceCodeLocation 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.
-
getDescription
@PublicAPI(usage=ACCESS) public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceHasDescription
-
getName
@PublicAPI(usage=ACCESS) public java.lang.String getName()
-
getFullName
@PublicAPI(usage=ACCESS) public java.lang.String getFullName()
- Specified by:
getFullName
in interfaceHasName.AndFullName
- Returns:
- The fully qualified name of this
JavaClass
, i.e. the result is the same as invokinggetName()
-
getSimpleName
@PublicAPI(usage=ACCESS) public java.lang.String getSimpleName()
-
getPackage
@PublicAPI(usage=ACCESS) public JavaPackage getPackage()
-
getPackageName
@PublicAPI(usage=ACCESS) public java.lang.String getPackageName()
-
isPrimitive
@PublicAPI(usage=ACCESS) public boolean isPrimitive()
-
isInterface
@PublicAPI(usage=ACCESS) public boolean isInterface()
-
isEnum
@PublicAPI(usage=ACCESS) public boolean isEnum()
-
tryGetEnumConstant
@PublicAPI(usage=ACCESS) public Optional<JavaEnumConstant> tryGetEnumConstant(java.lang.String name)
-
getEnumConstant
@PublicAPI(usage=ACCESS) public JavaEnumConstant getEnumConstant(java.lang.String name)
-
getEnumConstants
@PublicAPI(usage=ACCESS) public java.util.Set<JavaEnumConstant> getEnumConstants()
-
isArray
@PublicAPI(usage=ACCESS) public boolean isArray()
-
getComponentType
@PublicAPI(usage=ACCESS) public JavaClass getComponentType()
This is a convenience method fortryGetComponentType()
in cases where clients know that this type is certainly an array type and thus the component type present.- Returns:
- The result of
tryGetComponentType()
- Throws:
java.lang.IllegalArgumentException
- if this class is no array
-
isTopLevelClass
@PublicAPI(usage=ACCESS) public boolean isTopLevelClass()
A top level class is a class that is not a nested class, i.e. not declared within the body of another class.
Example:
Of all these class declarations onlypublic class TopLevel { class NestedNonStatic {} static class NestedStatic {} void method() { class NestedLocal {} new NestedAnonymous() {} } }
TopLevel
is a top level class, since all other classes are declared within the body ofTopLevel
and are thereby nested classes.
Compare e.g. Java Language Specification- Returns:
true
if this class is a top level class, i.e. not nested inside of any other class,false
otherwise- See Also:
isNestedClass()
,isMemberClass()
,isInnerClass()
,isLocalClass()
,isAnonymousClass()
-
isNestedClass
@PublicAPI(usage=ACCESS) public boolean isNestedClass()
A nested class is any class whose declaration occurs within the body of another class or interface.
Example:
All classespublic class TopLevel { class NestedNonStatic {} static class NestedStatic {} void method() { class NestedLocal {} new NestedAnonymous() {} } }
NestedNonStatic
,NestedStatic
,NestedLocal
and the class the compiler creates for the anonymous class derived from"new NestedAnonymous() {}"
(which will have some generated name likeTopLevel$1
) are considered nested classes.TopLevel
on the other side is no nested class.
Compare e.g. Java Language Specification- Returns:
true
if this class is nested, i.e. declared within another class,false
otherwise (i.e. for top-level classes)- See Also:
isTopLevelClass()
,isMemberClass()
,isInnerClass()
,isLocalClass()
,isAnonymousClass()
-
isMemberClass
@PublicAPI(usage=ACCESS) public boolean isMemberClass()
A member class is a class whose declaration is directly enclosed in the body of another class or interface declaration.
Example:
Bothpublic class TopLevel { class MemberClassNonStatic {} static class MemberClassStatic {} void method() { class NoMemberLocal {} new NoMemberAnonymous() {} } }
MemberClassNonStatic
andMemberClassStatic
are member classes, since they are directly declared within the body ofTopLevel
. On the other handNoMemberLocal
and the class the compiler creates for the anonymous class derived from"new NoMemberAnonymous() {}"
(which will have some generated name likeTopLevel$1
), as well asTopLevel
itself, are not considered member classes.
Compare e.g. Java Language Specification- Returns:
true
if this class is a member class, i.e. directly declared within the body of another class,false
otherwise- See Also:
isTopLevelClass()
,isNestedClass()
,isInnerClass()
,isLocalClass()
,isAnonymousClass()
-
isInnerClass
@PublicAPI(usage=ACCESS) public boolean isInnerClass()
An inner class is a nested class that is not explicitly or implicitly declared static.
Example:
The classespublic class TopLevel { class InnerMemberClass {} static class NoInnerClassSinceDeclaredStatic {} interface NoInnerClassSinceInterface {} void method() { class InnerLocalClass {} new InnerAnonymousClass() {} } }
InnerMemberClass
,InnerLocalClass
and the class the compiler creates for the anonymous class derived from"new InnerAnonymousClass() {}"
(which will have some generated name likeTopLevel$1
) are inner classes since they are nested but not static. On the other handNoInnerClassSinceDeclaredStatic
,NoInnerClassSinceInterface
andTopLevel
are no inner classes, because the former two explicitly or implicitly have thestatic
modifier while the latter one is a top level class.
Compare e.g. Java Language Specification- Returns:
true
if this class is an inner class (i.e. nested but non-static)false
otherwise- See Also:
isTopLevelClass()
,isNestedClass()
,isMemberClass()
,isLocalClass()
,isAnonymousClass()
-
isLocalClass
@PublicAPI(usage=ACCESS) public boolean isLocalClass()
A local class is a nested class that is not a member of any class and that has a name.
Example:
Only The classpublic class TopLevel { class InnerClass {} static class NestedStaticClass {} void method() { class LocalClass {} new AnonymousClass() {} } }
LocalClass
is a local class, since it is a nested class that is not a member class, but it has the name "LocalClass".
All the other classesTopLevel
,InnerClass
,NestedStaticClass
and the class the compiler creates for the anonymous class derived from"new AnonymousClass() {}"
(which will have some generated name likeTopLevel$1
) are considered non-local, since they either are top level, directly declared within the body ofTopLevel
or are anonymous and thus have no name.
Compare e.g. Java Language Specification- Returns:
true
if this class is local class,false
otherwise- See Also:
isTopLevelClass()
,isNestedClass()
,isMemberClass()
,isInnerClass()
,isAnonymousClass()
-
isAnonymousClass
@PublicAPI(usage=ACCESS) public boolean isAnonymousClass()
An anonymous class is an inner class that is automatically derived from a class creation expression with a declared class body, e.g.new Example(){ <some-body> }
.
The compiler will automatically create a class backing this instance, typically with an autogenerated name likeSomeClass$1
, whereSomeClass
is the class holding the class creation expression.
Example:
Only the class the compiler creates for the anonymous class derived frompublic class TopLevel { class InnerClass {} static class NestedStaticClass {} void method() { class LocalClass {} new AnonymousClass() {} } }
"new AnonymousClass() {}"
(which will have some generated name likeTopLevel$1
) is considered an anonymous class.
All the other classesTopLevel
,InnerClass
,NestedStaticClass
andLocalClass
are considered non-anonymous.
Compare e.g. Java Language Specification- Returns:
true
if this class is an anonymous class,false
otherwise- See Also:
isTopLevelClass()
,isNestedClass()
,isMemberClass()
,isInnerClass()
,isLocalClass()
-
getModifiers
@PublicAPI(usage=ACCESS) public java.util.Set<JavaModifier> getModifiers()
- Specified by:
getModifiers
in interfaceHasModifiers
-
isAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
-
isAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isAnnotatedWith(java.lang.String annotationTypeName)
- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
-
isAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate)
- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
-
isMetaAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isMetaAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> type)
- Specified by:
isMetaAnnotatedWith
in interfaceCanBeAnnotated
-
isMetaAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isMetaAnnotatedWith(java.lang.String typeName)
- Specified by:
isMetaAnnotatedWith
in interfaceCanBeAnnotated
-
isMetaAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate)
- Specified by:
isMetaAnnotatedWith
in interfaceCanBeAnnotated
-
getAnnotationOfType
@PublicAPI(usage=ACCESS) public <A extends java.lang.annotation.Annotation> A getAnnotationOfType(java.lang.Class<A> type)
- Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaClass>
- Parameters:
type
- A given annotation type to matchJavaAnnotations
against- Returns:
- An
Annotation
of the given annotation type - Throws:
java.lang.IllegalArgumentException
- if the class is note annotated with the given type- See Also:
isAnnotatedWith(Class)
,tryGetAnnotationOfType(Class)
-
getAnnotationOfType
@PublicAPI(usage=ACCESS) public JavaAnnotation<JavaClass> getAnnotationOfType(java.lang.String typeName)
- Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaClass>
-
getAnnotations
@PublicAPI(usage=ACCESS) public java.util.Set<JavaAnnotation<JavaClass>> getAnnotations()
- Specified by:
getAnnotations
in interfaceHasAnnotations<JavaClass>
-
tryGetAnnotationOfType
@PublicAPI(usage=ACCESS) public <A extends java.lang.annotation.Annotation> Optional<A> tryGetAnnotationOfType(java.lang.Class<A> type)
- Specified by:
tryGetAnnotationOfType
in interfaceHasAnnotations<JavaClass>
- Parameters:
type
- A given annotation type to matchJavaAnnotations
against- Returns:
- An
Optional
containing anAnnotation
of the given annotation type, if this class is annotated with the given type, otherwise Optional.absent() - See Also:
isAnnotatedWith(Class)
,getAnnotationOfType(Class)
-
tryGetAnnotationOfType
@PublicAPI(usage=ACCESS) public Optional<JavaAnnotation<JavaClass>> tryGetAnnotationOfType(java.lang.String typeName)
Same astryGetAnnotationOfType(Class)
, but takes the type name.- Specified by:
tryGetAnnotationOfType
in interfaceHasAnnotations<JavaClass>
-
getSuperClass
@PublicAPI(usage=ACCESS) public Optional<JavaClass> getSuperClass()
-
getClassHierarchy
@PublicAPI(usage=ACCESS) public java.util.List<JavaClass> getClassHierarchy()
- Returns:
- The complete class hierarchy, i.e. the class itself and the result of
getAllSuperClasses()
-
getAllSuperClasses
@PublicAPI(usage=ACCESS) public java.util.List<JavaClass> getAllSuperClasses()
- Returns:
- All super classes sorted ascending by distance in the class hierarchy, i.e. first the direct super class, then the super class of the super class and so on. Includes Object.class in the result.
-
getSubClasses
@PublicAPI(usage=ACCESS) public java.util.Set<JavaClass> getSubClasses()
-
getInterfaces
@PublicAPI(usage=ACCESS) public java.util.Set<JavaClass> getInterfaces()
-
getAllInterfaces
@PublicAPI(usage=ACCESS) public java.util.Set<JavaClass> getAllInterfaces()
-
getAllClassesSelfIsAssignableTo
@PublicAPI(usage=ACCESS) public java.util.Set<JavaClass> getAllClassesSelfIsAssignableTo()
- Returns:
- All classes, this class is assignable to, in particular
- self
- superclasses this class extends
- interfaces this class implements
-
getEnclosingClass
@PublicAPI(usage=ACCESS) public Optional<JavaClass> getEnclosingClass()
-
getAllSubClasses
@PublicAPI(usage=ACCESS) public java.util.Set<JavaClass> getAllSubClasses()
-
getMembers
@PublicAPI(usage=ACCESS) public java.util.Set<JavaMember> getMembers()
-
getAllMembers
@PublicAPI(usage=ACCESS) public java.util.Set<JavaMember> getAllMembers()
-
getFields
@PublicAPI(usage=ACCESS) public java.util.Set<JavaField> getFields()
-
getAllFields
@PublicAPI(usage=ACCESS) public java.util.Set<JavaField> getAllFields()
-
getField
@PublicAPI(usage=ACCESS) public JavaField getField(java.lang.String name)
-
tryGetField
@PublicAPI(usage=ACCESS) public Optional<JavaField> tryGetField(java.lang.String name)
-
getCodeUnits
@PublicAPI(usage=ACCESS) public java.util.Set<JavaCodeUnit> getCodeUnits()
-
getCodeUnitWithParameterTypes
@PublicAPI(usage=ACCESS) public JavaCodeUnit getCodeUnitWithParameterTypes(java.lang.String name, java.lang.Class<?>... parameters)
- Parameters:
name
- The name of the code unit, can be a method name, but alsoCONSTRUCTOR_NAME
orSTATIC_INITIALIZER_NAME
parameters
- The parameter signature of the method specified asClass
Objects- Returns:
- A code unit (method, constructor or static initializer) with the given signature
-
getCodeUnitWithParameterTypeNames
@PublicAPI(usage=ACCESS) public JavaCodeUnit getCodeUnitWithParameterTypeNames(java.lang.String name, java.lang.String... parameters)
Same asgetCodeUnitWithParameterTypes(String, Class[])
, but with parameter signature specified as full class names
-
getCodeUnitWithParameterTypes
@PublicAPI(usage=ACCESS) public JavaCodeUnit getCodeUnitWithParameterTypes(java.lang.String name, java.util.List<java.lang.Class<?>> parameters)
-
getCodeUnitWithParameterTypeNames
@PublicAPI(usage=ACCESS) public JavaCodeUnit getCodeUnitWithParameterTypeNames(java.lang.String name, java.util.List<java.lang.String> parameters)
-
getMethod
@PublicAPI(usage=ACCESS) public JavaMethod getMethod(java.lang.String name)
-
getMethod
@PublicAPI(usage=ACCESS) public JavaMethod getMethod(java.lang.String name, java.lang.Class<?>... parameters)
-
getMethod
@PublicAPI(usage=ACCESS) public JavaMethod getMethod(java.lang.String name, java.lang.String... parameters)
-
tryGetMethod
@PublicAPI(usage=ACCESS) public Optional<JavaMethod> tryGetMethod(java.lang.String name)
-
tryGetMethod
@PublicAPI(usage=ACCESS) public Optional<JavaMethod> tryGetMethod(java.lang.String name, java.lang.Class<?>... parameters)
-
tryGetMethod
@PublicAPI(usage=ACCESS) public Optional<JavaMethod> tryGetMethod(java.lang.String name, java.lang.String... parameters)
-
getMethods
@PublicAPI(usage=ACCESS) public java.util.Set<JavaMethod> getMethods()
-
getAllMethods
@PublicAPI(usage=ACCESS) public java.util.Set<JavaMethod> getAllMethods()
-
getConstructor
@PublicAPI(usage=ACCESS) public JavaConstructor getConstructor()
-
getConstructor
@PublicAPI(usage=ACCESS) public JavaConstructor getConstructor(java.lang.Class<?>... parameters)
-
getConstructor
@PublicAPI(usage=ACCESS) public JavaConstructor getConstructor(java.lang.String... parameters)
-
getConstructors
@PublicAPI(usage=ACCESS) public java.util.Set<JavaConstructor> getConstructors()
-
getAllConstructors
@PublicAPI(usage=ACCESS) public java.util.Set<JavaConstructor> getAllConstructors()
-
getStaticInitializer
@PublicAPI(usage=ACCESS) public Optional<JavaStaticInitializer> getStaticInitializer()
-
getAccessesFromSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaAccess<?>> getAccessesFromSelf()
-
getAllAccessesFromSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaAccess<?>> getAllAccessesFromSelf()
- Returns:
- Set of all
JavaAccess
in the class hierarchy, as opposed to the accesses this class directly performs.
-
getFieldAccessesFromSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaFieldAccess> getFieldAccessesFromSelf()
-
getCallsFromSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaCall<?>> getCallsFromSelf()
Returns all calls of this class to methods or constructors.
-
getMethodCallsFromSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaMethodCall> getMethodCallsFromSelf()
-
getConstructorCallsFromSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaConstructorCall> getConstructorCallsFromSelf()
-
getDirectDependenciesFromSelf
@PublicAPI(usage=ACCESS) public java.util.Set<Dependency> getDirectDependenciesFromSelf()
Returns all dependencies originating directly from this class (i.e. not just from a superclass), where a dependency can be- field access
- method call
- constructor call
- extending a class
- implementing an interface
- referencing in throws declaration
- Returns:
- All dependencies originating directly from this class (i.e. where this class is the origin)
-
getDirectDependenciesToSelf
@PublicAPI(usage=ACCESS) public java.util.Set<Dependency> getDirectDependenciesToSelf()
LikegetDirectDependenciesFromSelf()
, but instead returns all dependencies where this class is target.- Returns:
- Dependencies where this class is the target.
-
getFieldAccessesToSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaFieldAccess> getFieldAccessesToSelf()
-
getMethodCallsToSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaMethodCall> getMethodCallsToSelf()
-
getConstructorCallsToSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaConstructorCall> getConstructorCallsToSelf()
-
getAccessesToSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaAccess<?>> getAccessesToSelf()
-
getFieldsWithTypeOfSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaField> getFieldsWithTypeOfSelf()
- Returns:
- Fields of all imported classes that have the type of this class.
-
getMethodsWithParameterTypeOfSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaMethod> getMethodsWithParameterTypeOfSelf()
- Returns:
- Methods of all imported classes that have a parameter type of this class.
-
getMethodsWithReturnTypeOfSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaMethod> getMethodsWithReturnTypeOfSelf()
- Returns:
- Methods of all imported classes that have a return type of this class.
-
getMethodThrowsDeclarationsWithTypeOfSelf
@PublicAPI(usage=ACCESS) public java.util.Set<ThrowsDeclaration<JavaMethod>> getMethodThrowsDeclarationsWithTypeOfSelf()
- Returns:
ThrowsDeclarations
of all imported classes that have the type of this class.
-
getConstructorsWithParameterTypeOfSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaConstructor> getConstructorsWithParameterTypeOfSelf()
- Returns:
- Constructors of all imported classes that have a parameter type of this class.
-
getConstructorsWithThrowsDeclarationTypeOfSelf
@PublicAPI(usage=ACCESS) public java.util.Set<ThrowsDeclaration<JavaConstructor>> getConstructorsWithThrowsDeclarationTypeOfSelf()
- Returns:
ThrowsDeclarations
of all imported classes that have the type of this class.
-
getAnnotationsWithTypeOfSelf
@PublicAPI(usage=ACCESS) public java.util.Set<JavaAnnotation<?>> getAnnotationsWithTypeOfSelf()
- Returns:
- All imported
JavaAnnotations
that have the annotation type of this class.
-
isEquivalentTo
@PublicAPI(usage=ACCESS) public boolean isEquivalentTo(java.lang.Class<?> clazz)
- Parameters:
clazz
- An arbitrary type- Returns:
- true, if this
JavaClass
represents the same class as the suppliedClass
, otherwise false
-
isAssignableFrom
@PublicAPI(usage=ACCESS) public boolean isAssignableFrom(java.lang.Class<?> type)
-
isAssignableFrom
@PublicAPI(usage=ACCESS) public boolean isAssignableFrom(java.lang.String typeName)
-
isAssignableFrom
@PublicAPI(usage=ACCESS) public boolean isAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
-
isAssignableTo
@PublicAPI(usage=ACCESS) public boolean isAssignableTo(java.lang.Class<?> type)
-
isAssignableTo
@PublicAPI(usage=ACCESS) public boolean isAssignableTo(java.lang.String typeName)
-
isAssignableTo
@PublicAPI(usage=ACCESS) public boolean isAssignableTo(DescribedPredicate<? super JavaClass> predicate)
-
reflect
@PublicAPI(usage=ACCESS) public java.lang.Class<?> reflect()
Resolves the respectiveClass
from the classpath.
NOTE: This method will throw an exception, if the respectiveClass
or any of its dependencies can't be found on the classpath.- Returns:
- The
Class
equivalent to thisJavaClass
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
namesOf
@PublicAPI(usage=ACCESS) public static java.util.List<java.lang.String> namesOf(java.lang.Class<?>... paramTypes)
-
namesOf
@PublicAPI(usage=ACCESS) public static java.util.List<java.lang.String> namesOf(java.util.List<java.lang.Class<?>> paramTypes)
-
isAnonymous
@Deprecated @PublicAPI(usage=ACCESS) public boolean isAnonymous()
Deprecated.useisAnonymousClass()
instead
-
-