Package 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
build()
Builds the bean from the state of the builder.Object
get(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.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.
-
-
-
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
<P> P get(MetaProperty<P> metaProperty)
Gets the value of a single property previously added to the builder.- Type Parameters:
P
- the type of the property.- 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 nullvalue
- 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 nullvalue
- the property value, may be null- Returns:
this
, for chaining, not null- Throws:
RuntimeException
- optionally thrown if the property 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
-
-