Class ClassDescriptor


  • public class ClassDescriptor
    extends java.lang.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 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
    • Constructor Detail

      • ClassDescriptor

        public ClassDescriptor​(java.lang.Class type,
                               boolean scanAccessible,
                               boolean extendedProperties,
                               boolean includeFieldsAsProperties,
                               java.lang.String[] propertyFieldPrefix)
    • Method Detail

      • getType

        public java.lang.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 java.lang.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​(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)
        Returns method descriptor identified by name and parameters.
      • getMethodDescriptor

        public MethodDescriptor getMethodDescriptor​(java.lang.String name,
                                                    java.lang.Class[] params,
                                                    boolean declared)
        Returns method descriptor identified 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 or null if not found.
      • getCtorDescriptor

        public CtorDescriptor getCtorDescriptor​(java.lang.Class[] args,
                                                boolean declared)
        Returns the constructor identified by arguments or null if not found.
      • 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.class is not included in the returned list.