类 AbstractConfiguredBuilder<O,B extends ConfigurableBuilder<O,B>>
- java.lang.Object
-
- cn.sliew.milky.dsl.AbstractBuilder<O>
-
- cn.sliew.milky.dsl.AbstractConfiguredBuilder<O,B>
-
- 类型参数:
O- The object that this builder returnsB- The type of this builder (that is returned by the base class)
- 所有已实现的接口:
Builder<O>,ConfigurableBuilder<O,B>
public abstract class AbstractConfiguredBuilder<O,B extends ConfigurableBuilder<O,B>> extends AbstractBuilder<O> implements ConfigurableBuilder<O,B>
A base
Builderthat allowsConfigurerto be applied to it. This makes modifying theBuildera strategy that can be customized and broken up into a number ofConfigurerobjects that have more specific goals than that of theBuilder.
-
-
构造器概要
构造器 构造器 说明 AbstractConfiguredBuilder()
-
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 <C extends AbstractConfigurer<O,B>>
Capply(C configurer)protected voidbeforeConfigure()Invoked prior to invoking eachConfigurer.configure(Builder)method.protected voidbeforeInit()Invoked prior to invoking eachConfigurer.init(Builder)method.protected OdoBuild()Executes the build using theConfigurer's that have been applied using the following steps: InvokesbeforeInit()for any subclass to hook into InvokesConfigurer.init(Builder)for anyConfigurerthat was applied to this builder. InvokesbeforeConfigure()for any subclass to hook into InvokesperformBuild()which actually builds the Object<C extends Configurer<O,B>>
CgetConfigurer(Class<C> clazz)Gets theConfigurerby its class name ornullif not found.OgetOrBuild()Similar toAbstractBuilder.build()andAbstractBuilder.getObject()but checks the state to determine ifAbstractBuilder.build()needs to be called first.protected abstract OperformBuild()Subclasses must implement this method to build the object that is being returned.<C extends Configurer<O,B>>
CremoveConfigurer(Class<C> clazz)Removes and returns theConfigurerby its class name ornullif not found.-
从类继承的方法 cn.sliew.milky.dsl.AbstractBuilder
build, getObject
-
-
-
-
方法详细资料
-
getOrBuild
public O getOrBuild()
Similar toAbstractBuilder.build()andAbstractBuilder.getObject()but checks the state to determine ifAbstractBuilder.build()needs to be called first.- 返回:
- the result of
AbstractBuilder.build()orAbstractBuilder.getObject(). If an error occurs while building, returns null.
-
doBuild
protected final O doBuild() throws Exception
Executes the build using theConfigurer's that have been applied using the following steps:- Invokes
beforeInit()for any subclass to hook into - Invokes
Configurer.init(Builder)for anyConfigurerthat was applied to this builder. - Invokes
beforeConfigure()for any subclass to hook into - Invokes
performBuild()which actually builds the Object
- 指定者:
doBuild在类中AbstractBuilder<O>- 返回:
- the object that should be returned by
AbstractBuilder.build(). - 抛出:
Exception- if an error occurs
- Invokes
-
beforeInit
protected void beforeInit() throws ExceptionInvoked prior to invoking eachConfigurer.init(Builder)method. Subclasses may override this method to hook into the lifecycle without using aConfigurer.- 抛出:
Exception
-
beforeConfigure
protected void beforeConfigure() throws ExceptionInvoked prior to invoking eachConfigurer.configure(Builder)method. Subclasses may override this method to hook into the lifecycle without using aConfigurer.- 抛出:
Exception
-
performBuild
protected abstract O performBuild() throws Exception
Subclasses must implement this method to build the object that is being returned.- 返回:
- the Object to be buit or null if the implementation allows it
- 抛出:
Exception
-
apply
public <C extends AbstractConfigurer<O,B>> C apply(C configurer) throws Exception
- 参数:
configurer-- 返回:
- the
AbstractConfigurerfor further customizations - 抛出:
Exception
-
apply
public <C extends Configurer<O,B>> C apply(C configurer) throws Exception
Applies aConfigurerto thisBuilderoverriding anyConfigurerof the exact same class. Note that object hierarchies are not considered.- 参数:
configurer-- 返回:
- the
AbstractConfigurerfor further customizations - 抛出:
Exception
-
getConfigurer
public <C extends Configurer<O,B>> C getConfigurer(Class<C> clazz)
Gets theConfigurerby its class name ornullif not found. Note that object hierarchies are not considered.- 指定者:
getConfigurer在接口中ConfigurableBuilder<O,B extends ConfigurableBuilder<O,B>>- 参数:
clazz-- 返回:
- the
Configurerfor further customizations
-
removeConfigurer
public <C extends Configurer<O,B>> C removeConfigurer(Class<C> clazz)
Removes and returns theConfigurerby its class name ornullif not found. Note that object hierarchies are not considered.- 指定者:
removeConfigurer在接口中ConfigurableBuilder<O,B extends ConfigurableBuilder<O,B>>- 参数:
clazz-- 返回:
-
-