O - The object that this builder returnsB - The type of this builder (that is returned by the base class)public abstract class AbstractConfiguredBuilder<O,B extends ConfigurableBuilder<O,B>> extends AbstractBuilder<O> implements ConfigurableBuilder<O,B>
A base Builder that allows Configurer to be applied to
it. This makes modifying the Builder a strategy that can be customized
and broken up into a number of Configurer objects that have more
specific goals than that of the Builder.
| Constructor and Description |
|---|
AbstractConfiguredBuilder() |
| Modifier and Type | Method and Description |
|---|---|
<C extends AbstractConfigurer<O,B>> |
apply(C configurer)
|
<C extends Configurer<O,B>> |
apply(C configurer)
|
protected void |
beforeConfigure()
Invoked prior to invoking each
Configurer.configure(Builder) method. |
protected void |
beforeInit()
Invoked prior to invoking each
Configurer.init(Builder)
method. |
protected O |
doBuild()
Executes the build using the
Configurer's that have been applied
using the following steps:
Invokes beforeInit() for any subclass to hook into
Invokes Configurer.init(Builder) for any
Configurer that was applied to this builder.
Invokes beforeConfigure() for any subclass to hook into
Invokes performBuild() which actually builds the Object
|
<C extends Configurer<O,B>> |
getConfigurer(Class<C> clazz)
Gets the
Configurer by its class name or null if not
found. |
O |
getOrBuild()
Similar to
AbstractBuilder.build() and AbstractBuilder.getObject() but checks the state to
determine if AbstractBuilder.build() needs to be called first. |
protected abstract O |
performBuild()
Subclasses must implement this method to build the object that is being returned.
|
<C extends Configurer<O,B>> |
removeConfigurer(Class<C> clazz)
Removes and returns the
Configurer by its class name or
null if not found. |
build, getObjectpublic O getOrBuild()
AbstractBuilder.build() and AbstractBuilder.getObject() but checks the state to
determine if AbstractBuilder.build() needs to be called first.AbstractBuilder.build() or AbstractBuilder.getObject(). If an error occurs
while building, returns null.protected final O doBuild() throws Exception
Configurer's that have been applied
using the following steps:
beforeInit() for any subclass to hook intoConfigurer.init(Builder) for any
Configurer that was applied to this builder.beforeConfigure() for any subclass to hook intoperformBuild() which actually builds the ObjectdoBuild in class AbstractBuilder<O>AbstractBuilder.build().Exception - if an error occursprotected void beforeInit()
throws Exception
Configurer.init(Builder)
method. Subclasses may override this method to hook into the lifecycle without
using a Configurer.Exceptionprotected void beforeConfigure()
throws Exception
Configurer.configure(Builder) method. Subclasses may
override this method to hook into the lifecycle without using a
Configurer.Exceptionprotected abstract O performBuild() throws Exception
Exceptionpublic <C extends AbstractConfigurer<O,B>> C apply(C configurer) throws Exception
configurer - AbstractConfigurer for further customizationsExceptionpublic <C extends Configurer<O,B>> C apply(C configurer) throws Exception
Configurer to this Builder overriding any
Configurer of the exact same class. Note that object hierarchies
are not considered.configurer - AbstractConfigurer for further customizationsExceptionpublic <C extends Configurer<O,B>> C getConfigurer(Class<C> clazz)
Configurer by its class name or null if not
found. Note that object hierarchies are not considered.getConfigurer in interface ConfigurableBuilder<O,B extends ConfigurableBuilder<O,B>>clazz - Configurer for further customizationspublic <C extends Configurer<O,B>> C removeConfigurer(Class<C> clazz)
Configurer by its class name or
null if not found. Note that object hierarchies are not considered.removeConfigurer in interface ConfigurableBuilder<O,B extends ConfigurableBuilder<O,B>>clazz - Copyright © 2022. All rights reserved.