package com.atlassian.bitbucket.mesh.management;

import com.atlassian.bitbucket.mesh.rpc.v1.RpcGitInfo;
import com.atlassian.bitbucket.mesh.util.Version;

import javax.annotation.Nonnull;

import static java.util.Objects.requireNonNull;

class GitInfo {

    private final Version current;
    private final Version startup;

    GitInfo(@Nonnull Version current, @Nonnull Version startup) {
        this.current = requireNonNull(current, "current");
        this.startup = requireNonNull(startup, "startup");
    }

    @Nonnull
    Version getCurrent() {
        return current;
    }

    @Nonnull
    Version getStartup() {
        return startup;
    }

    @Nonnull
    RpcGitInfo toGitInfo() {
        return RpcGitInfo.newBuilder()
                .setCurrentVersion(getCurrent().toString())
                .setStartupVersion(getStartup().toString())
                .build();
    }
}
