Class DefaultHandlerStrategy
java.lang.Object
org.camunda.community.bpmndt.strategy.DefaultStrategy
org.camunda.community.bpmndt.strategy.DefaultHandlerStrategy
- All Implemented Interfaces:
GeneratorStrategy
- Direct Known Subclasses:
CallActivityStrategy,EventStrategy,ExternalTaskClientStrategy,ExternalTaskStrategy,JobStrategy,MultiInstanceScopeStrategy,ReceiveTaskStrategy,UserTaskStrategy
Default strategy for all handled activities, that provide a fluent handler API.
-
Field Summary
Fields inherited from class org.camunda.community.bpmndt.strategy.DefaultStrategy
activity, literal, multiInstanceParentFields inherited from interface org.camunda.community.bpmndt.GeneratorStrategy
CALL_ACTIVITY, EVENT, EXTERNAL_TASK, EXTERNAL_TASK_CLIENT, JOB, OTHER, RECEIVE_TASK, USER_TASK -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHandlerField(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a handler field to the class, if the activity is handled by a handler - e.g.:voidaddHandlerMethod(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a "handle" method to the class, if the activity is handled by a handler - e.g.:voidapplyHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code to the execute/apply method, if the activity is handled by a handler and a wait state - e.g.:protected com.squareup.javapoet.CodeBlockcom.squareup.javapoet.CodeBlockReturns code for getting a handler field reference.voidinitHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which initializes a handler field.com.squareup.javapoet.CodeBlockReturns the statement that initializes the handler.Methods inherited from class org.camunda.community.bpmndt.strategy.DefaultStrategy
addHandlerFieldAfter, addHandlerFieldBefore, addHandlerMethodAfter, addHandlerMethodBefore, applyHandlerAfter, applyHandlerBefore, buildHandlerMethodName, equals, getActivity, getHandlerAfter, getHandlerBefore, getHandlerType, getLiteral, getLiteralAfter, getLiteralBefore, hashCode, hasPassed, initHandlerAfter, initHandlerAfterStatement, initHandlerBefore, initHandlerBeforeStatement, isWaitingAt, setMultiInstanceParent, shouldHandleAfter, shouldHandleBefore
-
Constructor Details
-
DefaultHandlerStrategy
-
-
Method Details
-
addHandlerField
public void addHandlerField(com.squareup.javapoet.TypeSpec.Builder classBuilder) Description copied from interface:GeneratorStrategyAdds a handler field to the class, if the activity is handled by a handler - e.g.:private UserTaskHandler approveUserTask;
Otherwise, no field is added.
- Specified by:
addHandlerFieldin interfaceGeneratorStrategy- Overrides:
addHandlerFieldin classDefaultStrategy- Parameters:
classBuilder- The class builder to use.
-
addHandlerMethod
public void addHandlerMethod(com.squareup.javapoet.TypeSpec.Builder classBuilder) Description copied from interface:GeneratorStrategyAdds a "handle" method to the class, if the activity is handled by a handler - e.g.:public UserTaskHandler handleApproveUserTask() { return approveUserTask; }Otherwise, no field is added.
- Specified by:
addHandlerMethodin interfaceGeneratorStrategy- Overrides:
addHandlerMethodin classDefaultStrategy- Parameters:
classBuilder- The class builder to use.
-
buildHandlerMethodJavadoc
protected com.squareup.javapoet.CodeBlock buildHandlerMethodJavadoc() -
applyHandler
public void applyHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code to the execute/apply method, if the activity is handled by a handler and a wait state - e.g.:assertThat(pi).isWaitingAt("placeOrderExternalTask"); instance.apply(placeOrderExternalTask)or the previous activity is an event based gateway.
- Specified by:
applyHandlerin interfaceGeneratorStrategy- Overrides:
applyHandlerin classDefaultStrategy- Parameters:
methodBuilder- The method builder to use.
-
getHandler
public com.squareup.javapoet.CodeBlock getHandler()Description copied from interface:GeneratorStrategyReturns code for getting a handler field reference. Normally a handler field is referenced usingTestCaseActivity.getId()as literal, but in case of a multi instance scope a specificgetHandlermethod must be called.
Normally:
approveUserTask
Multi instance scope:
getApproveUserTaskHandler(loopIndex)
- Specified by:
getHandlerin interfaceGeneratorStrategy- Overrides:
getHandlerin classDefaultStrategy- Returns:
- The handler reference code.
-
initHandler
public void initHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code, which initializes a handler field.approveUserTask = new UserTaskHandler(getProcessEngine(), "approveUserTask");
- Specified by:
initHandlerin interfaceGeneratorStrategy- Overrides:
initHandlerin classDefaultStrategy- Parameters:
methodBuilder- The method builder to use.- See Also:
-
initHandlerStatement
public com.squareup.javapoet.CodeBlock initHandlerStatement()Description copied from interface:GeneratorStrategyReturns the statement that initializes the handler.new UserTaskHandler(getProcessEngine(), "approveUserTask");
- Specified by:
initHandlerStatementin interfaceGeneratorStrategy- Overrides:
initHandlerStatementin classDefaultStrategy- Returns:
- The code.
-