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

com.codingapi.springboot.flow.script.ScriptRuntime Maven / Gradle / Ivy

package com.codingapi.springboot.flow.script;

import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import groovy.lang.Script;

import java.util.function.Consumer;

public class ScriptRuntime {

    public static  T run(String script,
                            Consumer consumer,
                            Class clazz) {
        Binding binding = new Binding();
        consumer.accept(binding);
        GroovyShell groovyShell = new GroovyShell(binding);
        Script userScript = groovyShell.parse(script);
        return (T) userScript.run();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy