code: public static <T> T executeGroovyScriptEngine(final String script,
                                                    final Map<String, Object> variables,
                                                    final Class<T> clazz) {
          try {
              val engine = new ScriptEngineManager().getEngineByName("groovy");
              if (engine == null) {
                  LOGGER.warn("Script engine is not available for Groovy");
                  return null;
              }
              val binding = new SimpleBindings();
              if (variables != null && !variables.isEmpty()) {
                  binding.putAll(variables);
              }
              if (!binding.containsKey("logger")) {
                  binding.put("logger", LOGGER);
              }
              val result = engine.eval(script, binding);
              return getGroovyScriptExecutionResultOrThrow(clazz, result);
          } catch (final Exception e) {
              LOGGER.error(e.getMessage(), e);
          }
          return null;
      }
docs: Execute inline groovy script engine.
  
  @param <T>       the type parameter
  @param script    the script
  @param variables the variables
  @param clazz     the clazz
  @return the t