Class ReflectiveMetaBean<T extends Bean>
- java.lang.Object
-
- org.joda.beans.impl.reflection.ReflectiveMetaBean<T>
-
- Type Parameters:
T
- the type of the bean
- All Implemented Interfaces:
MetaBean
,TypedMetaBean<T>
public final class ReflectiveMetaBean<T extends Bean> extends Object implements TypedMetaBean<T>
A meta-bean implementation that uses reflection.This is implementation of a meta-bean can be used directly by applications without code generation. It requires that the bean implements
Bean
and has a no-arguments constructor. Therefore, it is only suitable for mutable beans.Typically, the meta-bean will be created as a public static final constant. Only one method from
Bean
needs to be implemented, which simply returns the meta-bean.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<T>
beanType()
Get the type of the bean, represented as aClass
.BeanBuilder<T>
builder()
Creates a bean builder that can be used to create an instance of this bean.boolean
equals(Object obj)
int
hashCode()
boolean
isBuildable()
Checks whether this bean is buildable or not.Map<String,MetaProperty<?>>
metaPropertyMap()
Gets the map of meta-properties, keyed by property name.static <B extends Bean>
ReflectiveMetaBean<B>of(Class<B> beanClass, String... propertyNames)
Create a meta-bean and meta properties.String
toString()
Returns a string that summarises the meta-bean.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.joda.beans.MetaBean
annotation, annotationOpt, annotations, beanName, metaProperty, metaPropertyCount, metaPropertyExists, metaPropertyIterable
-
-
-
-
Method Detail
-
of
public static <B extends Bean> ReflectiveMetaBean<B> of(Class<B> beanClass, String... propertyNames)
Create a meta-bean and meta properties.The meta-properties will be created from the property names by searching for a getter and setter.
- Type Parameters:
B
- the type of the bean- Parameters:
beanClass
- the bean class, not nullpropertyNames
- the property names, not null- Returns:
- the meta-bean, not null
-
isBuildable
public boolean isBuildable()
Description copied from interface:MetaBean
Checks whether this bean is buildable or not.A buildable bean can be constructed using
MetaBean.builder()
. If this method returns true thenbuilder()
must return a valid builder. If this method returns false thenbuilder()
must throwUnsupportedOperationException
.- Specified by:
isBuildable
in interfaceMetaBean
- Returns:
- true if this bean is buildable
-
builder
public BeanBuilder<T> builder()
Description copied from interface:MetaBean
Creates a bean builder that can be used to create an instance of this bean.The builder is used in two main ways. The first is to allow immutable beans to be constructed. The second is to enable automated tools like serialization/deserialization.
The builder can be thought of as a
Map
ofMetaProperty
to value. Note that the implementation is not necessarily an actual map.
-
beanType
public Class<T> beanType()
Description copied from interface:MetaBean
Get the type of the bean, represented as aClass
.A
MetaBean
can be thought of as the equivalent ofClass
but for beans. This method allows the actualClass
instance of the bean to be obtained.
-
metaPropertyMap
public Map<String,MetaProperty<?>> metaPropertyMap()
Description copied from interface:MetaBean
Gets the map of meta-properties, keyed by property name.Where possible, use
MetaBean.metaPropertyIterable()
instead as it typically has better performance.- Specified by:
metaPropertyMap
in interfaceMetaBean
- Returns:
- the unmodifiable map of meta property objects, not null
-
-