Class ClassDescriptor

java.lang.Object
jodd.introspector.ClassDescriptor

public class ClassDescriptor extends Object
A 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 Details

    • type

      protected final Class type
    • scanAccessible

      protected final boolean scanAccessible
    • extendedProperties

      protected final boolean extendedProperties
    • includeFieldsAsProperties

      protected final boolean includeFieldsAsProperties
    • propertyFieldPrefix

      protected final String[] propertyFieldPrefix
    • interfaces

      protected final Class[] interfaces
    • superclasses

      protected final Class[] superclasses
    • isArray

      private final boolean isArray
    • isMap

      private final boolean isMap
    • isList

      private final boolean isList
    • isSet

      private final boolean isSet
    • isCollection

      private final boolean isCollection
    • isSupplier

      private final boolean isSupplier
    • isSystemClass

      private boolean isSystemClass
    • fields

      private Fields fields
    • methods

      private Methods methods
    • properties

      private Properties properties
    • ctors

      private Ctors ctors
  • Constructor Details

    • ClassDescriptor

      public ClassDescriptor(Class type, boolean scanAccessible, boolean extendedProperties, boolean includeFieldsAsProperties, String[] propertyFieldPrefix)
  • Method Details

    • getType

      public Class getType()
      Get the class object that this descriptor describes.
    • isScanAccessible

      public boolean isScanAccessible()
      Returns true if this class descriptor works with accessible fields/methods/constructors or with all supported.
    • isExtendedProperties

      public boolean isExtendedProperties()
      Returns true if properties in this class descriptor are extended and include field description.
    • isIncludeFieldsAsProperties

      public boolean isIncludeFieldsAsProperties()
      Include fields as properties.
    • getPropertyFieldPrefix

      public String[] getPropertyFieldPrefix()
      Returns property field prefixes. May be null if 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()
      Returns true if class is an array.
    • isMap

      public boolean isMap()
      Returns true if class is a Map.
    • isList

      public boolean isList()
      Returns true if class is a List.
    • isSet

      public boolean isSet()
      Returns true if type is a Set.
    • isCollection

      public boolean isCollection()
      Returns true if type is a collection.
    • isSupplier

      public boolean isSupplier()
      Returns true if type is a supplier.
    • isSystemClass

      public boolean isSystemClass()
      Returns true is class is a system class and should not expose fields or declared methods.
    • getFields

      protected Fields getFields()
      Returns fields collection. Creates new fields collection on first usage.
    • getFieldDescriptor

      public FieldDescriptor getFieldDescriptor(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(String name, boolean declared)
      Returns method descriptor identified by name and parameters.
    • getMethodDescriptor

      public MethodDescriptor getMethodDescriptor(String name, Class[] params, boolean declared)
      Returns method descriptor identified by name and parameters.
    • getAllMethodDescriptors

      public MethodDescriptor[] getAllMethodDescriptors(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(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 or null if not found.
    • getCtorDescriptor

      public CtorDescriptor getCtorDescriptor(Class[] args, boolean declared)
      Returns the constructor identified by arguments or null if not found.
    • getAllCtorDescriptors

      public CtorDescriptor[] getAllCtorDescriptors()
      Returns an array of all constructor descriptors.
    • getAllInterfaces

      public Class[] getAllInterfaces()
      Returns all interfaces of this class.
    • getAllSuperclasses

      public Class[] getAllSuperclasses()
      Returns all superclasses of this class. Object.class is not included in the returned list.