org.joda.beans
Interface BeanBuilder<T extends Bean>

Type Parameters:
T - the type of the bean
All Known Implementing Classes:
BasicBeanBuilder, BasicImmutableBeanBuilder, DirectBeanBuilder

public interface BeanBuilder<T extends Bean>

A builder for a bean, providing a safe way to create it.

This interface allows a bean to be created even if it is immutable.


Method Summary
 T build()
          Builds the bean from the state of the builder.
 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.
 

Method Detail

set

BeanBuilder<T> set(String propertyName,
                   Object value)
Sets the value of a single property into the builder.

This will normally behave as per a Map, however it may not and as a general rule callers should only set each property once.

Parameters:
propertyName - the property name, not null
value - the property value, may be null
Returns:
this, for chaining, not null
Throws:
RuntimeException - optionally thrown if the property name is invalid

set

BeanBuilder<T> set(MetaProperty<?> property,
                   Object value)
Sets the value of a single property into the builder.

This will normally behave as per a Map, however it may not and as a general rule callers should only set each property once.

Parameters:
property - the property, not null
value - the property value, may be null
Returns:
this, for chaining, not null
Throws:
RuntimeException - optionally thrown if the property name is invalid

setString

BeanBuilder<T> setString(String propertyName,
                         String value)
Sets the value of a single property into the builder.

This 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.

Parameters:
propertyName - the property name, not null
value - the property value, may be null
Returns:
this, for chaining, not null
Throws:
RuntimeException - optionally thrown if the property name is invalid

setString

BeanBuilder<T> setString(MetaProperty<?> property,
                         String value)
Sets the value of a single property into the builder.

This 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.

Parameters:
property - the property name, not null
value - the property value, may be null
Returns:
this, for chaining, not null
Throws:
RuntimeException - optionally thrown if the property name is invalid

setAll

BeanBuilder<T> setAll(Map<String,? extends Object> propertyValueMap)
Sets the value of a map of properties into the builder.

Each map entry is used as the input to 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.

Parameters:
propertyValueMap - the property name to value map, not null
Returns:
this, for chaining, not null
Throws:
RuntimeException - optionally thrown if a property name is invalid

build

T build()
Builds the bean from the state of the builder.

Once this method has been called, the builder is in an invalid state. The effect of further method calls is undetermined.

Returns:
the created bean, not null


Copyright © 2007–2013 Joda.org. All rights reserved.