Class CommentThreads<T extends Comment>

java.lang.Object
com.google.gerrit.server.change.CommentThreads<T>
Type Parameters:
T - type of comments in the threads. Can also be Comment if the threads mix comments of different types.

public class CommentThreads<T extends Comment> extends Object
Identifier of comment threads.

Comments are ordered into threads according to their parent relationship indicated via Comment.parentUuid. It's possible that two comments refer to the same parent, which especially happens when two persons reply in parallel. If such branches exist, we merge them into a flat list taking the comment creation date (Comment.writtenOn into account (but still preserving the general parent order). Remaining ties are resolved by using the natural order of the comment UUID, which is unique.

  • Constructor Details

    • CommentThreads

      public CommentThreads(com.google.common.collect.ImmutableMap<String,T> commentPerUuid, Map<String,com.google.common.collect.ImmutableSet<T>> childrenPerParent)
  • Method Details

    • forComments

      public static <T extends Comment> CommentThreads<T> forComments(Iterable<T> comments)
    • getThreads

      public com.google.common.collect.ImmutableSet<CommentThread<T>> getThreads()
      Returns all comments organized into threads.

      Comments appear only once.

    • getThreadsForChildren

      public com.google.common.collect.ImmutableSet<CommentThread<T>> getThreadsForChildren(Iterable<? extends T> childComments)
      Returns only the comment threads to which the specified comments are a reply.

      If the specified child comments are part of the comments originally provided to forComments(Iterable), they will also appear in the returned comment threads. They don't need to be part of the originally provided comments, though, but should refer to one of these comments via their Comment.parentUuid. Child comments not referring to any known comments will be ignored.

      Parameters:
      childComments - comments for which the matching threads should be determined
      Returns:
      threads to which the provided child comments are a reply