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

main.name.remal.gradle_plugins.dsl.DefaultEnvironmentVariableInfo Maven / Gradle / Ivy

The newest version!
package name.remal.gradle_plugins.dsl;

import java.util.Objects;
import javax.annotation.Nullable;
import org.gradle.api.Project;

public class DefaultEnvironmentVariableInfo implements EnvironmentVariableInfo {

    private final String variableName;

    private final String description;

    @Nullable
    private final String pluginId;

    @Nullable
    private final Class> pluginClass;

    @Nullable
    private final String scope;

    @Nullable
    private final Class conditionClass;

    private DefaultEnvironmentVariableInfo(
        String variableName,
        String description,
        @Nullable String pluginId,
        @Nullable Class> pluginClass,
        @Nullable String scope,
        @Nullable Class conditionClass
    ) {
        this.variableName = variableName;
        this.description = description;
        this.pluginId = pluginId;
        this.pluginClass = pluginClass;
        this.scope = scope;
        this.conditionClass = conditionClass;
    }

    public DefaultEnvironmentVariableInfo(String variableName, String description) {
        this(variableName, description, null, null, null, null);
    }

    @Override
    public String getVariableName() {
        return variableName;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Nullable
    @Override
    public String getPluginId() {
        return pluginId;
    }

    @Nullable
    @Override
    public Class> getPluginClass() {
        return pluginClass;
    }

    @Nullable
    @Override
    public String getScope() {
        return scope;
    }

    @Nullable
    @Override
    public Class getConditionClass() {
        return conditionClass;
    }

    @Override
    public DefaultEnvironmentVariableInfo withPluginId(@Nullable String pluginId) {
        if (pluginId == null || pluginId.isEmpty()) pluginId = null;
        if (Objects.equals(getPluginId(), pluginId)) return this;
        return new DefaultEnvironmentVariableInfo(getVariableName(), getDescription(), pluginId, getPluginClass(), getScope(), getConditionClass());
    }

    @Override
    public DefaultEnvironmentVariableInfo withPluginClass(@Nullable Class> pluginClass) {
        if (NotDefinedProjectPlugin.class == pluginClass) pluginClass = null;
        if (Objects.equals(getPluginClass(), pluginClass)) return this;
        return new DefaultEnvironmentVariableInfo(getVariableName(), getDescription(), getPluginId(), pluginClass, getScope(), getConditionClass());
    }

    @Override
    public DefaultEnvironmentVariableInfo withScope(@Nullable String scope) {
        if (scope == null || scope.isEmpty()) scope = null;
        if (Objects.equals(getScope(), scope)) return this;
        return new DefaultEnvironmentVariableInfo(getVariableName(), getDescription(), getPluginId(), getPluginClass(), scope, getConditionClass());
    }

    @Override
    public DefaultEnvironmentVariableInfo withConditionClass(@Nullable Class conditionClass) {
        if (NotDefinedEnvironmentVariableCondition.class == conditionClass) conditionClass = null;
        if (Objects.equals(getConditionClass(), conditionClass)) return this;
        return new DefaultEnvironmentVariableInfo(getVariableName(), getDescription(), getPluginId(), getPluginClass(), getScope(), conditionClass);
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append(this.getClass().getSimpleName()).append('{');
        sb.append("variableName='").append(getVariableName()).append('\'');
        sb.append(", description='").append(getDescription()).append('\'');
        sb.append(", pluginId='").append(getPluginId()).append('\'');
        sb.append(", pluginClass='").append(getPluginClass()).append('\'');
        sb.append(", scope='").append(getScope()).append('\'');
        sb.append(", conditionClass='").append(getConditionClass()).append('\'');
        sb.append('}');
        return sb.toString();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy