Class Iteration
- java.lang.Object
-
- org.ocpsoft.rewrite.config.DefaultOperationBuilder
-
- org.jboss.windup.config.operation.Iteration
-
- All Implemented Interfaces:
IterationBuilderComplete,IterationBuilderOtherwise,IterationBuilderOver,IterationBuilderPerform,IterationBuilderVar,IterationBuilderWhen,org.ocpsoft.rewrite.config.CompositeOperation,org.ocpsoft.rewrite.config.Operation,org.ocpsoft.rewrite.config.OperationBuilder,org.ocpsoft.rewrite.param.Parameterized
public class Iteration extends org.ocpsoft.rewrite.config.DefaultOperationBuilder implements IterationBuilderVar, IterationBuilderOver, IterationBuilderWhen, IterationBuilderPerform, IterationBuilderOtherwise, IterationBuilderComplete, org.ocpsoft.rewrite.config.CompositeOperation, org.ocpsoft.rewrite.param.Parameterized
Used to iterate over an implicit or explicit variable defined within the correspondingConfigurationRuleBuilder.when(Condition)clause in the current rule.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_SINGLE_VARIABLE_STRINGstatic StringDEFAULT_VARIABLE_LIST_STRING
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IterationBuilderWhenall(org.ocpsoft.rewrite.config.Condition... condition)IterationBuilderVaras(Class<? extends org.jboss.windup.graph.model.WindupVertexFrame> varType, String var)Change the name of the single variable of the given type.IterationBuilderVaras(String var)Change the name of the single variable.IterationBuilderCompleteendIteration()Visual end of the iteration.static <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame>
FRAMETYPEgetCurrentPayload(Variables stack, Class<FRAMETYPE> type, String name)Get theIterationpayload with the given name and type.static <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame>
FRAMETYPEgetCurrentPayload(Variables stack, String name)Get theIterationpayload with the given name.List<org.ocpsoft.rewrite.config.Operation>getOperations()IterationPayloadManagergetPayloadManager()static StringgetPayloadVariableName(GraphRewrite event, org.ocpsoft.rewrite.context.EvaluationContext ctx)Return the currentIterationpayload variable name.Set<String>getRequiredParameterNames()These are really just needed to pass through to the condition, since the visitor system doesn't expect operations to have conditions and wouldn't otherwise find them.FramesSelectorgetSelectionManager()IterationBuilderOtherwiseotherwise(org.ocpsoft.rewrite.config.Operation operation)Perform the givenOperationwhen the conditions set in thisIterationare met.static IterationBuilderOverover()static IterationBuilderOverover(Class<? extends org.jboss.windup.graph.model.WindupVertexFrame> sourceType)Begin anIterationover the selection of the given type, named with the default name.static IterationBuilderOverover(Class<? extends org.jboss.windup.graph.model.WindupVertexFrame> sourceType, String source)Begin anIterationover the named selection of the given type.static IterationBuilderOverover(String source)Begin anIterationover the named selection.voidperform(GraphRewrite event, org.ocpsoft.rewrite.context.EvaluationContext context)Called internally to actually process the Iteration.IterationBuilderPerformperform(org.ocpsoft.rewrite.config.Operation operation)Perform the givenOperationwhen the conditions set in thisIterationare met.IterationBuilderPerformperform(org.ocpsoft.rewrite.config.Operation... operations)Perform the givenOperationinstances when the conditions set in thisIterationare met.voidperform(org.ocpsoft.rewrite.event.Rewrite event, org.ocpsoft.rewrite.context.EvaluationContext context)Called internally to actually process the Iteration.static <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame>
FRAMETYPEremoveCurrentPayload(Variables stack, Class<FRAMETYPE> type, String name)Remove the currentIterationpayload.static <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame>
FRAMETYPEremoveCurrentPayload(Variables stack, String name)Remove the currentIterationpayload.static voidsetCurrentPayload(Variables stack, String name, org.jboss.windup.graph.model.WindupVertexFrame frame)Set the currentIterationpayload.voidsetParameterStore(org.ocpsoft.rewrite.param.ParameterStore store)These are really just needed to pass through to the condition, since the visitor system doesn't expect operations to have conditions and wouldn't otherwise find them.voidsetPayloadManager(IterationPayloadManager payloadManager)static StringsingleVariableIterationName(String selectionName)Calculates the default name for the single variable in the selection with the given name.StringtoString()IterationBuilderWhenwhen(org.ocpsoft.rewrite.config.Condition condition)A condition which decides for each frame whetherIterationBuilderVar.perform(Operation)orotherwise(Operation)will be processed.
-
-
-
Field Detail
-
DEFAULT_VARIABLE_LIST_STRING
public static final String DEFAULT_VARIABLE_LIST_STRING
- See Also:
- Constant Field Values
-
DEFAULT_SINGLE_VARIABLE_STRING
public static final String DEFAULT_SINGLE_VARIABLE_STRING
-
-
Method Detail
-
singleVariableIterationName
public static String singleVariableIterationName(String selectionName)
Calculates the default name for the single variable in the selection with the given name.
-
over
public static IterationBuilderOver over(Class<? extends org.jboss.windup.graph.model.WindupVertexFrame> sourceType, String source)
Begin anIterationover the named selection of the given type. Also sets the name and type of the variable for this iteration's "current element". The type serves for automatic type check.
-
over
public static IterationBuilderOver over(String source)
Begin anIterationover the named selection. Also sets the name of the variable for this iteration's "current element".
-
over
public static IterationBuilderOver over(Class<? extends org.jboss.windup.graph.model.WindupVertexFrame> sourceType)
Begin anIterationover the selection of the given type, named with the default name. Also sets the name of the variable for this iteration's "current element" to have the default value.
-
over
public static IterationBuilderOver over()
-
getRequiredParameterNames
public Set<String> getRequiredParameterNames()
These are really just needed to pass through to the condition, since the visitor system doesn't expect operations to have conditions and wouldn't otherwise find them.- Specified by:
getRequiredParameterNamesin interfaceorg.ocpsoft.rewrite.param.Parameterized
-
setParameterStore
public void setParameterStore(org.ocpsoft.rewrite.param.ParameterStore store)
These are really just needed to pass through to the condition, since the visitor system doesn't expect operations to have conditions and wouldn't otherwise find them.- Specified by:
setParameterStorein interfaceorg.ocpsoft.rewrite.param.Parameterized
-
as
public IterationBuilderVar as(Class<? extends org.jboss.windup.graph.model.WindupVertexFrame> varType, String var)
Change the name of the single variable of the given type. If this method is not called, the name is calculated using thesingleVariableIterationName(String)method.- Specified by:
asin interfaceIterationBuilderOver
-
as
public IterationBuilderVar as(String var)
Change the name of the single variable. If this method is not called, the name is calculated using thesingleVariableIterationName(String)method.- Specified by:
asin interfaceIterationBuilderOver
-
all
public IterationBuilderWhen all(org.ocpsoft.rewrite.config.Condition... condition)
-
when
public IterationBuilderWhen when(org.ocpsoft.rewrite.config.Condition condition)
Description copied from interface:IterationBuilderVarA condition which decides for each frame whetherIterationBuilderVar.perform(Operation)orotherwise(Operation)will be processed.- Specified by:
whenin interfaceIterationBuilderVar
-
perform
public IterationBuilderPerform perform(org.ocpsoft.rewrite.config.Operation operation)
Description copied from interface:IterationBuilderVarPerform the givenOperationwhen the conditions set in thisIterationare met.- Specified by:
performin interfaceIterationBuilderVar- Specified by:
performin interfaceIterationBuilderWhen
-
perform
public IterationBuilderPerform perform(org.ocpsoft.rewrite.config.Operation... operations)
Description copied from interface:IterationBuilderVarPerform the givenOperationinstances when the conditions set in thisIterationare met.- Specified by:
performin interfaceIterationBuilderVar
-
otherwise
public IterationBuilderOtherwise otherwise(org.ocpsoft.rewrite.config.Operation operation)
Description copied from interface:IterationBuilderPerformPerform the givenOperationwhen the conditions set in thisIterationare met.- Specified by:
otherwisein interfaceIterationBuilderPerform
-
endIteration
public IterationBuilderComplete endIteration()
Visual end of the iteration.- Specified by:
endIterationin interfaceIterationBuilderOtherwise- Specified by:
endIterationin interfaceIterationBuilderPerform
-
perform
public void perform(org.ocpsoft.rewrite.event.Rewrite event, org.ocpsoft.rewrite.context.EvaluationContext context)Called internally to actually process the Iteration.- Specified by:
performin interfaceorg.ocpsoft.rewrite.config.Operation
-
perform
public void perform(GraphRewrite event, org.ocpsoft.rewrite.context.EvaluationContext context)
Called internally to actually process the Iteration. Loops over the frames to iterate, and performs their .perform( ... ) or .otherwise( ... ) parts.
-
getOperations
public List<org.ocpsoft.rewrite.config.Operation> getOperations()
- Specified by:
getOperationsin interfaceorg.ocpsoft.rewrite.config.CompositeOperation
-
getPayloadVariableName
public static String getPayloadVariableName(GraphRewrite event, org.ocpsoft.rewrite.context.EvaluationContext ctx) throws IllegalStateException
Return the currentIterationpayload variable name.- Throws:
IllegalStateException- if there is more than one variable in theVariablesstack, and the payload name cannot be determined.
-
setCurrentPayload
public static void setCurrentPayload(Variables stack, String name, org.jboss.windup.graph.model.WindupVertexFrame frame) throws IllegalArgumentException
Set the currentIterationpayload.- Throws:
IllegalArgumentException
-
getCurrentPayload
public static <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame> FRAMETYPE getCurrentPayload(Variables stack, String name) throws IllegalStateException, IllegalArgumentException
Get theIterationpayload with the given name.- Throws:
IllegalArgumentException- if the given variable refers to a non-payload.IllegalStateException
-
getCurrentPayload
public static <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame> FRAMETYPE getCurrentPayload(Variables stack, Class<FRAMETYPE> type, String name) throws IllegalStateException, IllegalArgumentException
Get theIterationpayload with the given name and type.- Throws:
IllegalArgumentException- if the given variable refers to a non-payload.IllegalStateException
-
removeCurrentPayload
public static <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame> FRAMETYPE removeCurrentPayload(Variables stack, Class<FRAMETYPE> type, String name) throws IllegalStateException, IllegalTypeArgumentException
Remove the currentIterationpayload.
-
removeCurrentPayload
public static <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame> FRAMETYPE removeCurrentPayload(Variables stack, String name) throws IllegalStateException, IllegalTypeArgumentException
Remove the currentIterationpayload.
-
setPayloadManager
public void setPayloadManager(IterationPayloadManager payloadManager)
-
getSelectionManager
public FramesSelector getSelectionManager()
-
getPayloadManager
public IterationPayloadManager getPayloadManager()
-
-