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

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

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import static java.util.Objects.requireNonNull;

public class GetNodeTypeParameters extends AbstractParameters {

    private final String commitId;
    private final String path;
    private final Repository repository;

    private GetNodeTypeParameters(Builder builder) {
        super(builder);

        commitId = requireNonNull(builder.commitId, "commitId");
        path = builder.path;
        repository = builder.repository;
    }

    @Nonnull
    public String getCommitId() {
        return commitId;
    }

    @Nullable
    public String getPath() {
        return path;
    }

    @Nonnull
    public Repository getRepository() {
        return repository;
    }

    public static class Builder extends AbstractBuilder<Builder, GetNodeTypeParameters> {

        private final Repository repository;

        private String commitId;
        private String path;

        public Builder(@Nonnull Repository repository) {
            this.repository = requireNonNull(repository, "repository");
        }

        @Nonnull
        @Override
        public GetNodeTypeParameters build() {
            return new GetNodeTypeParameters(this);
        }

        @Nonnull
        public Builder commitId(@Nonnull String value) {
            commitId = requireNonBlank(value, "commitId");

            return self();
        }

        @Nonnull
        public Builder path(@Nullable String value) {
            path = value;

            return self();
        }

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