Class BeanUtil

    • Method Detail

      • getBeanPropertyDescriptor

        public static List<PropertyDescriptor> getBeanPropertyDescriptor​(Class<?> beanClass)
                                                                  throws IntrospectionException
        Returns the property descriptors of a class or an interface. For an interface, superinterfaces are also iterated as Introspector does not take them into account (Oracle Java bug 4275879), but in that case, both the setter and the getter for a property must be in the same interface and should not be overridden in subinterfaces for the discovery to work correctly. NOTE : This utility method relies on introspection (and returns PropertyDescriptor) which is a part of java.beans package. The latter package could require bigger JDK in the future (with Java 9+). So it may be changed in the future. For interfaces, the iteration is depth first and the properties of superinterfaces are returned before those of their subinterfaces.
        Parameters:
        beanClass -
        Returns:
        Throws:
        IntrospectionException
      • getPropertyType

        public static Class<?> getPropertyType​(Class<?> clazz,
                                               String propertyId)
                                        throws IntrospectionException
        Returns propertyId class for property declared in clazz. Property could be of form "property.subProperty[.subProperty2]" i.e. refer to some nested property.
        Parameters:
        clazz - class where property is declared
        propertyId - property of form "property" or "property.subProperty[.subProperty2]"
        Returns:
        class of the property
        Throws:
        IntrospectionException