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

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

import javax.annotation.Nonnull;

import static java.util.Objects.requireNonNull;

public class DefaultGitCountObjectsBuilder extends AbstractGitProcessBuilder<GitCountObjectsBuilder>
        implements GitCountObjectsBuilder {

    private boolean verbose;

    public DefaultGitCountObjectsBuilder(@Nonnull GitProcessBuilder builder) {
        super(requireNonNull(builder, "builder").command("count-objects"));
    }

    @Nonnull
    @Override
    public GitCountObjectsBuilder verbose(boolean value) {
        verbose = value;

        return self();
    }

    @Override
    protected void applyArguments() {
        if (verbose) {
            builder.argument("-v");
        }
    }

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