Search in sources :

Example 1 with GlobalExtractor

use of org.drools.core.spi.GlobalExtractor in project drools by kiegroup.

the class RuleContext method getDeclaration.

Declaration getDeclaration(Variable variable) {
    if (variable.isFact()) {
        Declaration declaration = innerDeclaration.get(variable);
        if (declaration == null) {
            declaration = queryDeclaration.get(variable);
        }
        if (declaration == null) {
            Pattern pattern = patterns.get(variable);
            declaration = pattern != null ? pattern.getDeclaration() : null;
        }
        return declaration;
    } else {
        Global global = ((Global) variable);
        ObjectType objectType = builder.getObjectType(global);
        InternalReadAccessor globalExtractor = new GlobalExtractor(global.getName(), objectType);
        return new Declaration(global.getName(), globalExtractor, new Pattern(0, objectType));
    }
}
Also used : Pattern(org.drools.core.rule.Pattern) ObjectType(org.drools.core.spi.ObjectType) GlobalExtractor(org.drools.core.spi.GlobalExtractor) InternalReadAccessor(org.drools.core.spi.InternalReadAccessor) Declaration(org.drools.core.rule.Declaration) Global(org.drools.model.Global)

Aggregations

Declaration (org.drools.core.rule.Declaration)1 Pattern (org.drools.core.rule.Pattern)1 GlobalExtractor (org.drools.core.spi.GlobalExtractor)1 InternalReadAccessor (org.drools.core.spi.InternalReadAccessor)1 ObjectType (org.drools.core.spi.ObjectType)1 Global (org.drools.model.Global)1