package com.atlassian.stash.internal.scm.git.command.checkrefformat;

import com.atlassian.stash.internal.scm.git.command.AbstractGitCommandBuilder;
import com.atlassian.bitbucket.scm.git.command.GitScmCommandBuilder;
import com.atlassian.bitbucket.scm.git.command.checkrefformat.GitCheckRefFormatBuilder;

import javax.annotation.Nonnull;

import static com.google.common.base.Preconditions.checkArgument;
import static org.apache.commons.lang3.StringUtils.isNotBlank;

public class DefaultGitCheckRefFormatBuilder extends AbstractGitCommandBuilder<GitCheckRefFormatBuilder>
        implements GitCheckRefFormatBuilder {

    private final String refName;

    public DefaultGitCheckRefFormatBuilder(@Nonnull String refName, @Nonnull GitScmCommandBuilder builder) {
        super(builder);
        checkArgument(isNotBlank(refName), "refName is required");
        this.refName = refName;
    }

    @Override
    protected void applyArguments() {
        builder.argument(refName);
    }

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