Class BeanIntrospectionData


  • class BeanIntrospectionData
    extends java.lang.Object

    An internally used helper class for storing introspection information about a bean class.

    This class is used by PropertyUtilsBean. When accessing bean properties via reflection information about the properties available and their types and access methods must be present. PropertyUtilsBean stores this information in a cache so that it can be accessed quickly. The cache stores instances of this class.

    This class mainly stores information about the properties of a bean class. Per default, this is contained in PropertyDescriptor objects. Some additional information required by the BeanUtils library is also stored here.

    Since:
    1.9.1
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.beans.PropertyDescriptor[] descriptors
      An array with property descriptors for the managed bean class.
      private java.util.Map<java.lang.String,​java.lang.String> writeMethodNames
      A map for remembering the write method names for properties.
    • Constructor Summary

      Constructors 
      Constructor Description
      BeanIntrospectionData​(java.beans.PropertyDescriptor[] descs)
      Creates a new instance of BeanIntrospectionData and initializes its completely.
      BeanIntrospectionData​(java.beans.PropertyDescriptor[] descs, java.util.Map<java.lang.String,​java.lang.String> writeMethNames)
      Creates a new instance of BeanIntrospectionData and allows setting the map with write method names.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.beans.PropertyDescriptor getDescriptor​(java.lang.String name)
      Returns the PropertyDescriptor for the property with the specified name.
      java.beans.PropertyDescriptor[] getDescriptors()
      Returns the array with property descriptors.
      java.lang.reflect.Method getWriteMethod​(java.lang.Class<?> beanCls, java.beans.PropertyDescriptor desc)
      Returns the write method for the property determined by the given PropertyDescriptor.
      private static java.util.Map<java.lang.String,​java.lang.String> setUpWriteMethodNames​(java.beans.PropertyDescriptor[] descs)
      Initializes the map with the names of the write methods for the supported properties.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • descriptors

        private final java.beans.PropertyDescriptor[] descriptors
        An array with property descriptors for the managed bean class.
      • writeMethodNames

        private final java.util.Map<java.lang.String,​java.lang.String> writeMethodNames
        A map for remembering the write method names for properties.
    • Constructor Detail

      • BeanIntrospectionData

        public BeanIntrospectionData​(java.beans.PropertyDescriptor[] descs)
        Creates a new instance of BeanIntrospectionData and initializes its completely.
        Parameters:
        descs - the array with the descriptors of the available properties
      • BeanIntrospectionData

        BeanIntrospectionData​(java.beans.PropertyDescriptor[] descs,
                              java.util.Map<java.lang.String,​java.lang.String> writeMethNames)
        Creates a new instance of BeanIntrospectionData and allows setting the map with write method names. This constructor is mainly used for testing purposes.
        Parameters:
        descs - the array with the descriptors of the available properties
        writeMethNames - the map with the names of write methods
    • Method Detail

      • setUpWriteMethodNames

        private static java.util.Map<java.lang.String,​java.lang.String> setUpWriteMethodNames​(java.beans.PropertyDescriptor[] descs)
        Initializes the map with the names of the write methods for the supported properties. The method names - if defined - need to be stored separately because they may get lost when the GC claims soft references used by the PropertyDescriptor objects.
        Parameters:
        descs - the array with the descriptors of the available properties
        Returns:
        the map with the names of write methods for properties
      • getDescriptor

        public java.beans.PropertyDescriptor getDescriptor​(java.lang.String name)
        Returns the PropertyDescriptor for the property with the specified name. If this property is unknown, result is null.
        Parameters:
        name - the name of the property in question
        Returns:
        the PropertyDescriptor for this property or null
      • getDescriptors

        public java.beans.PropertyDescriptor[] getDescriptors()
        Returns the array with property descriptors.
        Returns:
        the property descriptors for the associated bean class
      • getWriteMethod

        public java.lang.reflect.Method getWriteMethod​(java.lang.Class<?> beanCls,
                                                       java.beans.PropertyDescriptor desc)
        Returns the write method for the property determined by the given PropertyDescriptor. This information is normally available in the descriptor object itself. However, at least by the ORACLE implementation, the method is stored as a SoftReference. If this reference has been freed by the GC, it may be the case that the method cannot be obtained again. Then, additional information stored in this object is necessary to obtain the method again.
        Parameters:
        beanCls - the class of the affected bean
        desc - the PropertyDescriptor of the desired property
        Returns:
        the write method for this property or null if there is none