@Documented @Target(value=CONSTRUCTOR) @Retention(value=RUNTIME) @Inherited public @interface BeanConstructor
This annotation can be used in the case of beans with properties whose values can only be set by passing them in
through a constructor on the class.
Since method parameter names are lost during compilation, this annotation essentially redefines them so that they
are available at runtime.
This annotation can only be applied to constructors and can only be applied to one constructor per class.
When present, bean instantiation is delayed until the call to BeanMap.getBean()
.
Until then, bean property values are stored in a local cache until getBean()
is called.
Because of this additional caching step, parsing into read-only beans tends to be slower and use more memory than
parsing into beans with writable properties.
Attempting to call BeanMap.put(String,Object)
on a read-only property after calling BeanMap.getBean()
will result in a BeanRuntimeException
being thrown.
Multiple calls to BeanMap.getBean()
will return the same bean instance.
Modifier and Type | Optional Element and Description |
---|---|
String |
properties
The names of the properties of the constructor arguments.
|
public abstract String properties
The @BeanConstructor
annotation is used to
map constructor arguments to property names on bean with read-only properties.
Since method parameter names are lost during compilation, this annotation essentially redefines
them so that they are available at runtime.
The definition of a read-only bean is a bean with properties with only getters, like shown below:
Copyright © 2018 Apache. All rights reserved.