T - the type of built objectspublic abstract class AbstractObjectBuilder<T> extends Object implements ObjectBuilder<T>
Abstract implementation of what is a ObjectBuilder. It is composed of a set of PropertySetter used
to configure it before to call the ObjectBuilder.build() method.
| Constructor and Description |
|---|
AbstractObjectBuilder(PropertySetter... setters)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addPropertySetter(PropertySetter... setters)
Adds the given
setters. |
T |
build()
Builds a new
NutDao thanks to the current state
of this builder. |
ObjectBuilder<T> |
disableSupport(String key,
Object value)
Disables the support of a property with a particular value.
|
protected Object[] |
getAllProperties()
Returns an array with one property for each
PropertySetter. |
Map<String,Object> |
getProperties()
Gets the property
Map. |
protected abstract T |
internalBuild()
Builds internally an object as specified by
ObjectBuilder.build() without
catching any exception. |
Object |
property(String key)
Gets the property identified by the given key.
|
ObjectBuilder<T> |
property(String key,
Object value)
Decorates this builder with a property.
|
protected void |
throwPropertyNotSupportedException(String key)
Throws a particular
IllegalArgumentException because a not supported property has been tried
to be set. |
public AbstractObjectBuilder(PropertySetter... setters)
Creates a new instance.
setters - the settersprotected void addPropertySetter(PropertySetter... setters)
Adds the given setters.
setters - the settersprotected Object[] getAllProperties()
Returns an array with one property for each PropertySetter. If the property
is not set, then the default value is returned.
public Map<String,Object> getProperties()
Gets the property Map.
getProperties in interface ObjectBuilder<T>public ObjectBuilder<T> property(String key, Object value)
Decorates this builder with a property.
Throws an IllegalArgumentException if the property key is not supported or if the value is incorrect.
property in interface ObjectBuilder<T>key - the keyvalue - the valuepublic ObjectBuilder<T> disableSupport(String key, Object value)
Disables the support of a property with a particular value. Any future setting which match the given key/value pair
(when calling ObjectBuilder.property(String, Object)) will result in an IllegalArgumentException.
disableSupport in interface ObjectBuilder<T>key - the keyvalue - the valuepublic Object property(String key)
Gets the property identified by the given key.
Throws an IllegalArgumentException if the property key is not supported.
property in interface ObjectBuilder<T>key - the keypublic T build()
Builds a new NutDao thanks to the current state
of this builder.
If the NutDao could not be built, then an IllegalArgumentException
should be thrown.
build in interface ObjectBuilder<T>NutDaoprotected abstract T internalBuild()
Builds internally an object as specified by ObjectBuilder.build() without
catching any exception.
protected final void throwPropertyNotSupportedException(String key)
Throws a particular IllegalArgumentException because a not supported property has been tried
to be set.
key - the property keyCopyright © 2012-2015. All Rights Reserved.