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

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

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.
 Object get(MetaProperty<?> metaProperty)
          Gets the value of a single property previously added to the builder.
 Object get(String propertyName)
          Gets the value of a single property previously added to the builder.
 BeanBuilder<T> set(MetaProperty<?> metaProperty, 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)
          Deprecated. Loop in application code
 BeanBuilder<T> setString(MetaProperty<?> metaProperty, String value)
          Deprecated. Use Joda-Convert in application code
 BeanBuilder<T> setString(String propertyName, String value)
          Deprecated. Use Joda-Convert in application code
 

Method Detail

get

Object get(String propertyName)
Gets the value of a single property previously added to the builder.

Parameters:
propertyName - the property name to query, not null
Returns:
the previously set value, null if none
Throws:
RuntimeException - thrown if the property name is invalid

get

Object get(MetaProperty<?> metaProperty)
Gets the value of a single property previously added to the builder.

Parameters:
metaProperty - the meta-property to query, not null
Returns:
the previously set value, null if none
Throws:
RuntimeException - thrown if the property is invalid

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 to set, 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<?> metaProperty,
                   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:
metaProperty - the meta-property to set, not null
value - the property value, may be null
Returns:
this, for chaining, not null
Throws:
RuntimeException - optionally thrown if the property is invalid

setString

@Deprecated
BeanBuilder<T> setString(String propertyName,
                                    String value)
Deprecated. Use Joda-Convert in application code

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 to set, 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

@Deprecated
BeanBuilder<T> setString(MetaProperty<?> metaProperty,
                                    String value)
Deprecated. Use Joda-Convert in application code

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:
metaProperty - the meta-property name to set, not null
value - the property value, may be null
Returns:
this, for chaining, not null
Throws:
RuntimeException - optionally thrown if a property is invalid

setAll

@Deprecated
BeanBuilder<T> setAll(Map<String,? extends Object> propertyValueMap)
Deprecated. Loop in application code

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–2017 Joda.org. All rights reserved.