Search in sources :

Example 1 with ParamItem

use of com.duangframework.rule.entity.ParamItem in project duangframework by tcrct.

the class AutoCreateDrlFile method createRuleWhen.

private static String createRuleWhen(List<ParamItem> paramItemList) {
    if (ToolsKit.isEmpty(paramItemList)) {
        throw new EmptyNullException("paramItemList is null");
    }
    StringBuilder paramItemString = new StringBuilder();
    int size = paramItemList.size();
    for (int i = 0; i < size; i++) {
        ParamItem paramItem = paramItemList.get(i);
        paramItemString.append("$ruleMap_").append(paramItem.getKey()).append(" : Map(this[\"").append(paramItem.getKey()).append("\"]");
        paramItemString.append(" " + paramItem.getOperatorEnum().getValue() + " ");
        Object valueObj = paramItem.getValue();
        if (valueObj instanceof String) {
            paramItemString.append("\"").append(valueObj).append("\"");
        } else {
            paramItemString.append(valueObj);
        }
        paramItemString.append(");");
        if (i < (size - 1)) {
            paramItemString.append(ENTER_FIELD).append(TAB_FIELD).append(TAB_FIELD);
        }
    }
    return paramItemString.toString();
}
Also used : ParamItem(com.duangframework.rule.entity.ParamItem) EmptyNullException(com.duangframework.core.exceptions.EmptyNullException)

Aggregations

EmptyNullException (com.duangframework.core.exceptions.EmptyNullException)1 ParamItem (com.duangframework.rule.entity.ParamItem)1