package org.implab.gradle.common.sources;

import org.implab.gradle.common.core.lang.Closures;
import org.gradle.api.Action;
import org.gradle.api.Named;
import org.gradle.api.provider.Property;

import groovy.lang.Closure;
import groovy.lang.DelegatesTo;

/**
 * Public DSL contract for per-layer source-set policy and callbacks.
 */
public interface LayerBindingSpec extends Named {
    Property<String> getSourceSetNamePattern();

    default void setSourceSetNamePattern(String pattern) {
        getSourceSetNamePattern().set(pattern);
    }

    void configureSourceSet(Action<? super GenericSourceSet> configure);

    default void configureSourceSet(
            @DelegatesTo(value = GenericSourceSet.class, strategy = Closure.DELEGATE_FIRST) Closure<?> configure) {
        configureSourceSet(Closures.action(configure));
    }

    void whenRegistered(Action<? super SourceSetRegistration> action);

    default void whenRegistered(
            @DelegatesTo(value = SourceSetRegistration.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) {
        whenRegistered(Closures.action(action));
    }

    void whenBound(Action<? super SourceSetUsageBinding> action);

    default void whenBound(
            @DelegatesTo(value = SourceSetUsageBinding.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) {
        whenBound(Closures.action(action));
    }
}
