Package cn.sliew.milky.dsl
Class AbstractConfigurer<O,B extends Builder<O>>
- java.lang.Object
-
- cn.sliew.milky.dsl.AbstractConfigurer<O,B>
-
- Type Parameters:
O- The Object being built by BB- The Builder that is building O and is configured byAbstractConfigurer
- All Implemented Interfaces:
Configurer<O,B>
public abstract class AbstractConfigurer<O,B extends Builder<O>> extends Object implements Configurer<O,B>
A base class forConfigurerthat allows subclasses to only implement the methods they are interested in. It also provides a mechanism for using theConfigurerand when done gaining access to theBuilderthat is being configured.
-
-
Constructor Summary
Constructors Constructor Description AbstractConfigurer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Band()Return theBuilderwhen done using theConfigurer.voidconfigure(B builder)protected BgetBuilder()Gets theBuilder.voidinit(B builder)Initialize theBuilder.voidsetBuilder(B builder)Sets theBuilderto be used.
-
-
-
Method Detail
-
init
public void init(B builder) throws Exception
Description copied from interface:ConfigurerInitialize theBuilder. Here only shared state should be created and modified, but not properties on theBuilderused for building the object. This ensures that theConfigurer.configure(Builder)method uses the correct shared objects when building. Configurers should be applied here.
-
configure
public void configure(B builder) throws Exception
Description copied from interface:Configurer
-
and
public B and()
Return theBuilderwhen done using theConfigurer. This is useful for method chaining.- Returns:
- the
Builderfor further customizations
-
getBuilder
protected final B getBuilder()
Gets theBuilder. Cannot be null.- Returns:
- the
Builder - Throws:
IllegalStateException- ifBuilderis null
-
setBuilder
public void setBuilder(B builder)
Sets theBuilderto be used. This is automatically set when usingAbstractConfiguredBuilder.apply(AbstractConfigurer)- Parameters:
builder- theBuilderto set
-
-