RuleModelVisitor { private void visitSingleFieldConstraint(SingleFieldConstraint sfc) { if (BaseSingleFieldConstraint.TYPE_PREDICATE == sfc.getConstraintValueType()){ parseStringPattern(sfc.getValue()); return; } InterpolationVariable var = new InterpolationVariable(sfc.getValue(), sfc.getFieldType(), (factPattern == null ? "" : factPattern.getFactType()), sfc.getFieldName(), sfc.getOperator()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == sfc.getConstraintValueType() && !vars.containsKey(var)) { vars.put(var, vars.size()); } if (sfc.getConnectives() != null) { for (int i = 0; i < sfc.getConnectives().length; i++) { final ConnectiveConstraint cc = sfc.getConnectives()[i]; InterpolationVariable ccVar = new InterpolationVariable(cc.getValue(), cc.getFieldType(), (factPattern == null ? "" : factPattern.getFactType()), cc.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == cc.getConstraintValueType() && !vars.containsKey(ccVar)) { vars.put(ccVar, vars.size()); } } } } RuleModelVisitor();  RuleModelVisitor(Map<InterpolationVariable, Integer> vars);  RuleModelVisitor(IPattern pattern,
                            Map<InterpolationVariable, Integer> vars);  RuleModelVisitor(IAction action,
                            Map<InterpolationVariable, Integer> vars);  RuleModelVisitor(IPattern[] lhs,
                            Map<InterpolationVariable, Integer> vars);  RuleModelVisitor(IAction[] rhs,
                            Map<InterpolationVariable, Integer> vars); void visit(Object o);  }
@Test public void visitSingleFieldConstraint() { Map<InterpolationVariable, Integer> variableMap = new HashMap<>(); RuleModelVisitor visitor = new RuleModelVisitor(variableMap); SingleFieldConstraint singleFieldConstraint = new SingleFieldConstraint(); singleFieldConstraint.setConstraintValueType(BaseSingleFieldConstraint.TYPE_TEMPLATE); singleFieldConstraint.setFieldType("fieldType"); singleFieldConstraint.setFieldName("fieldName"); singleFieldConstraint.setValue("value"); singleFieldConstraint.setOperator("=="); visitor.visit(singleFieldConstraint); assertEquals(1, variableMap.keySet().size()); InterpolationVariable interpolationVariable = variableMap.keySet().iterator().next(); assertEquals("value", interpolationVariable.getVarName()); assertEquals("fieldName", interpolationVariable.getFactField()); assertEquals("fieldType", interpolationVariable.getDataType()); assertEquals("==", interpolationVariable.getOperator()); }