Search in sources :

Example 1 with TypeUtils.classFromType

use of org.drools.mvelcompiler.util.TypeUtils.classFromType in project drools by kiegroup.

the class RHSPhase method asFieldAccessTExpr.

private Optional<TypedExpression> asFieldAccessTExpr(SimpleName n, Context arg) {
    Optional<TypedExpression> lastTypedExpression = arg.scope;
    Optional<Type> scopeType = arg.getScopeType();
    Optional<Field> fieldType = scopeType.flatMap(te -> {
        Class parentClass = TypeUtils.classFromType(te);
        Field field = ClassUtils.getField(parentClass, n.asString());
        return ofNullable(field);
    });
    return map2(lastTypedExpression, fieldType, FieldAccessTExpr::new);
}
Also used : Field(java.lang.reflect.Field) NullType(org.drools.core.util.MethodUtils.NullType) Type(java.lang.reflect.Type) TypeUtils.classFromType(org.drools.mvelcompiler.util.TypeUtils.classFromType) FieldAccessTExpr(org.drools.mvelcompiler.ast.FieldAccessTExpr) UnalteredTypedExpression(org.drools.mvelcompiler.ast.UnalteredTypedExpression) TypedExpression(org.drools.mvelcompiler.ast.TypedExpression)

Aggregations

Field (java.lang.reflect.Field)1 Type (java.lang.reflect.Type)1 NullType (org.drools.core.util.MethodUtils.NullType)1 FieldAccessTExpr (org.drools.mvelcompiler.ast.FieldAccessTExpr)1 TypedExpression (org.drools.mvelcompiler.ast.TypedExpression)1 UnalteredTypedExpression (org.drools.mvelcompiler.ast.UnalteredTypedExpression)1 TypeUtils.classFromType (org.drools.mvelcompiler.util.TypeUtils.classFromType)1