Package io.microsphere.beans
Class BeanMetadata
- java.lang.Object
-
- io.microsphere.beans.BeanMetadata
-
public class BeanMetadata extends java.lang.ObjectThe metadata class of Bean, which is used to represent a Java Bean.- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
BeanInfo,PropertyDescriptor
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBeanMetadata(java.beans.BeanInfo beanInfo)protectedBeanMetadata(java.lang.Class<?> beanClass)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.Class<?>getBeanClass()java.beans.BeanInfogetBeanInfo()java.beans.PropertyDescriptorgetPropertyDescriptor(java.lang.String propertyName)Get thePropertyDescriptorby property namejava.util.Collection<java.beans.PropertyDescriptor>getPropertyDescriptors()java.util.Map<java.lang.String,java.beans.PropertyDescriptor>getPropertyDescriptorsMap()inthashCode()static BeanMetadataof(java.lang.Class<?> beanClass)Create aBeanMetadatainstance from the specified bean class.java.lang.StringtoString()
-
-
-
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 thePropertyDescriptorby 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
PropertyDescriptorif found, otherwisenull
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
of
public static BeanMetadata of(@Nonnull java.lang.Class<?> beanClass) throws java.lang.RuntimeException
Create aBeanMetadatainstance 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 benull- Returns:
- a
BeanMetadatainstance - Throws:
java.lang.RuntimeException- if theBeanInfocannot be obtained from the specified bean class- See Also:
Introspector.getBeanInfo(Class, Class)
-
-