package com.atlassian.bitbucket.mesh.git.builder.config;

import com.atlassian.bitbucket.mesh.git.builder.GitProcessBuilder;

import javax.annotation.Nonnull;

public class DefaultGitConfigGetBuilder
        extends AbstractTypedGitConfigBuilder<GitConfigGetBuilder>
        implements GitConfigGetBuilder {

    private boolean nullTerminated;

    public DefaultGitConfigGetBuilder(GitProcessBuilder builder, String name) {
        super(builder, name);
    }

    @Nonnull
    @Override
    public GitConfigGetBuilder nullTerminated(boolean value) {
        nullTerminated = value;

        return self();
    }

    @Override
    protected void applyArguments() {
        super.applyArguments();

        if (nullTerminated) {
            builder.argument("-z");
        }

        builder.argument("--get").argument(name);
    }

    @Nonnull
    @Override
    protected GitConfigGetBuilder self() {
        return this;
    }
}
