T - the bean typeBeanBuilder<T>DirectBeanBuilderpublic class BasicBeanBuilder<T extends Bean> extends java.lang.Object implements BeanBuilder<T>
BeanBuilder that wraps a real bean.
This approach saves creating a temporary map, but is only suitable if the bean has a no-arg constructor and allows properties to be set.
| Constructor | Description |
|---|---|
BasicBeanBuilder(T bean) |
Constructs the builder wrapping the target bean.
|
| Modifier and Type | Method | Description |
|---|---|---|
T |
build() |
Builds the bean from the state of the builder.
|
java.lang.Object |
get(java.lang.String propertyName) |
Gets the value of a single property previously added to the builder.
|
<P> P |
get(MetaProperty<P> metaProperty) |
Gets the value of a single property previously added to the builder.
|
protected T |
getTargetBean() |
Gets the target bean.
|
BeanBuilder<T> |
set(java.lang.String propertyName,
java.lang.Object value) |
Sets the value of a single property into the builder.
|
BeanBuilder<T> |
set(MetaProperty<?> metaProperty,
java.lang.Object value) |
Sets the value of a single property into the builder.
|
java.lang.String |
toString() |
Returns a string that summarises the builder.
|
protected void |
validate(T bean) |
Hook to allow a subclass to validate the bean.
|
public BasicBeanBuilder(T bean)
bean - the target bean, not nullprotected T getTargetBean()
public java.lang.Object get(java.lang.String propertyName)
BeanBuilderget in interface BeanBuilder<T extends Bean>propertyName - the property name to query, not nullpublic <P> P get(MetaProperty<P> metaProperty)
BeanBuilderget in interface BeanBuilder<T extends Bean>P - the type of the property.metaProperty - the meta-property to query, not nullpublic BeanBuilder<T> set(java.lang.String propertyName, java.lang.Object value)
BeanBuilder
This will normally behave as per a Map, however it may not
and as a general rule callers should only set each property once.
set in interface BeanBuilder<T extends Bean>propertyName - the property name to set, not nullvalue - the property value, may be nullthis, for chaining, not nullpublic BeanBuilder<T> set(MetaProperty<?> metaProperty, java.lang.Object value)
BeanBuilder
This will normally behave as per a Map, however it may not
and as a general rule callers should only set each property once.
set in interface BeanBuilder<T extends Bean>metaProperty - the meta-property to set, not nullvalue - the property value, may be nullthis, for chaining, not nullpublic T build()
BeanBuilderOnce this method has been called, the builder is in an invalid state. The effect of further method calls is undetermined.
build in interface BeanBuilder<T extends Bean>protected void validate(T bean)
bean - the bean to validate, not nullpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2007–2018 Joda.org. All rights reserved.