01: package org.drools.rule.builder.dialect.java;
02:
03: import java.util.List;
04: import java.util.Map;
05:
06: import org.drools.lang.descr.PredicateDescr;
07: import org.drools.rule.Declaration;
08: import org.drools.rule.PredicateConstraint;
09: import org.drools.rule.builder.PredicateBuilder;
10: import org.drools.rule.builder.RuleBuildContext;
11:
12: public class JavaPredicateBuilder extends AbstractJavaBuilder implements
13: PredicateBuilder {
14:
15: public void build(final RuleBuildContext context,
16: final List[] usedIdentifiers,
17: final Declaration[] previousDeclarations,
18: final Declaration[] localDeclarations,
19: final PredicateConstraint predicateConstraint,
20: final PredicateDescr predicateDescr) {
21: final String className = "returnValue" + context.getNextId();
22: predicateDescr.setClassMethodName(className);
23:
24: final Map map = createVariableContext(className,
25: (String) predicateDescr.getContent(), context,
26: previousDeclarations, localDeclarations,
27: (String[]) usedIdentifiers[1]
28: .toArray(new String[usedIdentifiers[1].size()]));
29:
30: generatTemplates("predicateMethod", "predicateInvoker",
31: context, className, map, predicateConstraint,
32: predicateDescr);
33: }
34:
35: }
|