Class CommentThreads<T extends Comment>
- Type Parameters:
T
- type of comments in the threads. Can also beComment
if the threads mix comments of different types.
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comment>
CommentThreads<T>forComments
(Iterable<T> comments) com.google.common.collect.ImmutableSet<CommentThread<T>>
Returns all comments organized into threads.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.
-
Constructor Details
-
CommentThreads
-
-
Method Details
-
forComments
-
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 theirComment.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
-