Package org.joda.beans.impl
Class BufferingBeanBuilder<T extends Bean>
- java.lang.Object
-
- org.joda.beans.impl.BufferingBeanBuilder<T>
-
- Type Parameters:
T
- the bean type
- All Implemented Interfaces:
BeanBuilder<T>
public class BufferingBeanBuilder<T extends Bean> extends Object implements BeanBuilder<T>
Implementation ofBeanBuilder
that buffers data in a local map.This is useful for cases where the builder data might be manipulated before the final build. The buffer can be directly mutated.
-
-
Constructor Summary
Constructors Constructor Description BufferingBeanBuilder(MetaBean metaBean)
Constructs the builder wrapping the target bean.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
build()
Builds the bean from the state of the builder.Object
get(String propertyName)
Gets the buffered value associated with the specified property name.<P> P
get(MetaProperty<P> metaProperty)
Gets the buffered value associated with the specified property name.ConcurrentMap<MetaProperty<?>,Object>
getBuffer()
Gets the buffer holding the state of the builder.MetaBean
getMetaBean()
Gets the meta-beans.static BufferingBeanBuilder<?>
of(MetaBean metaBean)
Constructs the builder wrapping the target bean.BeanBuilder<T>
set(String propertyName, Object value)
Sets the value of a single property into the builder.BeanBuilder<T>
set(MetaProperty<?> metaProperty, Object value)
Sets the value of a single property into the builder.String
toString()
Returns a string that summarises the builder.
-
-
-
Constructor Detail
-
BufferingBeanBuilder
public BufferingBeanBuilder(MetaBean metaBean)
Constructs the builder wrapping the target bean.- Parameters:
metaBean
- the target meta-bean, not null
-
-
Method Detail
-
of
public static BufferingBeanBuilder<?> of(MetaBean metaBean)
Constructs the builder wrapping the target bean.- Parameters:
metaBean
- the target meta-bean, not null- Returns:
- a new untyped builder, not null
-
getMetaBean
public MetaBean getMetaBean()
Gets the meta-beans.- Returns:
- the meta-bean, not null
-
getBuffer
public ConcurrentMap<MetaProperty<?>,Object> getBuffer()
Gets the buffer holding the state of the builder.The buffer may be mutated.
- Returns:
- the mutable buffer, not null
-
get
public Object get(String propertyName)
Gets the buffered value associated with the specified property name.- Specified by:
get
in interfaceBeanBuilder<T extends Bean>
- Parameters:
propertyName
- the property name, not null- Returns:
- the current value in the builder, null if not found or value is null
-
get
public <P> P get(MetaProperty<P> metaProperty)
Gets the buffered value associated with the specified property name.- Specified by:
get
in interfaceBeanBuilder<T extends Bean>
- Type Parameters:
P
- the type of the property.- Parameters:
metaProperty
- the meta-property, not null- Returns:
- the current value in the builder, null if not found or value is null
-
set
public BeanBuilder<T> set(String propertyName, Object value)
Description copied from interface:BeanBuilder
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.- Specified by:
set
in interfaceBeanBuilder<T extends Bean>
- Parameters:
propertyName
- the property name to set, not nullvalue
- the property value, may be null- Returns:
this
, for chaining, not null
-
set
public BeanBuilder<T> set(MetaProperty<?> metaProperty, Object value)
Description copied from interface:BeanBuilder
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.- Specified by:
set
in interfaceBeanBuilder<T extends Bean>
- Parameters:
metaProperty
- the meta-property to set, not nullvalue
- the property value, may be null- Returns:
this
, for chaining, not null
-
build
public T build()
Description copied from interface:BeanBuilder
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.
- Specified by:
build
in interfaceBeanBuilder<T extends Bean>
- Returns:
- the created bean, not null
-
-