Package io.microsphere.beans
Class BeanMetadata
- java.lang.Object
-
- io.microsphere.beans.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 Summary
Constructors Modifier Constructor Description protected
BeanMetadata(java.beans.BeanInfo beanInfo)
protected
BeanMetadata(java.lang.Class<?> beanClass)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.lang.Class<?>
getBeanClass()
java.beans.BeanInfo
getBeanInfo()
java.beans.PropertyDescriptor
getPropertyDescriptor(java.lang.String propertyName)
Get thePropertyDescriptor
by property namejava.util.Collection<java.beans.PropertyDescriptor>
getPropertyDescriptors()
java.util.Map<java.lang.String,java.beans.PropertyDescriptor>
getPropertyDescriptorsMap()
int
hashCode()
static BeanMetadata
of(java.lang.Class<?> beanClass)
Create aBeanMetadata
instance from the specified bean class.java.lang.String
toString()
-
-
-
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 thePropertyDescriptor
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, 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
of
public static BeanMetadata of(@Nonnull java.lang.Class<?> beanClass) throws java.lang.RuntimeException
Create aBeanMetadata
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 benull
- Returns:
- a
BeanMetadata
instance - Throws:
java.lang.RuntimeException
- if theBeanInfo
cannot be obtained from the specified bean class- See Also:
Introspector.getBeanInfo(Class, Class)
-
-