Class MinimalMetaBean<T extends Bean>
- java.lang.Object
-
- org.joda.beans.impl.direct.MinimalMetaBean<T>
-
- Type Parameters:
T
- the type of the bean
- All Implemented Interfaces:
MetaBean
,TypedMetaBean<T>
public final class MinimalMetaBean<T extends Bean> extends Object implements TypedMetaBean<T>
A meta-bean implementation designed for use by the code generator.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated 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.<R> MetaProperty<R>
metaProperty(String propertyName)
Gets a meta-property by name.Map<String,MetaProperty<?>>
metaPropertyMap()
Gets the map of meta-properties, keyed by property name.static <B extends Bean>
MinimalMetaBean<B>of(Class<B> beanType, String[] fieldNames, Supplier<BeanBuilder<B>> builderSupplier, Function<B,Object>... getters)
Obtains an instance of the meta-bean for immutable beans.static <B extends Bean>
MinimalMetaBean<B>of(Class<B> beanType, String[] fieldNames, Supplier<BeanBuilder<B>> builderSupplier, List<Function<B,Object>> getters, List<BiConsumer<B,Object>> setters)
Obtains an instance of the meta-bean for mutable beans.static <B extends Bean>
MinimalMetaBean<B>of(Class<B> beanType, Supplier<BeanBuilder<B>> builderSupplier, Function<B,Object>... getters)
Deprecated.Use version that takes the field namesstatic <B extends Bean>
MinimalMetaBean<B>of(Class<B> beanType, Supplier<BeanBuilder<B>> builderSupplier, List<Function<B,Object>> getters, List<BiConsumer<B,Object>> setters)
Deprecated.Use version that takes the field namesString
toString()
Returns a string that summarises the meta-bean.MinimalMetaBean<T>
withAlias(String alias, String realName)
Adds an alias to 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, metaPropertyCount, metaPropertyExists, metaPropertyIterable
-
-
-
-
Method Detail
-
of
@Deprecated @SafeVarargs public static <B extends Bean> MinimalMetaBean<B> of(Class<B> beanType, Supplier<BeanBuilder<B>> builderSupplier, Function<B,Object>... getters)
Deprecated.Use version that takes the field namesObtains an instance of the meta-bean for immutable beans.The properties will be determined using reflection to find the
PropertyDefinition
annotation.- Type Parameters:
B
- the type of the bean- Parameters:
beanType
- the bean type, not nullbuilderSupplier
- the supplier of bean builders, not nullgetters
- the getter functions, not null- Returns:
- the meta-bean, not null
-
of
@SafeVarargs public static <B extends Bean> MinimalMetaBean<B> of(Class<B> beanType, String[] fieldNames, Supplier<BeanBuilder<B>> builderSupplier, Function<B,Object>... getters)
Obtains an instance of the meta-bean for immutable beans.The properties will be determined using reflection to find the
PropertyDefinition
annotation. The field names must be specified as reflection does not return fields in source code order.- Type Parameters:
B
- the type of the bean- Parameters:
beanType
- the bean type, not nullfieldNames
- the field names, not nullbuilderSupplier
- the supplier of bean builders, not nullgetters
- the getter functions, not null- Returns:
- the meta-bean, not null
-
of
@Deprecated public static <B extends Bean> MinimalMetaBean<B> of(Class<B> beanType, Supplier<BeanBuilder<B>> builderSupplier, List<Function<B,Object>> getters, List<BiConsumer<B,Object>> setters)
Deprecated.Use version that takes the field namesObtains an instance of the meta-bean for mutable beans.The properties will be determined using reflection to find the
PropertyDefinition
annotation.- Type Parameters:
B
- the type of the bean- Parameters:
beanType
- the bean type, not nullbuilderSupplier
- the supplier of bean builders, not nullgetters
- the getter functions, not nullsetters
- the setter functions, not null- Returns:
- the meta-bean, not null
-
of
public static <B extends Bean> MinimalMetaBean<B> of(Class<B> beanType, String[] fieldNames, Supplier<BeanBuilder<B>> builderSupplier, List<Function<B,Object>> getters, List<BiConsumer<B,Object>> setters)
Obtains an instance of the meta-bean for mutable beans.The properties will be determined using reflection to find the
PropertyDefinition
annotation. The field names must be specified as reflection does not return fields in source code order.- Type Parameters:
B
- the type of the bean- Parameters:
beanType
- the bean type, not nullfieldNames
- the field names, not nullbuilderSupplier
- the supplier of bean builders, not nullgetters
- the getter functions, not nullsetters
- the setter functions, not null- Returns:
- the meta-bean, not null
-
withAlias
public MinimalMetaBean<T> withAlias(String alias, String realName)
Adds an alias to the meta-bean.When using
metaProperty(String)
, the alias will return the meta-property of the real name.- Parameters:
alias
- the aliasrealName
- the real name- Returns:
- the new meta-bean instance
- Throws:
IllegalArgumentException
- if the realName is invalid
-
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.
-
metaProperty
public <R> MetaProperty<R> metaProperty(String propertyName)
Description copied from interface:MetaBean
Gets a meta-property by name.Each meta-bean manages a single bean with a known set of properties. This method returns the property with the specified name.
The base interface throws an exception if the name is not recognised. By contrast, the
DynamicMetaBean
subinterface creates the property on demand.- Specified by:
metaProperty
in interfaceMetaBean
- Type Parameters:
R
- the property type, optional, enabling auto-casting- Parameters:
propertyName
- the property name to retrieve, not null- Returns:
- the meta property, not null
-
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
-
-