Class ClassInfo
Provides various convenience methods for introspecting fields/methods/annotations that aren't provided by the standard Java reflection APIs.
Objects are designed to be lightweight to create and threadsafe.
Example:
   
See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionPerforms an action on this object if the specified predicate test passes.Same asgetFullName()but appends to an existing string builder.Same asgetShortName()but appends to an existing string builder.booleancanAcceptArg(Object child) Returnstrue if this type can be used as a parameter for the specified object.boolean<A extends Annotation>
 AfirstAnnotation(Class<A> type, Predicate<A> filter) Returns the first matching annotation on this class and superclasses/interfaces.<A extends Annotation>
 AfirstAnnotation(AnnotationProvider annotationProvider, Class<A> type, Predicate<A> filter) Returns the first matching annotation on this class and superclasses/interfaces.forEachAllField(Predicate<FieldInfo> filter, Consumer<FieldInfo> action) Performs an action on all matching fields on this class and all parent classes.forEachAllMethodParentFirst(Predicate<MethodInfo> filter, Consumer<MethodInfo> action) Performs an action on all matching declared methods on this class and all parent classes.<A extends Annotation>
 ClassInfoforEachAnnotation(Class<A> type, Predicate<A> filter, Consumer<A> action) Performs an action on all matching annotations on this class and superclasses/interfaces.<A extends Annotation>
 ClassInfoforEachAnnotation(AnnotationProvider annotationProvider, Class<A> type, Predicate<A> filter, Consumer<A> action) Performs an action on all matching annotations on this class and superclasses/interfaces.forEachAnnotationInfo(Predicate<AnnotationInfo<?>> filter, Consumer<AnnotationInfo<?>> action) Performs an action on all matching annotations on this class/parents/package.forEachDeclaredConstructor(Predicate<ConstructorInfo> filter, Consumer<ConstructorInfo> action) Performs an action on all matching declared constructors on this class.forEachDeclaredField(Predicate<FieldInfo> filter, Consumer<FieldInfo> action) Performs an action on all matching declared fields on this class.forEachDeclaredMethod(Predicate<MethodInfo> filter, Consumer<MethodInfo> action) Performs an action on all matching declared methods on this class.forEachMethod(Predicate<MethodInfo> filter, Consumer<MethodInfo> action) Performs an action on all matching methods on this class.forEachPublicConstructor(Predicate<ConstructorInfo> filter, Consumer<ConstructorInfo> action) Performs an action on all matching public constructors on this class.forEachPublicField(Predicate<FieldInfo> filter, Consumer<FieldInfo> action) Performs an action on all matching public fields on this class.forEachPublicMethod(Predicate<MethodInfo> filter, Consumer<MethodInfo> action) Performs an action on all matching public methods on this class.Returns all fields on this class and all parent classes.Returns all declared methods on this class and all parent classes.Returns a list including this class and all parent classes and interfaces.<A extends Annotation>
 AgetAnnotation(Class<A> type) Finds the annotation of the specified type defined on this class or parent class/interface.<A extends Annotation>
 AgetAnnotation(Class<A> type, Predicate<A> filter) Returns the first matching annotation of the specified type defined on the specified class or parent classes/interfaces in parent-to-child order.<A extends Annotation>
 AgetAnnotation(AnnotationProvider annotationProvider, Class<A> type) Finds the annotation of the specified type defined on this class or parent class/interface.Constructs anAnnotationListof all annotations found on this class.getAnnotationList(Predicate<AnnotationInfo<?>> filter) Constructs anAnnotationListof all matching annotations on this class.<A extends Annotation>
 List<A>getAnnotations(Class<A> type) Returns all annotations of the specified type defined on the specified class or parent classes/interfaces in parent-to-child order.<A extends Annotation>
 List<A>getAnnotations(AnnotationProvider annotationProvider, Class<A> type) Returns all annotations of the specified type defined on this or parent classes/interfaces.getAnyParent(Predicate<ClassInfo> filter) Returns the first matching parent class or interface.Returns the base component type of this class if it's an array.Returns the first matching declared constructor on this class.Returns all the constructors defined on this class.getDeclaredField(Predicate<FieldInfo> filter) Returns the first matching declared field on this class.Returns all declared fields on this class.Returns a list of interfaces declared on this class.getDeclaredMethod(Predicate<MethodInfo> filter) Returns the first matching declared method on this class.Returns all methods declared on this class.intReturns the number of dimensions if this is an array type.Returns the full name of this class.Returns a list of interfaces defined on this class and superclasses.getMethod(Predicate<MethodInfo> filter) Returns the first matching method on this class.Returns all declared methods on this class and all parent classes.getName()Returns the name of the underlying class.String[]getNames()Returns all possible names for this class.Locates the no-arg constructor for this class.Returns the package of this class.<A extends Annotation>
 AgetPackageAnnotation(Class<A> type) Returns the specified annotation only if it's been declared on the package of this class.Class<?>getParameterType(int index, Class<?> pt) Finds the real parameter type of this class.Returns a list including this class and all parent classes.Returns the default value for this primitive class.Class<?>If this class is a primitive wrapper (e.g.Class<?>If this class is a primitive (e.g.getPublicConstructor(Predicate<ConstructorInfo> filter) Returns the first matching public constructor on this class.Returns all the public constructors defined on this class.getPublicField(Predicate<FieldInfo> filter) Returns the first matching public field on this class.Returns all public fields on this class.getPublicMethod(Predicate<MethodInfo> filter) Returns the first matching public method on this class.Returns all public methods on this class.Returns the repeated annotation method on this class.Returns the short name of the underlying class.Returns the simple name of the underlying class.Returns the parent class.Class<?>If this class is a primitive (e.g.Same asgetWrapperIfPrimitive()but wraps it in aClassInfo.<A extends Annotation>
 booleanhasAnnotation(Class<A> type) Returnstrue if this class has the specified annotation.<A extends Annotation>
 booleanhasAnnotation(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if this class has the specified annotation.inthashCode()<A extends Annotation>
 booleanhasNoAnnotation(Class<A> type) Returnstrue if this class doesn't have the specified annotation.booleanReturnstrue if this class is not in the root package.booleanReturnstrue if thegetPrimitiveWrapper()method returns a value.<T> Class<T>inner()Returns the wrapped class as aClass.Returns the wrapped class as aType.booleanChecks for equality with the specified class.booleanChecks for equality with the specified class.booleanis(ReflectFlags... flags) Returnstrue if all specified flags are applicable to this field.booleanReturnstrue if this class is abstract.booleanisAll(ReflectFlags... flags) Returnstrue if all specified flags are applicable to this class.booleanReturnstrue if this class is an annotation.booleanReturnstrue if this class is any of the specified types.booleanisAny(ReflectFlags... flags) Returnstrue if all specified flags are applicable to this class.booleanisArray()Returnstrue if this class is an array.booleanReturnstrue if this class is a child or the same asparent .booleanReturnstrue if this class is a child or the same asparent .booleanReturnstrue if this class is a child or the same asparent .booleanisChildOfAny(Class<?>... parents) Returnstrue if this class is a child or the same as any of theparents .booleanisClass()Returnstrue if this class is not an interface.booleanReturnstrue if this class is aCollectionor an array.booleanReturnstrue if this class has the@Deprecatedannotation on it.booleanisEnum()Returnstrue if this class is an enum.booleanisInstance(Object value) Returnstrue if the specified value is an instance of this class.booleanReturnstrue if this class is an interface.booleanReturnstrue if this class is a local class.booleanReturnstrue if this class is a member class.booleanReturnstrue if this class is a member class and not static.booleanReturnstrue if this class is not abstract.booleanReturnstrue if this class doesn't have the@Deprecatedannotation on it.booleanReturnstrue if this class is a local class.booleanReturnstrue if this class is a member class.booleanReturnsfalse if this class is a member class and not static.booleanReturnstrue if this is not a primitive class.booleanReturnstrue if this class is not public.booleanReturnstrue if this class is not static.booleanisParentOf(Class<?> child) Returnstrue if this class is a parent or the same aschild .booleanisParentOf(Type child) Returnstrue if this class is a parent or the same aschild .booleanisParentOfFuzzyPrimitives(Class<?> child) Returnstrue if this class is a parent or the same aschild .booleanisParentOfFuzzyPrimitives(Type child) Returnstrue if this class is a parent or the same aschild .booleanSame asisParentOfFuzzyPrimitives(Class)but takes in aClassInfo.booleanReturnstrue if this is a primitive class.booleanisPublic()Returnstrue if this class is public.booleanReturnstrue if this is a repeated annotation class.booleanReturnstrue if this class is aRuntimeException.booleanisStatic()Returnstrue if this class is public.booleanisStrictChildOf(Class<?> parent) Returnstrue if this class is a child ofparent .booleanIdentifies if the specified visibility matches this constructor.<A extends Annotation>
 AlastAnnotation(Class<A> type, Predicate<A> filter) Returns the last matching annotation on this class and superclasses/interfaces.<A extends Annotation>
 AlastAnnotation(AnnotationProvider annotationProvider, Class<A> type, Predicate<A> filter) Returns the last matching annotation on this class and superclasses/interfaces.booleanReturnstrue if this object passes the specified predicate test.Shortcut for callingClass.getDeclaredConstructor().newInstance() on the underlying class.static ClassInfoReturns a class info wrapper around the specified class type.static ClassInfoReturns a class info wrapper around the specified class type.static ClassInfoSame as using the constructor, but operates on an object instance.static ClassInfoReturns a class info wrapper around the specified class type.static ClassInfoSame asof(Object)but attempts to deproxify the object if it's wrapped in a CGLIB proxy.toString()
- 
Field Details- 
OBJECTReusable ClassInfo for Object class.
 
- 
- 
Constructor Details- 
ClassInfoConstructor.- Parameters:
- c- The class type.
- t- The generic type (if parameterized type).
 
 
- 
- 
Method Details- 
ofReturns a class info wrapper around the specified class type.- Parameters:
- t- The class type.
- Returns:
- The constructed class info, or null if the type wasnull .
 
- 
ofReturns a class info wrapper around the specified class type.- Parameters:
- c- The class type.
- Returns:
- The constructed class info, or null if the type wasnull .
 
- 
ofReturns a class info wrapper around the specified class type.- Parameters:
- c- The class type.
- t- The generic type (if parameterized type).
- Returns:
- The constructed class info, or null if the type wasnull .
 
- 
ofSame as using the constructor, but operates on an object instance.- Parameters:
- o- The class instance.
- Returns:
- The constructed class info, or null if the object wasnull .
 
- 
ofProxySame asof(Object)but attempts to deproxify the object if it's wrapped in a CGLIB proxy.- Parameters:
- o- The class instance.
- Returns:
- The constructed class info, or null if the object wasnull .
 
- 
innerTypeReturns the wrapped class as aType.- Returns:
- The wrapped class as a Type.
 
- 
innerReturns the wrapped class as aClass.- Type Parameters:
- T- The inner class type.
- Returns:
- The wrapped class as a Class, ornull if it's not a class (e.g. it's aParameterizedType).
 
- 
unwrap- Parameters:
- wrapperTypes- The parameterized types to unwrap if this class is one of those types.
- Returns:
- The class info on the unwrapped type, or just this type if this isn't one of the specified types.
 
- 
getSuperclassReturns the parent class.- Returns:
- The parent class, or null if the class has no parent.
 
- 
getDeclaredInterfacesReturns a list of interfaces declared on this class.Does not include interfaces declared on parent classes. Results are in the same order as Class.getInterfaces(). - Returns:
- An unmodifiable list of interfaces declared on this class.
   
 Results are in the same order asClass.getInterfaces().
 
- 
getInterfacesReturns a list of interfaces defined on this class and superclasses.Results are in child-to-parent order. - Returns:
- An unmodifiable list of interfaces defined on this class and superclasses.
   
 Results are in child-to-parent order.
 
- 
getParentsReturns a list including this class and all parent classes.Does not include interfaces. Results are in child-to-parent order. - Returns:
- An unmodifiable list including this class and all parent classes.
   
 Results are in child-to-parent order.
 
- 
getAllParentsReturns a list including this class and all parent classes and interfaces.Results are classes-before-interfaces, then child-to-parent order. - Returns:
- An unmodifiable list including this class and all parent classes.
   
 Results are ordered child-to-parent order with classes listed before interfaces.
 
- 
getAnyParentReturns the first matching parent class or interface.Results are classes-before-interfaces, then child-to-parent order. - Parameters:
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- The parent class or interface that matches the specified predicate.
 
- 
getPublicMethodsReturns all public methods on this class.Methods defined on the Objectclass are excluded from the results.- Returns:
- All public methods on this class.
   
 Results are ordered alphabetically.
 
- 
forEachPublicMethodPerforms an action on all matching public methods on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
getPublicMethodReturns the first matching public method on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- The first matching method, or null if no methods matched.
 
- 
getDeclaredMethodsReturns all methods declared on this class.- Returns:
- All methods declared on this class.
   
 Results are ordered alphabetically.
 List is unmodifiable.
 
- 
forEachDeclaredMethodPerforms an action on all matching declared methods on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
getDeclaredMethodReturns the first matching declared method on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- The first matching method, or null if no methods matched.
 
- 
getMethodsReturns all declared methods on this class and all parent classes.- Returns:
- All declared methods on this class and all parent classes.
   
 Results are ordered child-to-parent, and then alphabetically per class.
 List is unmodifiable.
 
- 
forEachMethodPerforms an action on all matching methods on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
getMethodReturns the first matching method on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- The first matching method, or null if no methods matched.
 
- 
getAllMethodsParentFirstReturns all declared methods on this class and all parent classes.- Returns:
- All declared methods on this class and all parent classes.
   
 Results are ordered parent-to-child, and then alphabetically per class.
 List is unmodifiable.
 
- 
forEachAllMethodParentFirstpublic ClassInfo forEachAllMethodParentFirst(Predicate<MethodInfo> filter, Consumer<MethodInfo> action) Performs an action on all matching declared methods on this class and all parent classes.- Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
getPublicConstructorsReturns all the public constructors defined on this class.- Returns:
- All public constructors defined on this class.
 
- 
forEachPublicConstructorpublic ClassInfo forEachPublicConstructor(Predicate<ConstructorInfo> filter, Consumer<ConstructorInfo> action) Performs an action on all matching public constructors on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
getPublicConstructorReturns the first matching public constructor on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- The public constructor that matches the specified predicate.
 
- 
getDeclaredConstructorsReturns all the constructors defined on this class.- Returns:
- All constructors defined on this class.
   
 List is unmodifiable.
 
- 
forEachDeclaredConstructorpublic ClassInfo forEachDeclaredConstructor(Predicate<ConstructorInfo> filter, Consumer<ConstructorInfo> action) Performs an action on all matching declared constructors on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
getDeclaredConstructorReturns the first matching declared constructor on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- The declared constructor that matches the specified predicate.
 
- 
getNoArgConstructorLocates the no-arg constructor for this class.Constructor must match the visibility requirements specified by parameter 'v'. If class is abstract, always returns null . Note that this also returns the 1-arg constructor for non-static member classes.- Parameters:
- v- The minimum visibility.
- Returns:
- The constructor, or null if no no-arg constructor exists with the required visibility.
 
- 
getPublicFieldsReturns all public fields on this class.Hidden fields are excluded from the results. - Returns:
- All public fields on this class.
   
 Results are in alphabetical order.
 List is unmodifiable.
 
- 
forEachPublicFieldPerforms an action on all matching public fields on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
getPublicFieldReturns the first matching public field on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- The public field, or null if not found.
 
- 
getDeclaredFieldsReturns all declared fields on this class.- Returns:
- All declared fields on this class.
   
 Results are in alphabetical order.
 List is unmodifiable.
 
- 
forEachDeclaredFieldPerforms an action on all matching declared fields on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
getDeclaredFieldReturns the first matching declared field on this class.- Parameters:
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- The declared field, or null if not found.
 
- 
getAllFieldsReturns all fields on this class and all parent classes.Results are ordered parent-to-child, and then alphabetical per class. - Returns:
- All declared fields on this class.
   
 List is unmodifiable.
 
- 
forEachAllFieldPerforms an action on all matching fields on this class and all parent classes.Results are ordered parent-to-child, and then alphabetical per class. - Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
getAnnotationsReturns all annotations of the specified type defined on the specified class or parent classes/interfaces in parent-to-child order.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation type to look for.
- Returns:
- The matching annotations.
 
- 
getAnnotationspublic <A extends Annotation> List<A> getAnnotations(AnnotationProvider annotationProvider, Class<A> type) Returns all annotations of the specified type defined on this or parent classes/interfaces.Returns the list in reverse (parent-to-child) order. - Type Parameters:
- A- The annotation type to look for.
- Parameters:
- annotationProvider- The annotation provider.
- type- The annotation type to look for.
- Returns:
- The matching annotations.
 
- 
forEachAnnotationpublic <A extends Annotation> ClassInfo forEachAnnotation(Class<A> type, Predicate<A> filter, Consumer<A> action) Performs an action on all matching annotations on this class and superclasses/interfaces.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
forEachAnnotationpublic <A extends Annotation> ClassInfo forEachAnnotation(AnnotationProvider annotationProvider, Class<A> type, Predicate<A> filter, Consumer<A> action) Performs an action on all matching annotations on this class and superclasses/interfaces.Annotations are appended in the following orders: - On the package of this class.
- On interfaces ordered parent-to-child.
- On parent classes ordered parent-to-child.
- On this class.
 - Type Parameters:
- A- The annotation type to look for.
- Parameters:
- annotationProvider- The annotation provider.
- type- The annotation to look for.
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
firstAnnotationReturns the first matching annotation on this class and superclasses/interfaces.Annotations are searched in the following orders: - On the package of this class.
- On interfaces ordered parent-to-child.
- On parent classes ordered parent-to-child.
- On this class.
 - Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- filter- A predicate to apply to the entries to determine if annotation should be returned. Can be- null .
- Returns:
- This object.
 
- 
firstAnnotationpublic <A extends Annotation> A firstAnnotation(AnnotationProvider annotationProvider, Class<A> type, Predicate<A> filter) Returns the first matching annotation on this class and superclasses/interfaces.Annotations are searched in the following orders: - On the package of this class.
- On interfaces ordered parent-to-child.
- On parent classes ordered parent-to-child.
- On this class.
 - Type Parameters:
- A- The annotation type to look for.
- Parameters:
- annotationProvider- The annotation provider.
- type- The annotation to look for.
- filter- A predicate to apply to the entries to determine if annotation should be returned. Can be- null .
- Returns:
- This object.
 
- 
lastAnnotationReturns the last matching annotation on this class and superclasses/interfaces.Annotations are searched in the following orders: - On this class.
- On parent classes ordered child-to-parent.
- On interfaces ordered child-to-parent.
- On the package of this class.
 - Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- filter- A predicate to apply to the entries to determine if annotation should be returned. Can be- null .
- Returns:
- This object.
 
- 
lastAnnotationpublic <A extends Annotation> A lastAnnotation(AnnotationProvider annotationProvider, Class<A> type, Predicate<A> filter) Returns the last matching annotation on this class and superclasses/interfaces.Annotations are searched in the following orders: - On this class.
- On parent classes ordered child-to-parent.
- On interfaces ordered child-to-parent.
- On the package of this class.
 - Type Parameters:
- A- The annotation type to look for.
- Parameters:
- annotationProvider- The annotation provider.
- type- The annotation to look for.
- filter- A predicate to apply to the entries to determine if annotation should be returned. Can be- null .
- Returns:
- This object.
 
- 
getAnnotationFinds the annotation of the specified type defined on this class or parent class/interface.If the annotation cannot be found on the immediate class, searches methods with the same signature on the parent classes or interfaces. 
 The search is performed in child-to-parent order.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- Returns:
- The annotation if found, or null if not.
 
- 
getAnnotationFinds the annotation of the specified type defined on this class or parent class/interface.If the annotation cannot be found on the immediate class, searches methods with the same signature on the parent classes or interfaces. 
 The search is performed in child-to-parent order.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- annotationProvider- The annotation provider.
- type- The annotation to look for.
- Returns:
- The annotation if found, or null if not.
 
- 
hasAnnotationReturnstrue if this class has the specified annotation.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- Returns:
- The true if annotation if found.
 
- 
hasNoAnnotationReturnstrue if this class doesn't have the specified annotation.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- Returns:
- The true if annotation if not found.
 
- 
hasAnnotationpublic <A extends Annotation> boolean hasAnnotation(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if this class has the specified annotation.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- annotationProvider- The annotation provider.
- type- The annotation to look for.
- Returns:
- The true if annotation if found.
 
- 
getPackageAnnotationReturns the specified annotation only if it's been declared on the package of this class.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation class.
- Returns:
- The annotation, or null if not found.
 
- 
getAnnotationReturns the first matching annotation of the specified type defined on the specified class or parent classes/interfaces in parent-to-child order.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- This object.
 
- 
getAnnotationListConstructs anAnnotationListof all annotations found on this class.Annotations are appended in the following orders: - On the package of this class.
- On interfaces ordered parent-to-child.
- On parent classes ordered parent-to-child.
- On this class.
 - Returns:
- A new AnnotationListobject on every call.
 
- 
getAnnotationListConstructs anAnnotationListof all matching annotations on this class.Annotations are appended in the following orders: - On the package of this class.
- On interfaces ordered parent-to-child.
- On parent classes ordered parent-to-child.
- On this class.
 - Parameters:
- filter- A predicate to apply to the entries to determine if value should be used. Can be- null .
- Returns:
- A new AnnotationListobject on every call.
 
- 
forEachAnnotationInfopublic ClassInfo forEachAnnotationInfo(Predicate<AnnotationInfo<?>> filter, Consumer<AnnotationInfo<?>> action) Performs an action on all matching annotations on this class/parents/package.Annotations are consumed in the following order: - On the package of this class.
- On interfaces ordered parent-to-child.
- On parent classes ordered parent-to-child.
- On this class.
 - Parameters:
- filter- A predicate to apply to the entries to determine if action should be performed. Can be- null .
- action- An action to perform on the entry.
- Returns:
- This object.
 
- 
isAllReturnstrue if all specified flags are applicable to this class.- Parameters:
- flags- The flags to test for.
- Returns:
- true if all specified flags are applicable to this class.
 
- 
isAnyReturnstrue if all specified flags are applicable to this class.- Parameters:
- flags- The flags to test for.
- Returns:
- true if all specified flags are applicable to this class.
 
- 
isDeprecatedReturnstrue if this class has the@Deprecatedannotation on it.- Returns:
- true if this class has the- @Deprecatedannotation on it.
 
- 
isNotDeprecatedReturnstrue if this class doesn't have the@Deprecatedannotation on it.- Returns:
- true if this class doesn't have the- @Deprecatedannotation on it.
 
- 
isPublicReturnstrue if this class is public.- Returns:
- true if this class is public.
 
- 
isNotPublicReturnstrue if this class is not public.- Returns:
- true if this class is not public.
 
- 
isStaticReturnstrue if this class is public.Note that interfaces are always reported as static, and the static keyword on a member interface is meaningless. - Returns:
- true if this class is public.
 
- 
isNotStaticReturnstrue if this class is not static.Note that interfaces are always reported as static, and the static keyword on a member interface is meaningless. - Returns:
- true if this class is not static.
 
- 
isAbstractReturnstrue if this class is abstract.Note that interfaces are always reported as abstract. - Returns:
- true if this class is abstract.
 
- 
isNotAbstractReturnstrue if this class is not abstract.Note that interfaces are always reported as abstract. - Returns:
- true if this class is not abstract.
 
- 
isMemberClassReturnstrue if this class is a member class.- Returns:
- true if this class is a member class.
 
- 
isNotMemberClassReturnstrue if this class is a member class.- Returns:
- true if this class is a member class.
 
- 
isNonStaticMemberClassReturnstrue if this class is a member class and not static.- Returns:
- true if this class is a member class and not static.
 
- 
isNotNonStaticMemberClassReturnsfalse if this class is a member class and not static.- Returns:
- false if this class is a member class and not static.
 
- 
isLocalClassReturnstrue if this class is a local class.- Returns:
- true if this class is a local class.
 
- 
isNotLocalClassReturnstrue if this class is a local class.- Returns:
- true if this class is a local class.
 
- 
isVisibleIdentifies if the specified visibility matches this constructor.- Parameters:
- v- The visibility to validate against.
- Returns:
- true if this visibility matches the modifier attribute of this constructor.
 
- 
isPrimitiveReturnstrue if this is a primitive class.- Returns:
- true if this is a primitive class.
 
- 
isNotPrimitiveReturnstrue if this is not a primitive class.- Returns:
- true if this is not a primitive class.
 
- 
isInterfaceReturnstrue if this class is an interface.- Returns:
- true if this class is an interface.
 
- 
isClassReturnstrue if this class is not an interface.- Returns:
- true if this class is not an interface.
 
- 
isRuntimeExceptionReturnstrue if this class is aRuntimeException.- Returns:
- true if this class is a- RuntimeException.
 
- 
hasPrimitiveWrapperReturnstrue if thegetPrimitiveWrapper()method returns a value.- Returns:
- true if the- getPrimitiveWrapper()method returns a value.
 
- 
getPrimitiveWrapperIf this class is a primitive (e.g.int .class Integer.).class - Returns:
- The wrapper class, or null if class is not a primitive.
 
- 
getPrimitiveForWrapperIf this class is a primitive wrapper (e.g.Integer .class int.).class - Returns:
- The primitive class, or null if class is not a primitive wrapper.
 
- 
getWrapperIfPrimitiveIf this class is a primitive (e.g.int .class Integer.).class - Returns:
- The wrapper class if it's primitive, or the same class if class is not a primitive.
 
- 
getWrapperInfoIfPrimitiveSame asgetWrapperIfPrimitive()but wraps it in aClassInfo.- Returns:
- The wrapper class if it's primitive, or the same class if class is not a primitive.
 
- 
getPrimitiveDefaultReturns the default value for this primitive class.- Returns:
- The default value, or null if this is not a primitive class.
 
- 
getFullNameReturns the full name of this class.Examples:- "com.foo.MyClass" - Normal class
- "com.foo.MyClass[][]" - Array.
- "com.foo.MyClass$InnerClass" - Inner class.
- "com.foo.MyClass$InnerClass[][]" - Inner class array.
- "int" - Primitive class.
- "int[][]" - Primitive class class.
- "java.util.Map<java.lang.String,java.lang.Object>" - Parameterized type.
- "java.util.AbstractMap<K,V>" - Parameterized generic type.
- "V" - Parameterized generic type argument.
 - Returns:
- The underlying class name.
 
- 
getNamesReturns all possible names for this class.- Returns:
- An array consisting of:
   - getFullName()
- Class.getName()- Note that this might be a dup.
- getShortName()
- getSimpleName()
 
 
- 
appendFullNameSame asgetFullName()but appends to an existing string builder.- Parameters:
- sb- The string builder to append to.
- Returns:
- The same string builder.
 
- 
getShortNameReturns the short name of the underlying class.Similar to getSimpleName()but also renders local or member class name prefixes.- Returns:
- The short name of the underlying class.
 
- 
appendShortNameSame asgetShortName()but appends to an existing string builder.- Parameters:
- sb- The string builder to append to.
- Returns:
- The same string builder.
 
- 
getSimpleNameReturns the simple name of the underlying class.Returns either Class.getSimpleName()orType.getTypeName()depending on whether this is a class or type.- Returns:
- The simple name of the underlying class;
 
- 
getNameReturns the name of the underlying class.- Returns:
- The name of the underlying class.
 
- 
getReadableName- Returns:
- The readable name for this class.
 
- 
isParentOfReturnstrue if this class is a parent or the same aschild .- Parameters:
- child- The child class.
- Returns:
- true if this class is a parent or the same as- child .
 
- 
isParentOfFuzzyPrimitivesReturnstrue if this class is a parent or the same aschild .Primitive classes are converted to wrapper classes and compared. Examples:ClassInfo. of (String.class ).isParentOfFuzzyPrimitives(String.class );// true ClassInfo.of (CharSequence.class ).isParentOfFuzzyPrimitives(String.class );// true ClassInfo.of (String.class ).isParentOfFuzzyPrimitives(CharSequence.class );// false ClassInfo.of (int .class ).isParentOfFuzzyPrimitives(Integer.class );// true ClassInfo.of (Integer.class ).isParentOfFuzzyPrimitives(int .class );// true ClassInfo.of (Number.class ).isParentOfFuzzyPrimitives(int .class );// true ClassInfo.of (int .class ).isParentOfFuzzyPrimitives(Number.class );// false ClassInfo.of (int .class ).isParentOfFuzzyPrimitives(long .class );// false - Parameters:
- child- The child class.
- Returns:
- true if this class is a parent or the same as- child .
 
- 
canAcceptArgReturnstrue if this type can be used as a parameter for the specified object.- Parameters:
- child- The argument to check.
- Returns:
- true if this type can be used as a parameter for the specified object.
 
- 
isParentOfFuzzyPrimitivesSame asisParentOfFuzzyPrimitives(Class)but takes in aClassInfo.- Parameters:
- child- The child class.
- Returns:
- true if this class is a parent or the same as- child .
 
- 
isParentOfReturnstrue if this class is a parent or the same aschild .- Parameters:
- child- The child class.
- Returns:
- true if this class is a parent or the same as- child .
 
- 
isParentOfFuzzyPrimitivesReturnstrue if this class is a parent or the same aschild .- Parameters:
- child- The child class.
- Returns:
- true if this class is a parent or the same as- child .
 
- 
isStrictChildOfReturnstrue if this class is a child ofparent .- Parameters:
- parent- The parent class.
- Returns:
- true if this class is a parent of- child .
 
- 
isChildOfReturnstrue if this class is a child or the same asparent .- Parameters:
- parent- The parent class.
- Returns:
- true if this class is a child or the same as- parent .
 
- 
isChildOfAnyReturnstrue if this class is a child or the same as any of theparents .- Parameters:
- parents- The parents class.
- Returns:
- true if this class is a child or the same as any of the- parents .
 
- 
isChildOfReturnstrue if this class is a child or the same asparent .- Parameters:
- parent- The parent class.
- Returns:
- true if this class is a parent or the same as- parent .
 
- 
isChildOfReturnstrue if this class is a child or the same asparent .- Parameters:
- parent- The parent class.
- Returns:
- true if this class is a parent or the same as- parent .
 
- 
isChecks for equality with the specified class.- Parameters:
- c- The class to check equality with.
- Returns:
- true if the specified class is the same as this one.
 
- 
isChecks for equality with the specified class.- Parameters:
- c- The class to check equality with.
- Returns:
- true if the specified class is the same as this one.
 
- 
isInstanceReturnstrue if the specified value is an instance of this class.- Parameters:
- value- The value to check.
- Returns:
- true if the specified value is an instance of this class.
 
- 
isAnyReturnstrue if this class is any of the specified types.- Parameters:
- types- The types to check against.
- Returns:
- true if this class is any of the specified types.
 
- 
isReturnstrue if all specified flags are applicable to this field.- Parameters:
- flags- The flags to test for.
- Returns:
- true if all specified flags are applicable to this field.
 
- 
getPackageReturns the package of this class.- Returns:
- The package of this class.
 
- 
hasPackageReturnstrue if this class is not in the root package.- Returns:
- true if this class is not in the root package.
 
- 
getDimensionsReturns the number of dimensions if this is an array type.- Returns:
- The number of dimensions if this is an array type, or 0 if it is not.
 
- 
getComponentTypeReturns the base component type of this class if it's an array.- Returns:
- The base component type of this class if it's an array, or this object if it's not.
 
- 
isEnumReturnstrue if this class is an enum.- Returns:
- true if this class is an enum.
 
- 
isRepeatedAnnotationReturnstrue if this is a repeated annotation class.A repeated annotation has a single value()method that returns an array of annotations who themselves are marked with the@Repeatableannotation of this class.- Returns:
- true if this is a repeated annotation class.
 
- 
getRepeatedAnnotationMethodReturns the repeated annotation method on this class.The repeated annotation method is the value()method that returns an array of annotations who themselves are marked with the@Repeatableannotation of this class.- Returns:
- The repeated annotation method on this class, or null if it doesn't exist.
 
- 
isArrayReturnstrue if this class is an array.- Returns:
- true if this class is an array.
 
- 
isAnnotationReturnstrue if this class is an annotation.- Returns:
- true if this class is an annotation.
 
- 
isCollectionOrArrayReturnstrue if this class is aCollectionor an array.- Returns:
- true if this class is a- Collectionor an array.
 
- 
newInstanceShortcut for callingClass.getDeclaredConstructor().newInstance() on the underlying class.- Returns:
- A new instance of the underlying class
- Throws:
- ExecutableException- Exception occurred on invoked constructor/method/field.
 
- 
getParameterTypeFinds the real parameter type of this class.- Parameters:
- index- The zero-based index of the parameter to resolve.
- pt- The parameterized type class containing the parameterized type to resolve (e.g.- HashMap ).
- Returns:
- The resolved real class.
 
- 
matchesReturnstrue if this object passes the specified predicate test.- Parameters:
- test- The test to perform.
- Returns:
- true if this object passes the specified predicate test.
 
- 
acceptPerforms an action on this object if the specified predicate test passes.- Parameters:
- test- A test to apply to determine if action should be executed. Can be- null .
- action- An action to perform on this object.
- Returns:
- This object.
 
- 
toString
- 
hashCode
- 
equals
 
-