Package org.jboss.windup.config
Class Variables
- java.lang.Object
-
- org.jboss.windup.config.Variables
-
@Vetoed public class Variables extends Object
A variables stack - keeps few layers of "key"->[vertices] maps, one per rule execution level,IterationandRuleSubset.- Author:
- Lincoln Baxter, III
-
-
Field Summary
Fields Modifier and Type Field Description static intSEARCH_ALL_LAYERS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame>
FRAMETYPEfindSingletonVariable(Class<FRAMETYPE> type, String name)Type-safe wrapper aroundfindVariable(String)returns a uniqueWindupVertexFrame.<T extends org.jboss.windup.graph.model.WindupVertexFrame>
TfindSingletonVariable(String name)Wrapper aroundfindVariable(String)which gives only one framed vertex, and checks if there is 0 or 1; throws otherwise.Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame>findVariable(String name)Searches the variables layers, top to bottom, for given name, and returns if found; null otherwise.Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame>findVariable(String name, int maxDepth)Searches the variables layers, top to bottom, for given name, and returns if found; null otherwise.<T extends org.jboss.windup.graph.model.WindupVertexFrame>
Iterable<T>findVariableOfType(Class<T> type)Searches the variables layers, top to bottom, for the iterable having all of it's items of the given type.static Variablesinstance(GraphRewrite event)Get an instance of theVariablesstack from the givenGraphRewriteevent context.Map<String,Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame>>peek()Get the topVariableslayer from the stack.Map<String,Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame>>pop()Remove the topVariableslayer from the the stack.voidpush()Add newVariableslayer on top of the stack.voidpush(Map<String,Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame>> frame)Push the givenVariableslayer on top of the stack.voidremoveVariable(String name)Remove a variable in the top variables layer.voidsetSingletonVariable(String name, org.jboss.windup.graph.model.WindupVertexFrame frame)Type-safe wrapper around setVariable which sets only one framed vertex.voidsetVariable(String name, Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame> frames)Set a variable in the top variables layer to given "collection" of the vertex frames.StringtoString()
-
-
-
Method Detail
-
instance
public static Variables instance(GraphRewrite event)
Get an instance of theVariablesstack from the givenGraphRewriteevent context.
-
push
public void push()
Add newVariableslayer on top of the stack.
-
push
public void push(Map<String,Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame>> frame)
Push the givenVariableslayer on top of the stack.
-
pop
public Map<String,Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame>> pop()
Remove the topVariableslayer from the the stack.
-
peek
public Map<String,Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame>> peek()
Get the topVariableslayer from the stack.
-
setSingletonVariable
public void setSingletonVariable(String name, org.jboss.windup.graph.model.WindupVertexFrame frame)
Type-safe wrapper around setVariable which sets only one framed vertex.
-
setVariable
public void setVariable(String name, Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame> frames)
Set a variable in the top variables layer to given "collection" of the vertex frames. Can't be reassigned - throws on attempt to reassign.
-
removeVariable
public void removeVariable(String name)
Remove a variable in the top variables layer.
-
findSingletonVariable
public <T extends org.jboss.windup.graph.model.WindupVertexFrame> T findSingletonVariable(String name)
Wrapper aroundfindVariable(String)which gives only one framed vertex, and checks if there is 0 or 1; throws otherwise.
-
findSingletonVariable
public <FRAMETYPE extends org.jboss.windup.graph.model.WindupVertexFrame> FRAMETYPE findSingletonVariable(Class<FRAMETYPE> type, String name)
Type-safe wrapper aroundfindVariable(String)returns a uniqueWindupVertexFrame.- Throws:
IllegalStateException- If more than one frame was found.
-
findVariable
public Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame> findVariable(String name)
Searches the variables layers, top to bottom, for given name, and returns if found; null otherwise.
-
findVariable
public Iterable<? extends org.jboss.windup.graph.model.WindupVertexFrame> findVariable(String name, int maxDepth)
Searches the variables layers, top to bottom, for given name, and returns if found; null otherwise. If maxDepth is set toSEARCH_ALL_LAYERS, then search all layers.
-
findVariableOfType
public <T extends org.jboss.windup.graph.model.WindupVertexFrame> Iterable<T> findVariableOfType(Class<T> type)
Searches the variables layers, top to bottom, for the iterable having all of it's items of the given type. Return null if not found.
-
-