Class InPlaceIfCommand<I extends VariableDeclaration>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Expression
-
- net.ssehub.easy.instantiation.core.model.expressions.InPlaceCommand<I>
-
- net.ssehub.easy.instantiation.core.model.expressions.InPlaceIfCommand<I>
-
- Type Parameters:
I- the variable declaration type
public class InPlaceIfCommand<I extends VariableDeclaration> extends InPlaceCommand<I>
Replaces an in-place if-command/expression within a string/content expression.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private Expressionconditionprivate java.util.List<Expression>curExprivate java.util.List<Expression>elseExprivate java.util.List<Expression>thenEx
-
Constructor Summary
Constructors Constructor Description InPlaceIfCommand(Expression condition)Creates an in-place alternative.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadvanceState()Changes among different states of sub-structures, e.g., then-part and else-part.protected voidappend(java.util.List<Expression> exprs)Appends the sub-expressions in parse sequence toexprsleaving out this command as fallback.protected voidappend(Expression ex)Appends a sub-expression.protected Expressionclose(IStringParserFactory<I> factory)Closes this in-place command by creating the real expression.ExpressiongetCondition()Returns the condition expression.java.util.List<Expression>getElseExpressions()Returns the else expressions.java.util.List<Expression>getThenExpressions()Returns the then expressions.protected voidreplace(InPlaceCommand<I> cmd, Expression expr)Replacescmdbyexpr.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.InPlaceCommand
accept, holdsResolverLevel, inferType, replace
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.Expression
replaceEmptyLine
-
-
-
-
Field Detail
-
condition
private Expression condition
-
thenEx
private java.util.List<Expression> thenEx
-
elseEx
private java.util.List<Expression> elseEx
-
curEx
private transient java.util.List<Expression> curEx
-
-
Constructor Detail
-
InPlaceIfCommand
InPlaceIfCommand(Expression condition)
Creates an in-place alternative.- Parameters:
condition- the condition of the alternative
-
-
Method Detail
-
getCondition
public Expression getCondition()
Returns the condition expression.- Returns:
- the condition
-
getThenExpressions
public java.util.List<Expression> getThenExpressions()
Returns the then expressions.- Returns:
- the then expressions
-
getElseExpressions
public java.util.List<Expression> getElseExpressions()
Returns the else expressions.- Returns:
- the else expressions, may be null
-
advanceState
protected void advanceState()
Description copied from class:InPlaceCommandChanges among different states of sub-structures, e.g., then-part and else-part. Override if needed, else the respective call is just ignored.- Overrides:
advanceStatein classInPlaceCommand<I extends VariableDeclaration>
-
append
protected void append(Expression ex)
Description copied from class:InPlaceCommandAppends a sub-expression. An in-place command can have multiple sub-structures, that are sequentially switched to active viaInPlaceCommand.advanceState().- Specified by:
appendin classInPlaceCommand<I extends VariableDeclaration>- Parameters:
ex- the expression to append
-
close
protected Expression close(IStringParserFactory<I> factory) throws VilException
Description copied from class:InPlaceCommandCloses this in-place command by creating the real expression.- Specified by:
closein classInPlaceCommand<I extends VariableDeclaration>- Parameters:
factory- the factory used to create the real expression- Returns:
- the real expression, may be null if optional / none shall be created
- Throws:
VilException- if the provided information is not sufficient for creating an expression
-
append
protected void append(java.util.List<Expression> exprs)
Description copied from class:InPlaceCommandAppends the sub-expressions in parse sequence toexprsleaving out this command as fallback.- Specified by:
appendin classInPlaceCommand<I extends VariableDeclaration>- Parameters:
exprs- the expressions to add the sub-expressions to
-
replace
protected void replace(InPlaceCommand<I> cmd, Expression expr)
Description copied from class:InPlaceCommandReplacescmdbyexpr.- Specified by:
replacein classInPlaceCommand<I extends VariableDeclaration>- Parameters:
cmd- the command to be replacedexpr- the replacing expression
-
-