Class ConstantExpression
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Expression
-
- net.ssehub.easy.instantiation.core.model.expressions.ConstantExpression
-
public class ConstantExpression extends Expression
Represents a parenthesis expression.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private TypeDescriptor<?>typeprivate java.lang.Objectvalue
-
Constructor Summary
Constructors Constructor Description ConstantExpression()Constructor for serialization.ConstantExpression(TypeDescriptor<?> type, java.lang.Object value, TypeRegistry registry)Creates a new constant expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IExpressionVisitor visitor)Visits the expression.private booleancheckAndConvert(TypeDescriptor<?> checkFor)Checks the given type for compatibility withvalueand converts value if necessary and possible.TypeDescriptor<?>getType()Returns the type of this expression.java.lang.ObjectgetValue()Returns the value of this expression.TypeDescriptor<?>inferType()Infers the type of this expression including the type of the contained sub-expressions.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.Expression
replaceEmptyLine
-
-
-
-
Field Detail
-
value
private java.lang.Object value
-
type
private TypeDescriptor<?> type
-
-
Constructor Detail
-
ConstantExpression
ConstantExpression()
Constructor for serialization.
-
ConstantExpression
public ConstantExpression(TypeDescriptor<?> type, java.lang.Object value, TypeRegistry registry) throws VilException
Creates a new constant expression.- Parameters:
type- the type of this constantvalue- the assigned value of this constantregistry- the type registry to resolve (local) types- Throws:
VilException- in case of type incompatibilities
-
-
Method Detail
-
checkAndConvert
private boolean checkAndConvert(TypeDescriptor<?> checkFor)
Checks the given type for compatibility withvalueand converts value if necessary and possible.
-
getValue
public java.lang.Object getValue()
Returns the value of this expression. Value complies togetType().- Returns:
- the expression
-
getType
public TypeDescriptor<?> getType()
Returns the type of this expression.- Returns:
- the type
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Description copied from class:ExpressionInfers the type of this expression including the type of the contained sub-expressions.- Specified by:
inferTypein classExpression- Returns:
- the type of this expression
- Throws:
VilException- in case that inferring the type fails
-
accept
public java.lang.Object accept(IExpressionVisitor visitor) throws VilException
Description copied from class:ExpressionVisits the expression.- Specified by:
acceptin classExpression- Parameters:
visitor- the visitor- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
-