T - the type of the beanpublic final class LightMetaBean<T extends Bean> extends Object implements TypedMetaBean<T>
The properties are found using the PropertyDefinition annotation.
There must be a constructor matching the property definitions (arguments of same order and types).
This uses method handles to avoid problems with reflection setAccessible() in Java SE 9.
The old reflection approach is still present, but deprecated.
| Modifier and Type | Method and Description |
|---|---|
Class<T> |
beanType()
Get the type of the bean, represented as a
Class. |
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> |
of(Class<B> beanClass)
Deprecated.
Use method handles version of this method
|
static <B extends Bean> |
of(Class<B> beanType,
MethodHandles.Lookup lookup)
Obtains an instance of the meta-bean using standard default values.
|
static <B extends Bean> |
of(Class<B> beanType,
MethodHandles.Lookup lookup,
Object... defaultValues)
Deprecated.
Use version with field names, because no way to determine order of fields by reflection
|
static <B extends Bean> |
of(Class<B> beanType,
MethodHandles.Lookup lookup,
String[] fieldNames,
Object... defaultValues)
Obtains an instance of the meta-bean specifying default values.
|
String |
toString()
Returns a string that summarises the meta-bean.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitannotation, annotations, beanName, metaProperty, metaPropertyCount, metaPropertyExists, metaPropertyIterable, of, register@Deprecated public static <B extends Bean> LightMetaBean<B> of(Class<B> beanClass)
The properties will be determined using reflection to find the
PropertyDefinition annotation.
B - the type of the beanbeanClass - the bean class, not nullpublic static <B extends Bean> LightMetaBean<B> of(Class<B> beanType, MethodHandles.Lookup lookup)
The properties will be determined using reflection to find the fields.
Each field must have a PropertyDefinition annotation.
The order of the properties is undefined as Java fields are not necessarily
returned in source code order.
The default values for primitives are determined automatically.
If the bean has non-primitive values like lists and maps that need defaulting
then of(Class, java.lang.invoke.MethodHandles.Lookup, String[], Object...)
must be used.
B - the type of the beanbeanType - the bean type, not nulllookup - the method handle lookup, not null@Deprecated public static <B extends Bean> LightMetaBean<B> of(Class<B> beanType, MethodHandles.Lookup lookup, Object... defaultValues)
The properties will be determined using reflection to find the
PropertyDefinition annotation.
The default values must be provided if they cannot be determined automatically. Default values for primitives are determined automatically, but empty lists and maps are not.
B - the type of the beanbeanType - the bean type, not nulllookup - the method handle lookup, not nulldefaultValues - the default values, one for each property, not nullpublic static <B extends Bean> LightMetaBean<B> of(Class<B> beanType, MethodHandles.Lookup lookup, String[] fieldNames, Object... defaultValues)
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. The default values must be provided if they cannot be determined automatically. Default values for primitives are determined automatically, but empty lists and maps are not.
B - the type of the beanbeanType - the bean type, not nulllookup - the method handle lookup, not nullfieldNames - the field names, one for each property, not nulldefaultValues - the default values, one for each property, not nullpublic boolean isBuildable()
MetaBean
A buildable bean can be constructed using MetaBean.builder().
If this method returns true then builder() must return a valid builder.
If this method returns false then builder() must throw UnsupportedOperationException.
isBuildable in interface MetaBeanpublic BeanBuilder<T> builder()
MetaBeanThe 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 of MetaProperty to value.
Note that the implementation is not necessarily an actual map.
public Class<T> beanType()
MetaBeanClass.
A MetaBean can be thought of as the equivalent of Class but for beans.
This method allows the actual Class instance of the bean to be obtained.
public Map<String,MetaProperty<?>> metaPropertyMap()
MetaBean
Where possible, use MetaBean.metaPropertyIterable() instead as it typically has better performance.
metaPropertyMap in interface MetaBeanCopyright © 2007–2017 Joda.org. All rights reserved.