package com.atlassian.bitbucket.mesh.repository;

import javax.annotation.Nonnull;

/**
 * A {@link Repository} in Bitbucket Server's legacy format that is stored on shared home or in a legacy data store.
 */
public interface BitbucketServerRepository extends Repository {

    /**
     * @param shardId     the ID of the shard where the repository is stored
     * @param hierarchyId the repository hierarchy ID
     * @param bitbucketId the Bitbucket Server repository ID
     * @return the fully qualified Mesh ID for the repository
     */
    @Nonnull
    static String formatId(@Nonnull String shardId, @Nonnull String hierarchyId, @Nonnull String bitbucketId) {
        return "ds/" + shardId + "/h/" + hierarchyId + "/r/" + bitbucketId;
    }

    /**
     * Generates the fully qualified Mesh ID for a legacy Bitbucket Server repository in the shared home
     *
     * @param hierarchyId the repository hierarchy ID
     * @param bitbucketId the Bitbucket Server repository ID
     * @return the fully qualified Mesh ID for the repository
     */
    @Nonnull
    static String formatId(@Nonnull String hierarchyId, @Nonnull String bitbucketId) {
        return formatId("0", hierarchyId, bitbucketId);
    }

    @Nonnull
    String getBitbucketId();

    @Nonnull
    String getHierarchyId();
}
