Package com.cloudforge.core.config
Class VisibilityExpressionEvaluator
java.lang.Object
com.cloudforge.core.config.VisibilityExpressionEvaluator
Evaluates visibility expressions for configuration fields.
This evaluator implements a recursive descent parser that supports:
- Logical operators: && (AND), || (OR), ! (NOT)
- Comparison operators: == (equals), != (not equals), >, <, >=, <=
- Parentheses: for grouping expressions
- Capability checks: supportsDatabase, supportsOidc, etc.
- Field comparisons: provisionDatabase == true, runtime == FARGATE, maxCapacity > 1
Grammar (BNF):
expression ::= orExpression
orExpression ::= andExpression ( "||" andExpression )*
andExpression ::= notExpression ( "&&" notExpression )*
notExpression ::= "!" primary | primary
primary ::= "(" expression ")" | comparison | capability
comparison ::= identifier ( "==" | "!=" ) value
capability ::= identifier
identifier ::= [a-zA-Z_][a-zA-Z0-9_]*
value ::= string | number | boolean
Examples:
supportsDatabase → Check if ApplicationSpec supports databases provisionDatabase == true → Check if provisionDatabase field is true runtimeType == "fargate" → Check if runtimeType equals "fargate" supportsDatabase && provisionDatabase → Logical AND multiAz || databaseEngine == "aurora" → Logical OR !provisionDatabase → Logical NOT (supportsDatabase && provisionDatabase) || useEmbeddedDb → Parentheses for grouping
-
Constructor Summary
ConstructorsConstructorDescriptionVisibilityExpressionEvaluator(ApplicationSpec appSpec, Object config, String expression) Creates a new evaluator. -
Method Summary
-
Constructor Details
-
VisibilityExpressionEvaluator
Creates a new evaluator.- Parameters:
appSpec- the application spec (may be null)config- the deployment config objectexpression- the visibility expression to evaluate
-
-
Method Details
-
evaluate
public boolean evaluate()Evaluates the visibility expression.- Returns:
- true if the field should be visible, false otherwise
- Throws:
IllegalArgumentException- if the expression is malformed
-