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

import com.atlassian.bitbucket.mesh.git.builder.GitProcessBuilderFactory;
import com.atlassian.bitbucket.mesh.repository.Repository;

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

import static java.util.Objects.requireNonNull;

public class DefaultSubmoduleManager implements SubmoduleManager {

    private final GitProcessBuilderFactory builderFactory;

    public DefaultSubmoduleManager(GitProcessBuilderFactory builderFactory) {
        this.builderFactory = builderFactory;
    }

    @Nonnull
    @Override
    public Submodules get(@Nonnull Repository repository, @Nonnull String commitId, @Nullable String basePath) {
        requireNonNull(repository, "repository");
        requireNonNull(commitId, "commitId");

        return new LazySubmodules(builderFactory, repository, commitId, basePath);
    }
}
