package org.implab.gradle.common.utils;

import java.util.Optional;
import java.util.Set;

import org.gradle.api.plugins.ExtensionAware;

public interface ExtraProps {

    Set<String> keys();

    boolean has(String name);

    <T> Optional<T> get(String name, Class<T> clazz);

    void put(String name, Object value);

    void remove(String name);

    public static ExtraProps of(Object target) {
        return target instanceof ExtensionAware ext
                ? new ExtraPropsExtension(ext.getExtensions().getExtraProperties())
                : new ExtraPropsNone();
    }
}
