@Override protected void generateConstraint(final FieldConstraint constr, final LHSGeneratorContext gctx) { boolean generateTemplateCheck = isTemplateKey(constr); if (generateTemplateCheck) { if (constr instanceof SingleFieldConstraint && ((SingleFieldConstraint) constr).getConnectives() != null) { // if there are connectives, and the first is a template key, then all templates keys must be checked up front // individual connectives, that have template keys, will still need to be checked too. SingleFieldConstraint sconstr = (SingleFieldConstraint) constr; buf.append("@if{" + ((SingleFieldConstraint) constr).getValue() + " != empty"); for (int j = 0; j < sconstr.getConnectives().length; j++) { final ConnectiveConstraint conn = sconstr.getConnectives()[j]; if (conn.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_TEMPLATE) { buf.append(" || " + conn.getValue() + " != empty"); } } buf.append("}"); } else { buf.append("@if{" + ((SingleFieldConstraint) constr).getValue() + " != empty}"); } } buf.append("@code{hasLHSOutput" + gctx.getDepth() + "_" + gctx.getOffset() + " = true}"); super.generateConstraint(constr, gctx); if (generateTemplateCheck) { buf.append("@end{}"); } }
private void visitSingleFieldConstraint(SingleFieldConstraint sfc) { 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()); } //Visit Connection constraints 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()); } } } }
private void visitSingleFieldConstraint(SingleFieldConstraintEBLeftSide sfexp) { String genericType = sfexp.getExpressionLeftSide().getGenericType(); String factType = sfexp.getExpressionLeftSide().getPreviousClassType(); if (factType == null) { factType = sfexp.getExpressionLeftSide().getClassType(); } InterpolationVariable var = new InterpolationVariable(sfexp.getValue(), genericType, factType, sfexp.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == sfexp.getConstraintValueType() && !vars.containsKey(var)) { vars.put(var, vars.size()); } //Visit Connection constraints if (sfexp.getConnectives() != null) { for (int i = 0; i < sfexp.getConnectives().length; i++) { final ConnectiveConstraint cc = sfexp.getConnectives()[i]; InterpolationVariable ccVar = new InterpolationVariable(cc.getValue(), genericType, factType, cc.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == cc.getConstraintValueType() && !vars.containsKey(ccVar)) { vars.put(ccVar, vars.size()); } } } }
private void visitSingleFieldConstraint(final SingleFieldConstraint sfc) { final InterpolationVariable var = new InterpolationVariable(sfc.getValue(), sfc.getFieldType(), (factPattern == null ? "" : factPattern.getFactType()), sfc.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == sfc.getConstraintValueType() && !vars.contains(var)) { vars.add(var); } else { hasNonTemplateOutput = true; } //Visit Connection constraints 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.contains(ccVar)) { vars.add(ccVar); } else { hasNonTemplateOutput = true; } } } }
private ConnectiveConstraint visitConnectiveConstraint(ConnectiveConstraint cc) { ConnectiveConstraint clone = new ConnectiveConstraint(); clone.setConstraintValueType(cc.getConstraintValueType()); clone.setExpressionValue((ExpressionFormLine) visit(cc.getExpressionValue())); clone.setFactType(cc.getFactType()); clone.setFieldName(cc.getFieldName()); clone.setFieldType(cc.getFieldType()); clone.setOperator(cc.getOperator()); for (Map.Entry<String, String> entry : cc.getParameters().entrySet()) { clone.setParameter(entry.getKey(), entry.getValue()); } clone.setValue(cc.getValue()); return clone; }
private ConnectiveConstraint visitConnectiveConstraint(ConnectiveConstraint cc) { ConnectiveConstraint clone = new ConnectiveConstraint(); clone.setConstraintValueType(cc.getConstraintValueType()); clone.setExpressionValue((ExpressionFormLine) visit(cc.getExpressionValue())); clone.setFactType(cc.getFactType()); clone.setFieldName(cc.getFieldName()); clone.setFieldType(cc.getFieldType()); clone.setOperator(cc.getOperator()); for (Map.Entry<String, String> entry : cc.getParameters().entrySet()) { clone.setParameter(entry.getKey(), entry.getValue()); } clone.setValue(cc.getValue()); return clone; }
factType, cc.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == cc.getConstraintValueType() && !vars.contains(ccVar)) { vars.add(ccVar); } else {
conn.getConstraintValueType(), conn.getFieldType(), conn.getOperator(),