package com.atlassian.bitbucket.mesh.git.pull;

import com.atlassian.bitbucket.mesh.git.AbstractParameters;

import javax.annotation.Nonnull;

import static java.util.Objects.requireNonNull;

public class AbstractPullRequestParameters extends AbstractParameters {

    private final boolean allowUnrelated;
    private final PullRequest pullRequest;

    protected AbstractPullRequestParameters(AbstractPullRequestBuilder<?, ?> builder) {
        super(builder);

        allowUnrelated = builder.allowUnrelated;
        pullRequest = builder.pullRequest;
    }

    @Nonnull
    public PullRequest getPullRequest() {
        return pullRequest;
    }

    public boolean isAllowUnrelated() {
        return allowUnrelated;
    }

    public abstract static class AbstractPullRequestBuilder<B extends AbstractPullRequestBuilder<B, P>, P extends AbstractPullRequestParameters>
            extends AbstractBuilder<B, P> {

        private final PullRequest pullRequest;

        private boolean allowUnrelated;

        public AbstractPullRequestBuilder(@Nonnull PullRequest pullRequest) {
            this.pullRequest = requireNonNull(pullRequest, "pullRequest");
        }

        @Nonnull
        public B allowUnrelated(boolean value) {
            allowUnrelated = value;

            return self();
        }
    }
}
