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

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

import javax.annotation.Nonnull;

public class DefaultGitCatFileTypeBuilder
        extends AbstractObjectGitCatFileBuilder<GitCatFileTypeBuilder>
        implements GitCatFileTypeBuilder {

    private boolean allowUnknownType;

    public DefaultGitCatFileTypeBuilder(GitProcessBuilder builder) {
        super(builder, CatFileFormat.TYPE);
    }

    @Nonnull
    @Override
    public GitCatFileTypeBuilder allowUnknownType(boolean value) {
        allowUnknownType = value;

        return self();
    }

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

        if (allowUnknownType) {
            builder.argument("--allow-unknown-type");
        }
    }

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