package gw.rating.flow.domain uses gw.lang.reflect.IType uses gw.util.Pair uses gw.validation.PCValidationContext uses java.util.List class ConditionalOperand extends CalcStepOperand { var _subOperands: List as readonly SubOperands final var _codeSize: int override property get CodeSize() : int { return _codeSize } construct(aSubOperands : List>, context : PCValidationContext, opType : CalcStepOperatorType, numLeft: int, numRight: int) { this(aSubOperands, context, opType, numLeft, numRight, null) } construct(aSubOperands : List>, context : PCValidationContext, opType : CalcStepOperatorType, numLeft: int, numRight: int, aHighlightElement: RateRoutineHighlightElement) { super(opType, numLeft, numRight) this._subOperands = aSubOperands.toTypedArray().map(\ c -> { if (c.Second.OperatorType == null) { var operand = ParseUtil.createCalcStepOperand(c.First, context) as CalcStepValueOperand if (c.First.LogicalNot) { return new NegatedValueOperand(operand, 0, 0) } else { return operand } } else if (c.Second.OperandType == TC_COLLECTION) { return new TypekeyInclusionOperand(c.First, c.Second, context, 0, 0) } else { return new ComparisonOperand(c.First, c.Second, context, 0, 0) } }).toList() _highlightElement = aHighlightElement _codeSize = 1 + _subOperands*.CodeSize.sum() } override function getDataType(context: GenerationContext) : IType { return Boolean } override property get OperandType() : CalcStepOperandType { return CalcStepOperandType.TC_CONDITIONAL } private function generateOperator(op : CalcStepOperatorType) : String { return op == null ? "" : (op.LogicalOperator + " ") } override function generateCode(context: GenerationContext){ SubOperands.toTypedArray() .eachWithIndex(\ so, i -> { context.append(generateOperator(so.OperatorType)) so.generate(context) if (i < SubOperands.Count - 1) { context.append("\n") } }) } }