Package jodd.introspector
Class ClassDescriptor
- java.lang.Object
-
- jodd.introspector.ClassDescriptor
-
public class ClassDescriptor extends java.lang.ObjectA descriptor class for all methods/fields/properties/constructors of a class. Static methods/fields are ignored.Descriptors are 'lazy': various internal caches are created on first request.
Throughout this class, public members are defined as members defined with "public" keyword and declared in a public type. Public members declared by a non-public class is considered non-public because access to it from outside is prohibited by the java access control anyway.
Public members defined in public classes are always preferred even when we allow private/protected members and types to be visible. So if a non-public subtype and a public super type both have a field with the same name, the field in the public super type is always used.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanextendedPropertiesprotected booleanincludeFieldsAsPropertiesprotected java.lang.Class[]interfacesprotected java.lang.String[]propertyFieldPrefixprotected booleanscanAccessibleprotected java.lang.Class[]superclassesprotected java.lang.Classtype
-
Constructor Summary
Constructors Constructor Description ClassDescriptor(java.lang.Class type, boolean scanAccessible, boolean extendedProperties, boolean includeFieldsAsProperties, java.lang.String[] propertyFieldPrefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CtorDescriptor[]getAllCtorDescriptors()Returns an array of allconstructor descriptors.FieldDescriptor[]getAllFieldDescriptors()Returns all field descriptors, including declared ones.java.lang.Class[]getAllInterfaces()Returns all interfaces of this class.MethodDescriptor[]getAllMethodDescriptors()Returns an array of all methods.MethodDescriptor[]getAllMethodDescriptors(java.lang.String name)Returns an array of all methods with the same name.PropertyDescriptor[]getAllPropertyDescriptors()Returns all properties descriptors.java.lang.Class[]getAllSuperclasses()Returns all superclasses of this class.CtorDescriptorgetCtorDescriptor(java.lang.Class[] args, boolean declared)Returns the constructor identified by arguments ornullif not found.protected CtorsgetCtors()Returns constructors collection.CtorDescriptorgetDefaultCtorDescriptor(boolean declared)Returns the default ctor ornullif not found.FieldDescriptorgetFieldDescriptor(java.lang.String name, boolean declared)Returns field descriptor.protected FieldsgetFields()Returnsfields collection.MethodDescriptorgetMethodDescriptor(java.lang.String name, boolean declared)Returnsmethod descriptoridentified by name and parameters.MethodDescriptorgetMethodDescriptor(java.lang.String name, java.lang.Class[] params, boolean declared)Returnsmethod descriptoridentified by name and parameters.protected MethodsgetMethods()Returns methods collection.protected PropertiesgetProperties()Returns properties collection.PropertyDescriptorgetPropertyDescriptor(java.lang.String name, boolean declared)Returns property descriptor.java.lang.String[]getPropertyFieldPrefix()Returns property field prefixes.java.lang.ClassgetType()Get the class object that this descriptor describes.booleanisArray()Returnstrueif class is an array.booleanisCollection()Returnstrueif type is a collection.booleanisExtendedProperties()Returnstrueif properties in this class descriptor are extended and include field description.booleanisIncludeFieldsAsProperties()Include fields as properties.booleanisList()Returnstrueif class is aList.booleanisMap()Returnstrueif class is aMap.booleanisScanAccessible()Returnstrueif this class descriptor works with accessible fields/methods/constructors or with all supported.booleanisSet()Returnstrueif type is aSet.booleanisSupplier()Returnstrueif type is a supplier.booleanisSystemClass()Returnstrueis class is a system class and should not expose fields or declared methods.
-
-
-
Field Detail
-
type
protected final java.lang.Class type
-
scanAccessible
protected final boolean scanAccessible
-
extendedProperties
protected final boolean extendedProperties
-
includeFieldsAsProperties
protected final boolean includeFieldsAsProperties
-
propertyFieldPrefix
protected final java.lang.String[] propertyFieldPrefix
-
interfaces
protected final java.lang.Class[] interfaces
-
superclasses
protected final java.lang.Class[] superclasses
-
-
Method Detail
-
getType
public java.lang.Class getType()
Get the class object that this descriptor describes.
-
isScanAccessible
public boolean isScanAccessible()
Returnstrueif this class descriptor works with accessible fields/methods/constructors or with all supported.
-
isExtendedProperties
public boolean isExtendedProperties()
Returnstrueif properties in this class descriptor are extended and include field description.
-
isIncludeFieldsAsProperties
public boolean isIncludeFieldsAsProperties()
Include fields as properties.
-
getPropertyFieldPrefix
public java.lang.String[] getPropertyFieldPrefix()
Returns property field prefixes. May benullif prefixes are not set. If you need to access both prefixed and non-prefixed fields, use empty string as one of the prefixes.
-
isArray
public boolean isArray()
Returnstrueif class is an array.
-
isMap
public boolean isMap()
Returnstrueif class is aMap.
-
isList
public boolean isList()
Returnstrueif class is aList.
-
isSet
public boolean isSet()
Returnstrueif type is aSet.
-
isCollection
public boolean isCollection()
Returnstrueif type is a collection.
-
isSupplier
public boolean isSupplier()
Returnstrueif type is a supplier.
-
isSystemClass
public boolean isSystemClass()
Returnstrueis class is a system class and should not expose fields or declared methods.
-
getFields
protected Fields getFields()
Returnsfields collection. Creates new fields collection on first usage.
-
getFieldDescriptor
public FieldDescriptor getFieldDescriptor(java.lang.String name, boolean declared)
Returns field descriptor.
-
getAllFieldDescriptors
public FieldDescriptor[] getAllFieldDescriptors()
Returns all field descriptors, including declared ones.
-
getMethods
protected Methods getMethods()
Returns methods collection. Creates new collection on first access.
-
getMethodDescriptor
public MethodDescriptor getMethodDescriptor(java.lang.String name, boolean declared)
Returnsmethod descriptoridentified by name and parameters.
-
getMethodDescriptor
public MethodDescriptor getMethodDescriptor(java.lang.String name, java.lang.Class[] params, boolean declared)
Returnsmethod descriptoridentified by name and parameters.
-
getAllMethodDescriptors
public MethodDescriptor[] getAllMethodDescriptors(java.lang.String name)
Returns an array of all methods with the same name.
-
getAllMethodDescriptors
public MethodDescriptor[] getAllMethodDescriptors()
Returns an array of all methods.
-
getProperties
protected Properties getProperties()
Returns properties collection. Creates new collection on first access.
-
getPropertyDescriptor
public PropertyDescriptor getPropertyDescriptor(java.lang.String name, boolean declared)
Returns property descriptor. Declared flag is matched on both read and write methods.
-
getAllPropertyDescriptors
public PropertyDescriptor[] getAllPropertyDescriptors()
Returns all properties descriptors.
-
getCtors
protected Ctors getCtors()
Returns constructors collection. Creates new collection of first access.
-
getDefaultCtorDescriptor
public CtorDescriptor getDefaultCtorDescriptor(boolean declared)
Returns the default ctor ornullif not found.
-
getCtorDescriptor
public CtorDescriptor getCtorDescriptor(java.lang.Class[] args, boolean declared)
Returns the constructor identified by arguments ornullif not found.
-
getAllCtorDescriptors
public CtorDescriptor[] getAllCtorDescriptors()
Returns an array of allconstructor descriptors.
-
getAllInterfaces
public java.lang.Class[] getAllInterfaces()
Returns all interfaces of this class.
-
getAllSuperclasses
public java.lang.Class[] getAllSuperclasses()
Returns all superclasses of this class.Object.classis not included in the returned list.
-
-