@Documented @Target(value={FIELD,METHOD,PARAMETER}) @Retention(value=RUNTIME) @Inherited public @interface BeanProperty
This annotation is applied to public fields and public getter/setter methods of beans.
Modifier and Type | Optional Element and Description |
---|---|
Class<?>[] |
beanDictionary
Bean dictionary.
|
String |
format
Specifies a String format for converting the bean property value to a formatted string.
|
String |
name
Identifies the name of the property.
|
Class<?>[] |
params
For bean properties of maps and collections, this annotation can be used to identify the class types of the
contents of the bean property object when the generic parameter types are interfaces or abstract classes.
|
String |
properties
Used to limit which child properties are rendered by the serializers.
|
Class<?> |
type
Identifies a specialized class type for the property.
|
String |
value
A synonym for
name() . |
public abstract String name
Normally, this is automatically inferred from the field name or getter method name of the property. However, this property can be used to assign a different property name from the automatically inferred value.
If the BeanContext.BEAN_beanFieldVisibility
setting on the bean context excludes this field (e.g. the
visibility is set to PUBLIC, but the field is PROTECTED), this annotation can be used to force the field to be
identified as a property.
The bean property named
The following examples show how to define dynamic bean properties.
Similar rules apply for value types and swaps. The property values optionally can be any serializable type or use swaps.
BeanContext.BEAN_ignoreUnknownBeanProperties
setting to ignore values that don't fit into existing
properties.
@Name
annotation can also be used for identifying a property name.
public abstract Class<?> type
Normally this can be inferred through reflection of the field type or getter return type.
However, you'll want to specify this value if you're parsing beans where the bean property class is an interface
or abstract class to identify the bean type to instantiate.
Otherwise, you may cause an InstantiationException
when trying to set these fields.
This property must denote a concrete bean class with a no-arg constructor.
This annotation can also be used on private fields of a property like so:
public abstract Class<?>[] params
This annotation can also be used on private fields of a property like so:
public abstract String properties
Can be used on any of the following bean property types:
This annotation can also be used on private fields of a property like so:
public abstract Class<?>[] beanDictionary
The list of classes that make up the bean dictionary this bean property.
This annotation can also be used on private fields of a property.
public abstract String format
Note that this is usually a one-way conversion during serialization.
During parsing, we will attempt to convert the value to the original form by using the
BeanSession.convertToType(Object, Class)
but there is no guarantee that this will succeed.
This annotation can also be used on private fields of a property like so:
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.