Package 

Interface ClassMirror

  • All Implemented Interfaces:
    dev.thecodewarrior.mirror.type.ConcreteTypeMirror , dev.thecodewarrior.mirror.type.TypeMirror , dev.thecodewarrior.mirror.util.DeclarationMirror

    
    public interface ClassMirror
     implements ConcreteTypeMirror, DeclarationMirror
                        

    The type of mirror used to represent classes, as opposed to arrays, type variables, wildcards, and void.

    • Method Detail

      • withTypeArguments

         abstract ClassMirror withTypeArguments(TypeMirror parameters)

        Returns a copy of this mirror, replacing its type parameters the given types. This will ripple the changes to supertypes/interfaces, method and field signatures, etc. Passing zero arguments will return a copy of this mirror with the raw type arguments.

        Note: A new ClassMirror is only created if none already exist with the required specialization

      • withEnclosingClass

         abstract ClassMirror withEnclosingClass(ClassMirror enclosing)

        Returns a copy of this class with its enclosing class replaced with the annotation-stripped version of enclosing. If the passed class is null this method removes any enclosing class specialization.

        Note: A new ClassMirror is only created if none already exist with the required specialization

      • withEnclosingExecutable

         abstract ClassMirror withEnclosingExecutable(ExecutableMirror enclosing)

        Returns a copy of this class with its enclosing method/constructor replaced with enclosing. If the passed executable is null this method removes any enclosing executable specialization.

        Note: A new ClassMirror is only created if none already exist with the required specialization

      • withTypeAnnotations

         abstract ClassMirror withTypeAnnotations(List<Annotation> annotations)

        Creates a copy of this type mirror that has been specialized to have the passed Type Annotations. Type annotations on this mirror will not carry over to the resulting mirror.

        Note that are not the annotations present on the class declaration, they are the annotations present on the use of the type.

      • findSuperclass

         abstract ClassMirror findSuperclass(Class<?> clazz)

        Recursively searches through this class's supertypes to find the specificity superclass with the specified type. If this class is the specified type this method returns this class. This method returns null if no such superclass was found. Use getSuperclass if you want an exception thrown on failure instead.

      • getSuperclass

         abstract ClassMirror getSuperclass(Class<?> clazz)

        Recursively searches through this class's supertypes to find the specificity superclass with the specified type. If this class is the specified type this method returns this class. This method throws an exception if no such superclass was found. Use findSuperclass if you want a null on failure instead.

      • getMethod

         abstract MethodMirror getMethod(String name, TypeMirror params)

        Returns the public or private method declared in this class or its superclasses that has the specified signature, excluding overridden methods, or throws if no such method exists.

      • findMethods

         abstract List<MethodMirror> findMethods(String name)

        Returns the public and private methods declared in this class or its superclasses that have the specified name, excluding overridden methods. Since private methods can't be overridden, there may still be multiple methods with the same signature in the returned list.

        Note: The returned list is immutable.

      • findMethod

         abstract MethodMirror findMethod(String name, TypeMirror params)

        Returns the public or private method declared in this class or its superclasses that has the specified signature, excluding overridden methods, or null if no such method exists.

      • findMethodRaw

         abstract MethodMirror findMethodRaw(String name, Class<?> params)

        Returns the public or private method declared in this class or its superclasses that has the specified raw signature, excluding overridden methods, or null if no such method exists.

      • getMethodRaw

         abstract MethodMirror getMethodRaw(String name, Class<?> params)

        Returns the public or private method declared in this class or its superclasses that has the specified raw signature, excluding overridden methods, or throws if no such method exists.

      • getField

         abstract FieldMirror getField(String name)

        Returns the field declared in this class or inherited from its superclasses that has the specified name, or throws if no such field exists.

      • findDeclaredField

         abstract FieldMirror findDeclaredField(String name)

        Returns the field declared directly in this class that has the specified name, or null if no such field exists.

      • findPublicField

         abstract FieldMirror findPublicField(String name)

        Returns the public field declared in this class or inherited from its superclasses that has the specified name, or null if no such field exists.

      • findField

         abstract FieldMirror findField(String name)

        Returns the field declared in this class or inherited from its superclasses that has the specified name, or null if no such field exists.

      • getDeclaredField

         abstract FieldMirror getDeclaredField(String name)

        Returns the field declared directly in this class that has the specified signature, or throws if no such field exists.

      • getPublicField

         abstract FieldMirror getPublicField(String name)

        Returns the public field declared in this class or inherited from its superclasses that has the specified name, or throws if no such field exists.

      • getMemberClass

         abstract ClassMirror getMemberClass(String name)

        Returns the member class declared in this class or inherited from its superclasses that has the specified name, or throws if no such class exists.

      • findDeclaredMemberClass

         abstract ClassMirror findDeclaredMemberClass(String name)

        Returns the member class declared directly in this class that has the specified name, or null if no such class exists.

      • findPublicMemberClass

         abstract ClassMirror findPublicMemberClass(String name)

        Returns the public member class declared in this class or inherited from its superclasses that has the specified name, or null if no such class exists.

      • findMemberClass

         abstract ClassMirror findMemberClass(String name)

        Returns the member class declared in this class or inherited from its superclasses that has the specified name, or null if no such class exists.

      • getDeclaredMemberClass

         abstract ClassMirror getDeclaredMemberClass(String name)

        Returns the member class declared directly in this class that has the specified signature, or throws if no such class exists.

      • getPublicMemberClass

         abstract ClassMirror getPublicMemberClass(String name)

        Returns the public member class declared in this class or inherited from its superclasses that has the specified name, or throws if no such class exists.

      • getCoreType

         abstract Type getCoreType()

        The Java Core Reflection type this mirror represents

      • getCoreAnnotatedType

         abstract AnnotatedType getCoreAnnotatedType()

        The Java Core Reflection annotated type this mirror represents.

        !!NOTE!! The JVM implementations of AnnotatedType don't implement equals or hashCode, so they will equal neither each other nor this. If you need these methods pass any annotated type through Mirror.toCanonical.

      • getRaw

         abstract ClassMirror getRaw()

        The mirror representing this type without any generic specialization

      • getSuperclass

         abstract ClassMirror getSuperclass()

        The supertype of this class. This property is null if this reflect represents Object, an interface, a primitive, or void. The returned type will be specialized based on this type's specialization and any explicit parameters set in the source code.

      • getInterfaces

         abstract List<ClassMirror> getInterfaces()

        The list of interfaces directly implemented by this type, in the order they appear in the source code. The returned type will be specialized based on this type's specialization and any explicit parameters set in the source code.

        Note: this list is immutable

      • getTypeParameters

         abstract List<TypeMirror> getTypeParameters()

        The list of type parameters defined by this mirror. These will be replaced when specializing, so you should use raw to get the actual type parameters of the class as opposed to their specializations.

        Note: this list is immutable

      • getKClass

         abstract KClass<?> getKClass()

        The Kotlin KClass instance associated with this class

      • getModifiers

         abstract Set<Modifier> getModifiers()

        The modifiers present on this class. (e.g. public, abstract, final, etc.) This set is in customary order, as defined in JLS §8.1.1

        Note: this list is immutable

      • getIsInternalAccess

         abstract Boolean getIsInternalAccess()

        Returns true if this object represents a Kotlin class and that class has an internal visibility modifier

      • getIsKotlinClass

         abstract Boolean getIsKotlinClass()

        Returns true if this object represents a class directly written in Kotlin

      • getFlags

         abstract Set<ClassMirror.Flag> getFlags()

        A set of flags used to store properties such as whether the class is static, abstract, an enum, etc.

        Note: this list is immutable

      • getIsStatic

         abstract Boolean getIsStatic()

        Returns true if this mirror represents a static class.

      • getIsFinal

         abstract Boolean getIsFinal()

        Returns true if this mirror represents a final class.

      • getIsStrict

         abstract Boolean getIsStrict()

        Returns true if the class this mirror represents has the strictfp modifier.

        NOTE: For unknown reasons the strictfp modifier seems to not be present in the Core Reflection modifiers, so this is always false

      • getIsOpen

         abstract Boolean getIsOpen()

        Returns true if the class this mirror represents is not final.

      • getIsCompanion

         abstract Boolean getIsCompanion()

        Returns true if this object represents a Kotlin class and that class is a companion class

      • getIsData

         abstract Boolean getIsData()

        Returns true if this object represents a Kotlin class and that class is a data class

      • getIsSealed

         abstract Boolean getIsSealed()

        Returns true if this object represents a Kotlin class and that class is a sealed class

      • getIsAnnotation

         abstract Boolean getIsAnnotation()

        Returns true if this mirror represents an annotation class.

      • getIsAnonymous

         abstract Boolean getIsAnonymous()

        Returns true if this mirror represents an anonymous class.

      • getIsEnum

         abstract Boolean getIsEnum()

        Returns true if this mirror represents an enum class. This is false for anonymous enum subclasses, so for more consistent behavior check if enumType is non-null.

      • getIsInterface

         abstract Boolean getIsInterface()

        Returns true if the class this mirror represents is an interface.

      • getIsLocal

         abstract Boolean getIsLocal()

        Returns true if this mirror represents a local class. Local classes are classes declared within a block of code such as a method or constructor.

      • getIsMember

         abstract Boolean getIsMember()

        Returns true if the class this mirror represents is a member of another class. Member classes are non-static classes defined inside another class.

        public class Foo {
            public class Member {}
        }
      • getIsPrimitive

         abstract Boolean getIsPrimitive()

        Returns true if this mirror represents a primitive class.

      • getIsSynthetic

         abstract Boolean getIsSynthetic()

        Returns true if this mirror represents a synthetic class.

      • getAnnotations

         abstract AnnotationList getAnnotations()

        Returns annotations that are present on the class this mirror represents. These are not the annotations present on the use of the type, for those use typeAnnotations

      • getDeclaredAnnotations

         abstract AnnotationList getDeclaredAnnotations()

        Returns annotations that are directly present on the class this mirror represents. These are not the annotations present on the use of the type, for those use typeAnnotations

      • getEnumType

         abstract ClassMirror getEnumType()

        Returns the logical enum type of the class this mirror represents, taking into account anonymous enum subclasses, or null if this mirror does not represent an enum type or enum subclass.

        Anonymous enum subclasses (any enum element that overrides or implements a method from the enum itself) aren't enum classes themselves. This method will return the true enum class for both the actual enum and the subclasses.

      • getEnumConstants

         abstract List<Enum<?>> getEnumConstants()

        Returns the list of constants in the enum class this mirror represents, or null if this mirror does not represent an enum class. If this mirror represents an anonymous subclass of an enum, this will return null.

        Note: this list is immutable

      • getSimpleName

         abstract String getSimpleName()

        Returns the simple name of the class this mirror represents. e.g. "String"

      • getName

         abstract String getName()

        Returns an informative string describing this type. e.g. "java.lang.String" or "com.example.Foo$1"

      • getCanonicalName

         abstract String getCanonicalName()

        Returns the simple fully qualified name of the class this mirror represents. e.g. "java.lang.String". Returns null if the underlying class does not have a canonical name (i.e., if it is a local or anonymous class)

      • getJvmName

         abstract String getJvmName()

        Returns the internal name of the class this mirror represents. (e.g. boolean = "Z", com.example.Foo = "Lcom/example/Foo;")

      • getDeclaredMethods

         abstract MethodList getDeclaredMethods()

        The methods declared directly in this class. The returned list is in an arbitrary stable order.

        Note: this list is immutable

      • getInheritedMethods

         abstract MethodList getInheritedMethods()

        The methods inherited from the supertypes of this class. The returned list is in an arbitrary stable order.

        Note: this list is immutable

      • getPublicMethods

         abstract MethodList getPublicMethods()

        The public methods declared in this class and inherited from its superclasses. The returned list is in an arbitrary stable order.

        Note: this list is immutable

      • getVisibleMethods

         abstract MethodList getVisibleMethods()

        The methods that would be visible inside of this class. This includes public and private methods from this class, as well as any methods inherited from the supertypes of this class. This list will include hidden public static methods, since they can't be overridden, only hidden. The returned list is in an arbitrary stable order.

        Note: This list is immutable.

      • getMethods

         abstract MethodList getMethods()

        All the methods declared in this class and its supertypes, excluding overridden methods. This includes public and private methods from this class and its superclasses/interfaces, as well as any methods from the supertypes of this class. This list will include hidden private and static methods, since they can't be overridden, only hidden. The returned list is in an arbitrary stable order.

        Note: This list is immutable.

      • getDeclaredFields

         abstract List<FieldMirror> getDeclaredFields()

        The fields declared directly in this class. The returned list is in an arbitrary stable order.

        Note: this list is immutable

      • getPublicFields

         abstract List<FieldMirror> getPublicFields()

        The public methods declared in this class and inherited from its superclasses. The returned list is in an arbitrary stable order.

        Note: this list is immutable

      • getFields

         abstract List<FieldMirror> getFields()

        The fields declared in this class and its superclasses. Since fields can be shadowed but not overridden, there may be multiple fields with the same name in this list. The returned list is in an arbitrary stable order.

        Note: This list is immutable.

      • getDeclaredMemberClasses

         abstract List<ClassMirror> getDeclaredMemberClasses()

        The member classes declared directly in this class. The returned list is in an arbitrary stable order.

        Note: this list is immutable

      • getPublicMemberClasses

         abstract List<ClassMirror> getPublicMemberClasses()

        The public member classes declared in this class and inherited from its superclasses. The returned list is in an arbitrary stable order.

        Note: this list is immutable

      • getMemberClasses

         abstract List<ClassMirror> getMemberClasses()

        The member classes declared in this class and inherited from its superclasses. Since member classes can be shadowed but not overridden, there may be multiple classes with the same name in this list. The returned list is in an arbitrary stable order.

        Note: This list is immutable.

      • getJava

         abstract Class<?> getJava()

        The raw Core Reflection class this mirror represents