package org.implab.gradle.common.utils;

import groovy.lang.Closure;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.gradle.api.Action;

@NonNullByDefault
public final class Closures {
    private Closures() {
    }

    public static <T> Action<T> action(Closure<?> closure) {
        return arg -> {
            closure.setDelegate(arg);
            closure.call(arg);
        };
    }

    public static void apply(Closure<?> action, Object target) {
        action.setDelegate(target);
        action.call(target);
    }
}
