package com.atlassian.stash.internal.comment;

import com.atlassian.stash.internal.Dao;
import com.atlassian.stash.internal.commit.InternalCommitDiscussion;
import com.atlassian.stash.internal.content.InternalChangeLocation;
import com.atlassian.stash.internal.pull.InternalPullRequest;

import javax.annotation.Nonnull;
import java.util.Map;

/**
 * DAO for managing {@link InternalDiffCommentAnchor anchors} for {@link InternalCommitDiscussion commit discussion}
 * and {@link InternalPullRequest pull request} comments.
 *
 * @since 2.11
 */
public interface DiffCommentAnchorDao<T extends InternalCommentable, A extends InternalDiffCommentAnchor>
        extends Dao<Long, A> {

    /**
     * Retrieves a list of {@link CommentCounts comment counts} for each distinct
     * {@link InternalDiffCommentAnchor#getPath() path} and
     * {@link InternalDiffCommentAnchor#getSrcPath() srcPath} combination.
     * <p>
     * Note that, for the purpose of distinctiveness, if the same path appears with and without a source path, entries
     * with and without will be considered as distinct. Likewise, if a given value appears in one place as a path and in
     * another as a source path, they will also be considered distinct.
     *
     * @param entity the entity, such as a {@link InternalCommitDiscussion discussion} or {@link InternalPullRequest
     *               pull request}, to retrieve comment counts for
     * @return a mapping of {@link CommentCounts comment counts} to {@link InternalChangeLocation location}
     *         for the specified entity
     */
    @Nonnull
    Map<InternalChangeLocation, CommentCounts> getCountsByLocation(@Nonnull T entity);
}
