public final class BeanPropertyMeta extends Object
Contains information such as type of property (e.g. field/getter/setter), class type of property value, and whether any transforms are associated with this property.
Developers will typically not need access to this class. The information provided by it is already exposed through
several methods on the BeanMap
API.
Modifier and Type | Class and Description |
---|---|
static class |
BeanPropertyMeta.Builder
BeanPropertyMeta builder class.
|
Modifier | Constructor and Description |
---|---|
protected |
BeanPropertyMeta(BeanPropertyMeta.Builder b)
Creates a new BeanPropertyMeta using the contents of the specified builder.
|
Modifier and Type | Method and Description |
---|---|
void |
add(BeanMap<?> m,
String pName,
Object value)
Adds a value to a
Collection or array property. |
void |
add(BeanMap<?> m,
String pName,
String key,
Object value)
Adds a value to a
Map or bean property. |
static BeanPropertyMeta.Builder |
builder(BeanMeta<?> beanMeta,
String name)
Creates a builder for
BeanPropertyMeta(org.apache.juneau.BeanPropertyMeta.Builder) objects. |
boolean |
canRead()
Returns
|
boolean |
canWrite()
Returns
|
<A extends Annotation> |
findAnnotations(Class<A> a)
Returns all instances of the specified annotation in the hierarchy of this bean property.
|
Object |
get(BeanMap<?> m,
String pName)
Equivalent to calling
BeanMap.get(Object) , but is faster since it avoids looking up the property meta. |
<A extends Annotation> |
getAnnotation(Class<A> a)
Returns the specified annotation on the field or methods that define this property.
|
BeanMeta<?> |
getBeanMeta()
Returns the bean meta that this property belongs to.
|
BeanRegistry |
getBeanRegistry()
Returns the bean dictionary in use for this bean property.
|
ClassMeta<?> |
getClassMeta()
Returns the
ClassMeta of the class of this property. |
Map<String,Object> |
getDynaMap(Object bean)
Returns the
Map object returned by the DynaBean getter. |
<M extends BeanPropertyMetaExtended> |
getExtendedMeta(Class<M> c)
Returns the language-specified extended metadata on this bean property.
|
Field |
getField()
Returns the field for this property.
|
Method |
getGetter()
Returns the getter method for this property.
|
String |
getName()
Returns the name of this bean property.
|
String[] |
getProperties()
Returns the override list of properties defined through a
@BeanProperty.properties() annotation
on this property. |
Object |
getRaw(BeanMap<?> m,
String pName)
Equivalent to calling
BeanMap.getRaw(Object) , but is faster since it avoids looking up the property meta. |
Method |
getSetter()
Returns the setter method for this property.
|
boolean |
isDyna()
Returns
|
boolean |
isUri()
Returns
|
Object |
set(BeanMap<?> m,
String pName,
Object value)
Equivalent to calling
BeanMap.put(String, Object) , but is faster since it avoids looking up the property
meta. |
protected void |
setArray(Object bean,
List l)
Sets an array field on this bean.
|
String |
toString() |
protected BeanPropertyMeta(BeanPropertyMeta.Builder b)
b
- The builder to copy fields from.public static BeanPropertyMeta.Builder builder(BeanMeta<?> beanMeta, String name)
BeanPropertyMeta(org.apache.juneau.BeanPropertyMeta.Builder)
objects.beanMeta
- The metadata on the beanname
- The bean property name.public String getName()
@BeanIgnore public BeanMeta<?> getBeanMeta()
public Method getGetter()
public Method getSetter()
public Field getField()
public ClassMeta<?> getClassMeta()
ClassMeta
of the class of this property.
If this property or the property type class has a PojoSwap
associated with it, this method returns the
transformed class meta.
This matches the class type that is used by the get(BeanMap,String)
and
set(BeanMap,String,Object)
methods.
ClassMeta
of the class of this property.public BeanRegistry getBeanRegistry()
The order of lookup for the dictionary is as follows:
@BeanProperty.beanDictionary()
.
BeanContext.BEAN_beanDictionary
context property.
public boolean isUri()
A bean property can be considered a URI if any of the following are true:
public boolean isDyna()
public String[] getProperties()
@BeanProperty.properties()
annotation
on this property.public <M extends BeanPropertyMetaExtended> M getExtendedMeta(Class<M> c)
c
- The name of the metadata class to create.public Object get(BeanMap<?> m, String pName)
BeanMap.get(Object)
, but is faster since it avoids looking up the property meta.m
- The bean map to get the transformed value from.pName
- The property name.public Object getRaw(BeanMap<?> m, String pName)
BeanMap.getRaw(Object)
, but is faster since it avoids looking up the property meta.m
- The bean map to get the transformed value from.pName
- The property name.public Object set(BeanMap<?> m, String pName, Object value) throws BeanRuntimeException
BeanMap.put(String, Object)
, but is faster since it avoids looking up the property
meta.m
- The bean map to set the property value on.pName
- The property name.value
- The value to set.BeanRuntimeException
- If property could not be set.public Map<String,Object> getDynaMap(Object bean) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
Map
object returned by the DynaBean getter.
The DynaBean property is the property whose name is
bean
- The bean.IllegalArgumentException
- Thrown by method invocation.IllegalAccessException
- Thrown by method invocation.InvocationTargetException
- Thrown by method invocation.protected void setArray(Object bean, List l) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
Works on both Object
and primitive arrays.
bean
- The bean of the field.l
- The collection to use to set the array field.IllegalArgumentException
- Thrown by method invocation.IllegalAccessException
- Thrown by method invocation.InvocationTargetException
- Thrown by method invocation.public void add(BeanMap<?> m, String pName, Object value) throws BeanRuntimeException
Collection
or array property.
Note that adding values to an array property is inefficient for large arrays since it must copy the array into a larger array on each operation.
m
- The bean of the field being set.pName
- The property name.value
- The value to add to the field.BeanRuntimeException
- If field is not a collection or array.public void add(BeanMap<?> m, String pName, String key, Object value) throws BeanRuntimeException
Map
or bean property.m
- The bean of the field being set.pName
- The property name.key
- The key to add to the field.value
- The value to add to the field.BeanRuntimeException
- If field is not a map or array.public <A extends Annotation> List<A> findAnnotations(Class<A> a)
Searches through the class hierarchy (e.g. superclasses, interfaces, packages) for all instances of the specified annotation.
a
- The class to find annotations for.public <A extends Annotation> A getAnnotation(Class<A> a)
This method will search up the parent class/interface hierarchy chain to search for the annotation on overridden getters and setters.
a
- The annotation to search for.public boolean canRead()
public boolean canWrite()
Copyright © 2018 Apache. All rights reserved.