-
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumClassMirror.FlagA set of useful flags for classes, such as whether it is abstract, anonymous, primitive, etc.
-
Method Summary
Modifier and Type Method Description abstract ClassMirrorwithTypeArguments(TypeMirror parameters)Returns a copy of this mirror, replacing its type parameters the given types. abstract ClassMirrorwithEnclosingClass(ClassMirror enclosing)Returns a copy of this class with its enclosing class replaced with the annotation-stripped version of enclosing. abstract ClassMirrorwithEnclosingExecutable(ExecutableMirror enclosing)Returns a copy of this class with its enclosing method/constructor replaced with enclosing. abstract ClassMirrorwithTypeAnnotations(List<Annotation> annotations)Creates a copy of this type mirror that has been specialized to have the passed Type Annotations. abstract ClassMirrorfindSuperclass(Class<?> clazz)Recursively searches through this class's supertypes to find the specificity superclass with the specified type. abstract ClassMirrorgetSuperclass(Class<?> clazz)Recursively searches through this class's supertypes to find the specificity superclass with the specified type. abstract MethodMirrorgetMethod(Method other)Returns the specialized mirror that represents other. abstract MethodMirrorgetMethod(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. 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. abstract MethodMirrorfindMethod(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. abstract MethodMirrorfindMethodRaw(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. abstract MethodMirrorgetMethodRaw(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. abstract FieldMirrorgetField(Field other)Returns the specialized mirror that represents other. abstract FieldMirrorgetField(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. abstract FieldMirrorfindDeclaredField(String name)Returns the field declared directly in this class that has the specified name, or null if no such field exists. abstract FieldMirrorfindPublicField(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. abstract FieldMirrorfindField(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. abstract FieldMirrorgetDeclaredField(String name)Returns the field declared directly in this class that has the specified signature, or throws if no such field exists. abstract FieldMirrorgetPublicField(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. abstract ConstructorMirrorgetConstructor(ConstructorMirror other)Returns the specialized mirror that represents the same constructor as other. abstract ConstructorMirrorgetConstructor(Constructor<?> other)Gets the specialized mirror that represents other. abstract ConstructorMirrorfindDeclaredConstructor(TypeMirror params)Returns the constructor declared in this class that has the specified parameter types, or null if no such constructor exists. abstract ConstructorMirrorgetDeclaredConstructor(TypeMirror params)Returns the constructor declared in this class that has the specified parameter types, or throws if no such constructor exists. abstract ClassMirrorgetMemberClass(ClassMirror other)Returns the specialized mirror that represents the same class as other. abstract ClassMirrorgetMemberClass(Class<?> other)Returns the specialized mirror that represents other. abstract ClassMirrorgetMemberClass(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. abstract ClassMirrorfindDeclaredMemberClass(String name)Returns the member class declared directly in this class that has the specified name, or null if no such class exists. abstract ClassMirrorfindPublicMemberClass(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. abstract ClassMirrorfindMemberClass(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. abstract ClassMirrorgetDeclaredMemberClass(String name)Returns the member class declared directly in this class that has the specified signature, or throws if no such class exists. abstract ClassMirrorgetPublicMemberClass(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. abstract TypegetCoreType()The Java Core Reflection type this mirror represents abstract AnnotatedTypegetCoreAnnotatedType()The Java Core Reflection annotated type this mirror represents. abstract ClassMirrorgetRaw()The mirror representing this type without any generic specialization abstract ClassMirrorgetSuperclass()The supertype of this class. abstract List<ClassMirror>getInterfaces()The list of interfaces directly implemented by this type, in the order they appear in the source code. abstract List<TypeMirror>getTypeParameters()The list of type parameters defined by this mirror. abstract ClassMirrorgetEnclosingClass()The class this class is defined inside, if any. abstract ExecutableMirrorgetEnclosingExecutable()The executable this class is defined inside, if any. abstract KClass<?>getKClass()The Kotlin KClassinstance associated with this classabstract Set<Modifier>getModifiers()The modifiers present on this class. abstract Modifier.AccessgetAccess()The access modifier present on this class abstract BooleangetIsInternalAccess()Returns true if this object represents a Kotlin class and that class has an internalvisibility modifierabstract BooleangetIsKotlinClass()Returns true if this object represents a class directly written in Kotlin abstract Set<ClassMirror.Flag>getFlags()A set of flags used to store properties such as whether the class is static, abstract, an enum, etc. abstract BooleangetIsAbstract()Returns true if this mirror represents an class. abstract BooleangetIsStatic()Returns true if this mirror represents a static class. abstract BooleangetIsFinal()Returns true if this mirror represents a final class. abstract BooleangetIsStrict()Returns true if the class this mirror represents has the strictfpmodifier.abstract BooleangetIsOpen()Returns true if the class this mirror represents is not final. abstract BooleangetIsCompanion()Returns true if this object represents a Kotlin class and that class is a companion class abstract BooleangetIsData()Returns true if this object represents a Kotlin class and that class is a data class abstract BooleangetIsSealed()Returns true if this object represents a Kotlin class and that class is a sealed class abstract BooleangetIsAnnotation()Returns true if this mirror represents an annotation class. abstract BooleangetIsAnonymous()Returns true if this mirror represents an anonymous class. abstract BooleangetIsEnum()Returns true if this mirror represents an enum class. abstract BooleangetIsInterface()Returns true if the class this mirror represents is an interface. abstract BooleangetIsLocal()Returns true if this mirror represents a local class. abstract BooleangetIsMember()Returns true if the class this mirror represents is a member of another class. abstract BooleangetIsPrimitive()Returns true if this mirror represents a primitive class. abstract BooleangetIsSynthetic()Returns true if this mirror represents a synthetic class. abstract AnnotationListgetAnnotations()Returns annotations that are present on the class this mirror represents. abstract AnnotationListgetDeclaredAnnotations()Returns annotations that are directly present on the class this mirror represents. abstract ClassMirrorgetEnumType()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. 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. abstract StringgetSimpleName()Returns the simple name of the class this mirror represents. abstract StringgetName()Returns an informative string describing this type. abstract StringgetCanonicalName()Returns the simple fully qualified name of the class this mirror represents. abstract StringgetJvmName()Returns the internal name of the class this mirror represents. abstract MethodListgetDeclaredMethods()The methods declared directly in this class. abstract MethodListgetInheritedMethods()The methods inherited from the supertypes of this class. abstract MethodListgetPublicMethods()The public methods declared in this class and inherited from its superclasses. abstract MethodListgetVisibleMethods()The methods that would be visible inside of this class. abstract MethodListgetMethods()All the methods declared in this class and its supertypes, excluding overridden methods. abstract List<FieldMirror>getDeclaredFields()The fields declared directly in this class. abstract List<FieldMirror>getPublicFields()The public methods declared in this class and inherited from its superclasses. abstract List<FieldMirror>getFields()The fields declared in this class and its superclasses. abstract List<ConstructorMirror>getDeclaredConstructors()The constructors declared in this class. abstract List<ConstructorMirror>getPublicConstructors()The public constructors declared in this class. abstract List<ClassMirror>getDeclaredMemberClasses()The member classes declared directly in this class. abstract List<ClassMirror>getPublicMemberClasses()The public member classes declared in this class and inherited from its superclasses. abstract List<ClassMirror>getMemberClasses()The member classes declared in this class and inherited from its superclasses. abstract Class<?>getJava()The raw Core Reflection class this mirror represents abstract Class<?>getErasure()The JVM erasure of this type. abstract AnnotationListgetTypeAnnotations()The type annotations present on this type. -
Methods inherited from class dev.thecodewarrior.mirror.type.ConcreteTypeMirror
asArrayMirror, asClassMirror, isAssignableFrom, toJavaString, toKotlinString, toString -
Methods inherited from class dev.thecodewarrior.mirror.type.ClassMirror
toDeclarationString, toJavaDeclarationString, toKotlinDeclarationString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
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
ClassMirroris 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
ClassMirroris 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
ClassMirroris 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(Method other)
Returns the specialized mirror that represents other.
-
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(Field other)
Returns the specialized mirror that represents other.
-
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.
-
getConstructor
abstract ConstructorMirror getConstructor(ConstructorMirror other)
Returns the specialized mirror that represents the same constructor as other.
-
getConstructor
abstract ConstructorMirror getConstructor(Constructor<?> other)
Gets the specialized mirror that represents other.
-
findDeclaredConstructor
abstract ConstructorMirror findDeclaredConstructor(TypeMirror params)
Returns the constructor declared in this class that has the specified parameter types, or null if no such constructor exists.
-
getDeclaredConstructor
abstract ConstructorMirror getDeclaredConstructor(TypeMirror params)
Returns the constructor declared in this class that has the specified parameter types, or throws if no such constructor exists.
-
getMemberClass
abstract ClassMirror getMemberClass(ClassMirror other)
Returns the specialized mirror that represents the same class as other.
-
getMemberClass
abstract ClassMirror getMemberClass(Class<?> other)
Returns the specialized mirror that represents other.
-
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
AnnotatedTypedon't implementequalsorhashCode, 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
nullif this reflect represents Object, an interface, a primitive, orvoid. 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
-
getEnclosingClass
abstract ClassMirror getEnclosingClass()
The class this class is defined inside, if any.
-
getEnclosingExecutable
abstract ExecutableMirror getEnclosingExecutable()
The executable this class is defined inside, if any. May occur in addition to enclosingClass.
-
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.1Note: this list is immutable
-
getAccess
abstract Modifier.Access getAccess()
The access modifier present on this class
-
getIsInternalAccess
abstract Boolean getIsInternalAccess()
Returns true if this object represents a Kotlin class and that class has an
internalvisibility 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
-
getIsAbstract
abstract Boolean getIsAbstract()
Returns true if this mirror represents an class.
-
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
strictfpmodifier.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.
-
getDeclaredConstructors
abstract List<ConstructorMirror> getDeclaredConstructors()
The constructors declared in this class.
Note: this list is immutable
-
getPublicConstructors
abstract List<ConstructorMirror> getPublicConstructors()
The public constructors declared in this class.
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.
-
getErasure
abstract Class<?> getErasure()
The JVM erasure of this type.
-
getTypeAnnotations
abstract AnnotationList getTypeAnnotations()
The type annotations present on this type. These are not the annotations present on the declaration, they are the annotations present on the use of the type.
-
-
-
-