public String getOperator() { return operator != null ? operator.getOperator() : null; }
/** * Creates a new alias for the operator, setting it in the descriptor * class, adding it to the internal Map and returning it as a String * * @param operator * @return */ public String createAlias( OperatorDescr operator ) { String alias = operator.getOperator() + counter++; operator.setAlias(alias); this.aliases.put( alias, operator ); return alias; }
protected void rewriteBasicOperator( StringBuilder sbuilder, String left, OperatorDescr operator, String right) { sbuilder.append( evaluatorPrefix( operator.isNegated() ) ) .append( left ) .append( " " ) .append( operator.getOperator() ) .append( " " ) .append( right ) .append( evaluatorSufix( operator.isNegated() ) ); }
OperatorDescr operator, String right ) { Operator op = Operator.determineOperator( operator.getOperator(), operator.isNegated() ); if ( op == Operator.determineOperator( "memberOf", .append( right ) .append( evaluatorSufix( operator.isNegated() ) ); } else if ( lookupBasicOperator( operator.getOperator() ) ) { if (operator.getOperator().equals("instanceof")) { context.addInferredCast(left, right);
Declaration requiredDeclaration, RelationalExprDescr relDescr) { if (!isMvelOperator(operatorDescr.getOperator())) { EvaluatorDefinition.Target right = getRightTarget( extractor ); EvaluatorDefinition.Target left = (requiredDeclaration.isPatternDeclaration() && !(Date.class.isAssignableFrom( requiredDeclaration.getExtractor().getExtractToClass() ) || Number.class.isAssignableFrom( requiredDeclaration.getExtractor().getExtractToClass() ))) ? EvaluatorDefinition.Target.HANDLE : EvaluatorDefinition.Target.FACT; relDescr, extractor.getValueType(), operatorDescr.getOperator(), relDescr.isNegated(), relDescr.getParametersText(), boolean isUnification = requiredDeclaration != null && requiredDeclaration.getPattern().getObjectType().equals( new ClassObjectType( DroolsQuery.class ) ) && Operator.EQUAL.getOperatorString().equals( operatorDescr.getOperator() ); if (isUnification) { expression = resolveUnificationAmbiguity(expression, declarations, leftValue, rightValue); IndexUtil.ConstraintType constraintType = IndexUtil.ConstraintType.decode(operatorDescr.getOperator()); MVELCompilationUnit compilationUnit = isUnification ? null : buildCompilationUnit(context, pattern, expression, null); return new MvelConstraint(context.getPkg().getName(), expression, declarations, compilationUnit, constraintType, requiredDeclaration, extractor, isUnification);
protected static Map<String, EvaluatorWrapper> buildOperators(RuleBuildContext context, Pattern pattern, PredicateDescr predicateDescr, Map<String, OperatorDescr> aliases) { Map<String, EvaluatorWrapper> operators = new HashMap<String, EvaluatorWrapper>(); for ( Map.Entry<String, OperatorDescr> entry : aliases.entrySet() ) { OperatorDescr op = entry.getValue(); Declaration leftDecl = createDeclarationForOperator(context, pattern, op.getLeftString()); Declaration rightDecl = createDeclarationForOperator(context, pattern, op.getRightString()); Target left = leftDecl != null && leftDecl.isPatternDeclaration() ? Target.HANDLE : Target.FACT; Target right = rightDecl != null && rightDecl.isPatternDeclaration() ? Target.HANDLE : Target.FACT; op.setLeftIsHandle( left == Target.HANDLE ); op.setRightIsHandle( right == Target.HANDLE ); Evaluator evaluator = getConstraintBuilder( context ).getEvaluator( context, predicateDescr, ValueType.OBJECT_TYPE, op.getOperator(), false, // the rewrite takes care of negation op.getParametersText(), left, right); EvaluatorWrapper wrapper = getConstraintBuilder( context ).wrapEvaluator( evaluator, leftDecl, rightDecl ); operators.put( entry.getKey(), wrapper ); } return operators; }