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

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

import javax.annotation.Nonnull;

public class DefaultGitCommitGraphWriteBuilder
        extends AbstractGitProcessBuilder<GitCommitGraphWriteBuilder>
        implements GitCommitGraphWriteBuilder {

    private boolean reachable;
    private boolean split;

    public DefaultGitCommitGraphWriteBuilder(GitProcessBuilder builder) {
        super(builder);
    }

    @Nonnull
    @Override
    public GitCommitGraphWriteBuilder reachable(boolean value) {
        reachable = value;

        return self();
    }

    @Nonnull
    @Override
    public GitCommitGraphWriteBuilder split(boolean value) {
        split = value;

        return self();
    }

    @Override
    protected void applyArguments() {
        builder.argument("write");
        if (reachable) {
            builder.argument("--reachable");
        }
        if (split) {
            builder.argument("--split");
        }
    }

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