Class BeanMetadata


  • public class BeanMetadata
    extends java.lang.Object
    The metadata class of Bean, which is used to represent a Java Bean.
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    BeanInfo, PropertyDescriptor
    • Constructor Detail

      • BeanMetadata

        protected BeanMetadata​(@Nonnull
                               java.lang.Class<?> beanClass)
      • BeanMetadata

        protected BeanMetadata​(java.beans.BeanInfo beanInfo)
    • Method Detail

      • getBeanInfo

        public java.beans.BeanInfo getBeanInfo()
      • getPropertyDescriptors

        @Nonnull
        @Immutable
        public java.util.Collection<java.beans.PropertyDescriptor> getPropertyDescriptors()
      • getPropertyDescriptor

        public java.beans.PropertyDescriptor getPropertyDescriptor​(java.lang.String propertyName)
        Get the PropertyDescriptor by property name
        Parameters:
        propertyName - the property name, which is usually the uncapitalized name of the property (e.g., "propertyName" for a property named "PropertyName")
        Returns:
        the PropertyDescriptor if found, otherwise null
      • getPropertyDescriptorsMap

        @Nonnull
        @Immutable
        public java.util.Map<java.lang.String,​java.beans.PropertyDescriptor> getPropertyDescriptorsMap()
      • getBeanClass

        public java.lang.Class<?> getBeanClass()
      • equals

        public final boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • of

        public static BeanMetadata of​(@Nonnull
                                      java.lang.Class<?> beanClass)
                               throws java.lang.RuntimeException
        Create a BeanMetadata instance from the specified bean class.

        Example Usage

        
         // Example 1: Create BeanMetadata for a simple Java Bean
         BeanMetadata metadata = BeanMetadata.of(Person.class);
        
         // Example 2: Create BeanMetadata for a complex Bean
         BeanMetadata metadata = BeanMetadata.of(Company.class);
         
        Parameters:
        beanClass - the bean class must not be null
        Returns:
        a BeanMetadata instance
        Throws:
        java.lang.RuntimeException - if the BeanInfo cannot be obtained from the specified bean class
        See Also:
        Introspector.getBeanInfo(Class, Class)