Search in sources :

Example 1 with SnippetType

use of org.drools.template.model.SnippetBuilder.SnippetType in project drools-wb by kiegroup.

the class GuidedDecisionTableLHSBuilder method getValueBuilder.

private ParameterizedValueBuilder getValueBuilder(final String content) {
    // Work out the type of "template":-
    // age                     ---> SnippetType.SINGLE
    // age ==                  ---> SnippetType.SINGLE
    // age == $param           ---> SnippetType.PARAM
    // age == $1 || age == $2  ---> SnippetType.INDEXED
    // forall{age < $}{,}      ---> SnippetType.FORALL
    String template = content.trim();
    SnippetType type = SnippetBuilder.getType(template);
    if (type == SnippetType.SINGLE) {
        type = SnippetType.PARAM;
        boolean hasExplicitOperator = false;
        for (String op : operators) {
            if (template.endsWith(op)) {
                hasExplicitOperator = true;
                break;
            }
        }
        if (!hasExplicitOperator) {
            template = template + " ==";
        }
        template = template + " \"";
        template = template + SnippetBuilder.PARAM_STRING + "\"";
    }
    // Make a ValueBuilder for the template
    switch(type) {
        case INDEXED:
            return new IndexedParametersValueBuilder(template, parameterUtilities, ParameterizedValueBuilder.Part.LHS);
        case PARAM:
            return new SingleParameterValueBuilder(template, parameterUtilities, ParameterizedValueBuilder.Part.LHS);
        case SINGLE:
            return new LiteralValueBuilder(template);
    }
    throw new DecisionTableParseException("SnippetBuilder.SnippetType '" + type.toString() + "' is not supported. The column will not be added.");
}
Also used : SnippetType(org.drools.template.model.SnippetBuilder.SnippetType) DecisionTableParseException(org.drools.template.parser.DecisionTableParseException)

Aggregations

SnippetType (org.drools.template.model.SnippetBuilder.SnippetType)1 DecisionTableParseException (org.drools.template.parser.DecisionTableParseException)1