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

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

import javax.annotation.Nonnull;

public class DefaultGitSymbolicRefGetBuilder
        extends AbstractGitProcessBuilder<GitSymbolicRefGetBuilder>
        implements GitSymbolicRefGetBuilder {

    private final String name;

    private boolean quiet;
    private boolean shorten;

    public DefaultGitSymbolicRefGetBuilder(GitProcessBuilder builder, String name) {
        super(builder);

        this.name = name;
    }

    @Nonnull
    @Override
    public GitSymbolicRefGetBuilder quiet(boolean value) {
        quiet = value;

        return self();
    }

    @Nonnull
    @Override
    public GitSymbolicRefGetBuilder shorten(boolean value) {
        shorten = value;

        return self();
    }

    @Override
    protected void applyArguments() {
        if (quiet) {
            builder.argument("--quiet");
        }
        if (shorten) {
            builder.argument("--short");
        }
        builder.argument(name);
    }

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