Class AbstractConfiguredAnnotationBuilder<O,I,B extends AnnotationBuilder<O>>
java.lang.Object
org.springframework.statemachine.config.common.annotation.AbstractAnnotationBuilder<O>
org.springframework.statemachine.config.common.annotation.AbstractConfiguredAnnotationBuilder<O,I,B>
- Type Parameters:
O
- The object that this builder returnsI
- The interface of type BB
- The type of this builder (that is returned by the base class)
- All Implemented Interfaces:
AnnotationBuilder<O>
- Direct Known Subclasses:
StateMachineConfigBuilder
,StateMachineConfigurationBuilder
,StateMachineModelBuilder
,StateMachineStateBuilder
,StateMachineTransitionBuilder
public abstract class AbstractConfiguredAnnotationBuilder<O,I,B extends AnnotationBuilder<O>>
extends AbstractAnnotationBuilder<O>
A base
AnnotationBuilder
that allows AnnotationConfigurer
s to be
applied to it. This makes modifying the AnnotationBuilder
a strategy
that can be customised and broken up into a number of
AnnotationConfigurer
objects that have more specific goals than that
of the AnnotationBuilder
.
- Author:
- Rob Winch, Janne Valkealahti
-
Constructor Summary
ModifierConstructorDescriptionprotected
Instantiates a new annotation builder.protected
AbstractConfiguredAnnotationBuilder
(ObjectPostProcessor<Object> objectPostProcessor) Instantiates a new annotation builder.protected
AbstractConfiguredAnnotationBuilder
(ObjectPostProcessor<Object> objectPostProcessor, boolean allowConfigurersOfSameType) Instantiates a new annotation builder. -
Method Summary
Modifier and TypeMethodDescription<C extends AnnotationConfigurerAdapter<O,
I, B>>
Capply
(C configurer) Applies aAnnotationConfigurerAdapter
to thisAnnotationBuilder
and invokesAnnotationConfigurerAdapter.setBuilder(AnnotationBuilder)
.protected void
Invoked prior to invoking each mainAnnotationConfigurer.configure(AnnotationBuilder)
method.protected void
Invoked prior to invoking each postAnnotationConfigurer.configure(AnnotationBuilder)
method.protected void
Invoked prior to invoking eachAnnotationConfigurer.init(AnnotationBuilder)
method.protected final O
doBuild()
Subclasses should implement this to perform the build.<C extends AnnotationConfigurer<O,
B>>
CgetConfigurer
(Class<C> clazz) Gets theAnnotationConfigurer
by its class name ornull
if not found.<C extends AnnotationConfigurer<O,
B>>
List<C>getConfigurers
(Class<C> clazz) Gets all theAnnotationConfigurer
instances by its class name or an empty List if not found.<C extends AnnotationConfigurerAdapter<O,
I, B>>
CgetOrApply
(C configurer) Similar toapply(AnnotationConfigurer)
but checks the state to determine ifapply(AnnotationConfigurer)
needs to be called first.Similar toAbstractAnnotationBuilder.build()
andAbstractAnnotationBuilder.getObject()
but checks the state to determine ifAbstractAnnotationBuilder.build()
needs to be called first.<C> C
getSharedObject
(Class<C> sharedType) Gets a shared Object.Gets the shared objects.objectPostProcessor
(ObjectPostProcessor<Object> objectPostProcessor) Specifies theObjectPostProcessor
to use.protected abstract O
Subclasses must implement this method to build the object that is being returned.protected <P> P
postProcess
(P object) Performs post processing of an object.<C extends AnnotationConfigurer<O,
B>>
CremoveConfigurer
(Class<C> clazz) Removes and returns theAnnotationConfigurer
by its class name ornull
if not found.<C extends AnnotationConfigurer<O,
B>>
List<C>removeConfigurers
(Class<C> clazz) Removes all theAnnotationConfigurer
instances by its class name or an empty List if not found.<C> void
setSharedObject
(Class<C> sharedType, C object) Sets an object that is shared by multipleAnnotationConfigurer
.Methods inherited from class org.springframework.statemachine.config.common.annotation.AbstractAnnotationBuilder
build, getObject
-
Constructor Details
-
AbstractConfiguredAnnotationBuilder
protected AbstractConfiguredAnnotationBuilder()Instantiates a new annotation builder. -
AbstractConfiguredAnnotationBuilder
Instantiates a new annotation builder.- Parameters:
objectPostProcessor
- the object post processor
-
AbstractConfiguredAnnotationBuilder
protected AbstractConfiguredAnnotationBuilder(ObjectPostProcessor<Object> objectPostProcessor, boolean allowConfigurersOfSameType) Instantiates a new annotation builder.- Parameters:
objectPostProcessor
- the object post processorallowConfigurersOfSameType
- the allow configurers of same type
-
-
Method Details
-
doBuild
Description copied from class:AbstractAnnotationBuilder
Subclasses should implement this to perform the build.- Specified by:
doBuild
in classAbstractAnnotationBuilder<O>
- Returns:
- the object that should be returned by
AbstractAnnotationBuilder.build()
. - Throws:
Exception
- if an error occurs
-
getOrBuild
Similar toAbstractAnnotationBuilder.build()
andAbstractAnnotationBuilder.getObject()
but checks the state to determine ifAbstractAnnotationBuilder.build()
needs to be called first.- Returns:
- the result of
AbstractAnnotationBuilder.build()
orAbstractAnnotationBuilder.getObject()
. If an error occurs while building, returns null.
-
apply
Applies aAnnotationConfigurerAdapter
to thisAnnotationBuilder
and invokesAnnotationConfigurerAdapter.setBuilder(AnnotationBuilder)
.- Type Parameters:
C
- type of AnnotationConfigurer- Parameters:
configurer
- the configurer- Returns:
- Configurer passed as parameter
- Throws:
Exception
- if error occurred
-
getOrApply
Similar toapply(AnnotationConfigurer)
but checks the state to determine ifapply(AnnotationConfigurer)
needs to be called first.- Type Parameters:
C
- type of AnnotationConfigurer- Parameters:
configurer
- the configurer- Returns:
- Configurer passed as parameter
- Throws:
Exception
- if error occurred
-
apply
Applies aAnnotationConfigurer
to thisAnnotationBuilder
overriding anyAnnotationConfigurer
of the exact same class. Note that object hierarchies are not considered.- Type Parameters:
C
- type of AnnotationConfigurer- Parameters:
configurer
- the configurer- Returns:
- Configurer passed as parameter
- Throws:
Exception
- if error occurred
-
getConfigurers
Gets all theAnnotationConfigurer
instances by its class name or an empty List if not found. Note that object hierarchies are not considered.- Type Parameters:
C
- type of AnnotationConfigurer- Parameters:
clazz
- theAnnotationConfigurer
class to look for- Returns:
- All configurers
-
removeConfigurers
Removes all theAnnotationConfigurer
instances by its class name or an empty List if not found. Note that object hierarchies are not considered.- Type Parameters:
C
- type of AnnotationConfigurer- Parameters:
clazz
- theAnnotationConfigurer
class to look for- Returns:
- Empty list of configurers
-
getConfigurer
Gets theAnnotationConfigurer
by its class name ornull
if not found. Note that object hierarchies are not considered.- Type Parameters:
C
- type of AnnotationConfigurer- Parameters:
clazz
- the configurer class type- Returns:
- Matched configurers
-
removeConfigurer
Removes and returns theAnnotationConfigurer
by its class name ornull
if not found. Note that object hierarchies are not considered.- Type Parameters:
C
- type of AnnotationConfigurer- Parameters:
clazz
- the configurer class type- Returns:
- Matched configurers
-
objectPostProcessor
Specifies theObjectPostProcessor
to use.- Parameters:
objectPostProcessor
- theObjectPostProcessor
to use. Cannot be null- Returns:
- the
AnnotationBuilder
for further customizations
-
postProcess
protected <P> P postProcess(P object) Performs post processing of an object. The default is to delegate to theObjectPostProcessor
.- Type Parameters:
P
- type of processed object- Parameters:
object
- the Object to post process- Returns:
- the possibly modified Object to use
-
beforeInit
Invoked prior to invoking eachAnnotationConfigurer.init(AnnotationBuilder)
method. Subclasses may override this method to hook into the lifecycle without using aAnnotationConfigurer
.- Throws:
Exception
- if error occurred
-
beforeConfigureMains
Invoked prior to invoking each mainAnnotationConfigurer.configure(AnnotationBuilder)
method. Subclasses may override this method to hook into the lifecycle without using aAnnotationConfigurer
.- Throws:
Exception
- if error occurred
-
beforeConfigurePosts
Invoked prior to invoking each postAnnotationConfigurer.configure(AnnotationBuilder)
method. Subclasses may override this method to hook into the lifecycle without using aAnnotationConfigurer
.- Throws:
Exception
- if error occurred
-
performBuild
Subclasses must implement this method to build the object that is being returned.- Returns:
- Object build by this builder
- Throws:
Exception
- if error occurred
-