Class ConstraintBuilder
- java.lang.Object
-
- jadex.rules.parser.conditions.javagrammar.ConstraintBuilder
-
public class ConstraintBuilder extends java.lang.Object
The constraint builder takes an expression (e.g. from the parser) and generates appropriate constraints and/or conditions for it.
-
-
Constructor Summary
Constructors Constructor Description ConstraintBuilder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static void
buildConstraint(Expression exp, BuildContext context, boolean invert, IParserHelper helper)
Build a constraint for a single expression.static ICondition
buildConstraints(Expression expression, BuildContext context, IParserHelper helper)
Build or adapt conditions for representing the given constraints.protected static void
buildOperatorConstraint(Expression left, Expression right, IOperator op, BuildContext context, IParserHelper helper)
Build an operator constraint.protected static java.util.List
combineValueSources(java.lang.Object valuesource, java.util.List suffs)
Combine (i.e.protected static MethodCall
createMethodCall(OAVJavaType type, java.lang.String name, Expression[] paramvalues, BuildContext context, IParserHelper helper)
Create a method call.protected static Expression
flattenToPrimary(Expression value, BuildContext context, IParserHelper helper)
Flatten a value to a primary value (literal or variable).protected static java.lang.Object
getObjectConditionAndValueSource(Expression value, BuildContext context, IParserHelper helper)
Find or create an object condition for a value and return the appropriate value source.protected static void
shuffle(BuildContext context)
Shuffle conditions and constraints, such that all variables are bound before used.
-
-
-
Method Detail
-
buildConstraints
public static ICondition buildConstraints(Expression expression, BuildContext context, IParserHelper helper)
Build or adapt conditions for representing the given constraints.- Parameters:
expression
- The expression, which contains the constraints to represent.context
- The build context.- Returns:
- The generated condition.
-
buildConstraint
protected static void buildConstraint(Expression exp, BuildContext context, boolean invert, IParserHelper helper)
Build a constraint for a single expression.
-
buildOperatorConstraint
protected static void buildOperatorConstraint(Expression left, Expression right, IOperator op, BuildContext context, IParserHelper helper)
Build an operator constraint.
-
getObjectConditionAndValueSource
protected static java.lang.Object getObjectConditionAndValueSource(Expression value, BuildContext context, IParserHelper helper)
Find or create an object condition for a value and return the appropriate value source. The condition is pushed on the stack of the build context. When the condition is no longer required (e.g. all current constraints added) it has to be popped from the stack (manually).- Parameters:
value
- The value to be obtained.lcons
- The existing conditions.bcons
- The conditions for existing variables.tmodel
- The type model.- Returns:
- The value source.
-
createMethodCall
protected static MethodCall createMethodCall(OAVJavaType type, java.lang.String name, Expression[] paramvalues, BuildContext context, IParserHelper helper)
Create a method call.- Parameters:
type
- The object type.name
- The method name.paramvalues
- The parameter values.context
- The build context.- Returns:
- The method call object.
-
flattenToPrimary
protected static Expression flattenToPrimary(Expression value, BuildContext context, IParserHelper helper)
Flatten a value to a primary value (literal or variable). For a complex expression, additional conditions might be created that bind the desired value in a new variable.- Parameters:
value
- The value to be obtained.lcons
- The existing conditions.bcons
- The conditions for existing variables.tmodel
- The type model.- Returns:
- The primary value (i.e. variable or literal).
-
shuffle
protected static void shuffle(BuildContext context)
Shuffle conditions and constraints, such that all variables are bound before used.- Parameters:
lcons
- The list of conditions (shuffled in place).
-
combineValueSources
protected static java.util.List combineValueSources(java.lang.Object valuesource, java.util.List suffs)
Combine (i.e. chain) value sources.- Parameters:
valuesource
- The initial value source.suffs
- The suffixes to the initial value source.- Returns:
- The combined value source.
-
-