Class JavaClass

    • Method Detail

      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface HasName
      • getSimpleName

        public java.lang.String getSimpleName()
      • getPackage

        public java.lang.String getPackage()
      • isInterface

        public boolean isInterface()
      • isEnum

        public boolean isEnum()
      • isAnnotatedWith

        public boolean isAnnotatedWith​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
        Specified by:
        isAnnotatedWith in interface CanBeAnnotated
      • isAnnotatedWith

        public boolean isAnnotatedWith​(java.lang.String annotationTypeName)
        Specified by:
        isAnnotatedWith in interface CanBeAnnotated
      • isMetaAnnotatedWith

        public boolean isMetaAnnotatedWith​(java.lang.Class<? extends java.lang.annotation.Annotation> type)
        Specified by:
        isMetaAnnotatedWith in interface CanBeAnnotated
      • getClassHierarchy

        public java.util.List<JavaClass> getClassHierarchy()
        Returns:
        The complete class hierarchy, i.e. the class itself and the result of getAllSuperClasses()
      • getAllSuperClasses

        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

        public java.util.Set<JavaClass> getSubClasses()
      • getInterfaces

        public java.util.Set<JavaClass> getInterfaces()
      • getAllInterfaces

        public java.util.Set<JavaClass> getAllInterfaces()
      • getAllClassesSelfIsAssignableTo

        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
      • getAllSubClasses

        public java.util.Set<JavaClass> getAllSubClasses()
      • getMembers

        public java.util.Set<JavaMember> getMembers()
      • getAllMembers

        public java.util.Set<JavaMember> getAllMembers()
      • getFields

        public java.util.Set<JavaField> getFields()
      • getAllFields

        public java.util.Set<JavaField> getAllFields()
      • getField

        public JavaField getField​(java.lang.String name)
      • getCodeUnits

        public java.util.Set<JavaCodeUnit> getCodeUnits()
      • getCodeUnitWithParameterTypes

        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 also CONSTRUCTOR_NAME or STATIC_INITIALIZER_NAME
        parameters - The parameter signature of the method specified as Class Objects
        Returns:
        A code unit (method, constructor or static initializer) with the given signature
      • getMethod

        public JavaMethod getMethod​(java.lang.String name,
                                    java.lang.Class<?>... parameters)
      • tryGetMethod

        public Optional<JavaMethod> tryGetMethod​(java.lang.String name,
                                                 java.lang.Class<?>... parameters)
      • getMethods

        public java.util.Set<JavaMethod> getMethods()
      • getAllMethods

        public java.util.Set<JavaMethod> getAllMethods()
      • getConstructor

        public JavaConstructor getConstructor​(java.lang.Class<?>... parameters)
      • getConstructors

        public java.util.Set<JavaConstructor> getConstructors()
      • getAllConstructors

        public java.util.Set<JavaConstructor> getAllConstructors()
      • getAccessesFromSelf

        public java.util.Set<JavaAccess<?>> getAccessesFromSelf()
      • getAllAccessesFromSelf

        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

        public java.util.Set<JavaFieldAccess> getFieldAccessesFromSelf()
      • getMethodCallsFromSelf

        public java.util.Set<JavaMethodCall> getMethodCallsFromSelf()
      • getConstructorCallsFromSelf

        public java.util.Set<JavaConstructorCall> getConstructorCallsFromSelf()
      • getDirectDependenciesFromSelf

        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
        Returns:
        All dependencies originating directly from this class (i.e. where this class is the origin)
      • getDirectDependenciesToSelf

        public java.util.Set<Dependency> getDirectDependenciesToSelf()
        Like getDirectDependenciesFromSelf(), but instead returns all dependencies where this class is target.
        Returns:
        Dependencies where this class is the target.
      • getFieldAccessesToSelf

        public java.util.Set<JavaFieldAccess> getFieldAccessesToSelf()
      • getMethodCallsToSelf

        public java.util.Set<JavaMethodCall> getMethodCallsToSelf()
      • getConstructorCallsToSelf

        public java.util.Set<JavaConstructorCall> getConstructorCallsToSelf()
      • getAccessesToSelf

        public java.util.Set<JavaAccess<?>> getAccessesToSelf()
      • isEquivalentTo

        public boolean isEquivalentTo​(java.lang.Class<?> clazz)
        Parameters:
        clazz - An arbitrary type
        Returns:
        true, if this JavaClass represents the same class as the supplied Class, otherwise false
      • isAssignableFrom

        public boolean isAssignableFrom​(java.lang.Class<?> type)
      • isAssignableFrom

        public boolean isAssignableFrom​(java.lang.String typeName)
      • isAssignableTo

        public boolean isAssignableTo​(java.lang.Class<?> type)
      • isAssignableTo

        public boolean isAssignableTo​(java.lang.String typeName)
      • reflect

        public java.lang.Class<?> reflect()
        Resolves the respective Class from the classpath.
        NOTE: This method will throw an exception, if the respective Class or any of its dependencies can't be found on the classpath.
        Returns:
        The Class equivalent to this JavaClass
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • namesOf

        public static java.util.List<java.lang.String> namesOf​(java.lang.Class<?>... paramTypes)
      • namesOf

        public static java.util.List<java.lang.String> namesOf​(java.util.List<java.lang.Class<?>> paramTypes)
      • isAnonymous

        public boolean isAnonymous()