All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.virtdata.libbasics.core.MVELExpr Maven / Gradle / Ivy

There is a newer version: 2.12.15
Show newest version
package io.virtdata.libbasics.core;

import org.mvel2.MVEL;
import org.mvel2.ParserContext;

import java.io.Serializable;

/**
 * Utility class for creating pre-compiled MVEL expressions with a typed and named context variable.
 */
public class MVELExpr {

    public static Serializable compile(Class inputClass, String inputName, String expr) {
        ParserContext context = new ParserContext();
        context.setStrictTypeEnforcement(true);
        context.addInput(inputName,inputClass);
        Serializable compiled = MVEL.compileExpression(expr, context);
        return compiled;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy