T - the bean typepublic class BasicBeanBuilder<T extends Bean> extends 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 and Description |
|---|
BasicBeanBuilder(T bean)
Constructs the builder wrapping the target bean.
|
| Modifier and Type | Method and Description |
|---|---|
T |
build()
Builds the bean from the state of the builder.
|
protected BeanBuilder<T> |
get(String propertyName)
Gets the current value of the property.
|
protected T |
getTargetBean()
Gets the target bean.
|
BeanBuilder<T> |
set(MetaProperty<?> property,
Object value)
Sets the value of a single property into the builder.
|
BeanBuilder<T> |
set(String propertyName,
Object value)
Sets the value of a single property into the builder.
|
BeanBuilder<T> |
setAll(Map<String,? extends Object> propertyValueMap)
Sets the value of a map of properties into the builder.
|
BeanBuilder<T> |
setString(MetaProperty<?> property,
String value)
Sets the value of a single property into the builder.
|
BeanBuilder<T> |
setString(String propertyName,
String value)
Sets the value of a single property into the builder.
|
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()
protected BeanBuilder<T> get(String propertyName)
propertyName - the property name, not nullpublic BeanBuilder<T> set(String propertyName, 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, not nullvalue - the property value, may be nullthis, for chaining, not nullpublic BeanBuilder<T> set(MetaProperty<?> property, 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>property - the property, not nullvalue - the property value, may be nullthis, for chaining, not nullpublic BeanBuilder<T> setString(String propertyName, String value)
BeanBuilderThis converts the string to the correct type for the property. Conversion uses Joda-Convert.
This will normally behave as per a Map, however it may not
and as a general rule callers should only set each property once.
setString in interface BeanBuilder<T extends Bean>propertyName - the property name, not nullvalue - the property value, may be nullthis, for chaining, not nullpublic BeanBuilder<T> setString(MetaProperty<?> property, String value)
BeanBuilderThis converts the string to the correct type for the property. Conversion uses Joda-Convert.
This will normally behave as per a Map, however it may not
and as a general rule callers should only set each property once.
setString in interface BeanBuilder<T extends Bean>property - the property name, not nullvalue - the property value, may be nullthis, for chaining, not nullpublic BeanBuilder<T> setAll(Map<String,? extends Object> propertyValueMap)
BeanBuilder
Each map entry is used as the input to BeanBuilder.set(String, Object).
This will normally behave as per a Map, however it may not
and as a general rule callers should only set each property once.
setAll in interface BeanBuilder<T extends Bean>propertyValueMap - the property name to value map, not 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 nullCopyright © 2007–2013 Joda.org. All rights reserved.