@Documented @Target(value=TYPE) @Retention(value=RUNTIME) @Inherited public @interface Bean
Can be used to do the following:
PropertyNamerwith a class.
This annotation can be applied to classes and interfaces.
|Modifier and Type||Optional Element and Description|
The list of classes that make up the bean dictionary for all properties of this bean or for subclasses of this bean.
Specifies a list of properties that should be excluded from
Identifies a class to be used as the interface class for this and all subclasses.
The set and order of names of properties associated with a bean class.
Sort bean properties in alphabetical order.
Identifies a stop class for the annotated class.
An identifying name for this class.
The property name to use for representing the type name.
The name is used to identify the class type during parsing when it cannot be inferred through reflection.
For example, if a bean property is of type
Object, then the serializer will add the name to the
output so that the class can be determined during parsing.
It is also used to specify element names in XML.
The name is used in combination with the bean dictionary defined through
Together, they make up a simple name/value mapping of names to classes.
Names do not need to be universally unique.
However, they must be unique within a dictionary.
When serialized as XML, the bean is rendered as:
When serialized as JSON,
public abstract String typePropertyName
This can be used to override the name used for the
This is similar in concept to the
BeanContext.BEAN_beanTypePropertyName setting except this annotation
applies only to the annotated class and subclasses whereas the bean context property applies globally on
serializers and parsers.
public abstract String properties
The order specified is the same order that the entries will be returned by the
public abstract boolean sort
This property is disabled by default so that IBM JVM users don't have to use
to force bean properties to be in a particular order and can just alter the order of the fields/methods
in the Java file.
This annotation is equivalent to using the
BeanContext.BEAN_sortProperties property, but applied to
individual classes instead of globally at the serializer or parser level.
public abstract String excludeProperties
public abstract Class<? extends PropertyNamer> propertyNamer
PropertyNamerwith this bean to tailor the names of the bean properties.
Property namers are used to transform bean property names from standard form to some other form.
For example, the
PropertyNamerDLC will convert property names to dashed-lowercase, and these will be used
as attribute names in JSON, and element names in XML.
public abstract Class<?> interfaceClass
When specified, only the list of properties defined on the interface class will be used during serialization. Additional properties on subclasses will be ignored.
Note that this annotation can be used on the parent class so that it filters to all child classes, or can be set individually on the child classes.
Identical in purpose to the stop class specified by
Any properties in the stop class or in its base classes will be ignored during analysis.
For example, in the following class hierarchy, instances of
C3 will include property
public abstract Class<?> beanDictionary
This is a shorthand for setting the
BeanProperty.beanDictionary() on all properties of the bean.
This list can consist of the following class types:
BeanDictionaryListthat defines an entire set of mappings. Note that the subclass MUST implement a no-arg constructor so that it can be instantiated.
BeanDictionaryMapthat defines an entire set of mappings. Note that the subclass MUST implement a no-arg constructor so that it can be instantiated.
Copyright © 2017 Apache. All rights reserved.