public abstract class AbstractBuilder extends Object implements Builder
Modifier and Type | Class and Description |
---|---|
static class |
AbstractBuilder.BuilderElement
A temporary Element to stand in for a element being constructed with a
builder.
|
Modifier and Type | Field and Description |
---|---|
protected static boolean |
ASSERTIONS_ENABLED
If true then assertions have been enabled for the class.
|
protected static Class<AbstractBuilder.BuilderElement> |
BUILDER_ELEMENT_CLASS
The class used for intermediate sub-builders in the elements list.
|
protected List<Element> |
myElements
The list of elements in the builder.
|
Constructor and Description |
---|
AbstractBuilder(AbstractBuilder outerBuilder)
Creates a new builder.
|
Modifier and Type | Method and Description |
---|---|
protected abstract Element |
build(String name)
Constructs the final form of the element being constructed.
|
protected Element |
coerse(String name,
Object value)
Performs type coersion on the value into the best possible element type.
|
protected DocumentBuilder |
doPush(String name)
Pushes a context for constructing a sub-document.
|
protected ArrayBuilder |
doPushArray(String name)
Pushes a context for constructing a sub-array.
|
Builder |
pop()
Pops the sub-context.
|
Builder |
reset()
Resets the builder back to an empty state.
|
protected List<Element> |
subElements()
Renders the final form of the sub elements in the builder replacing all
AbstractBuilder.BuilderElement s with the final element form. |
protected static final boolean ASSERTIONS_ENABLED
protected static final Class<AbstractBuilder.BuilderElement> BUILDER_ELEMENT_CLASS
public AbstractBuilder(AbstractBuilder outerBuilder)
outerBuilder
- The outer scoped builder.public Builder pop()
public Builder reset()
protected abstract Element build(String name)
name
- The name of the element.protected Element coerse(String name, Object value) throws IllegalArgumentException
IllegalArgumentException
is thrown.
This method does type inspection which can be slow. It is generally much faster to use the type specific methods of this interface.
name
- The name for the element to create.value
- The Object value to coerce into an element.Element
resulting from the coersion.IllegalArgumentException
- If the value
cannot be coerced into an element type.protected DocumentBuilder doPush(String name)
name
- The name of the sub-document.DocumentBuilder
for constructing the sub-document.protected ArrayBuilder doPushArray(String name)
name
- The name of the sub-array.ArrayBuilder
for constructing the sub-array.protected List<Element> subElements()
AbstractBuilder.BuilderElement
s with the final element form.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.