@Override public Iterable<LocatedReplyThread> locateReplyThreads() { // NOTE(anorth): We must recalculate the anchor locations on each // call as the document does not provide stable elements. However, we // calculate the list of anchor locations on demand. Map<String, Integer> replyLocations = null; List<LocatedReplyThread> inlineReplyThreads = CollectionUtils.newArrayList(); for (WaveletBasedConversationThread reply : getReplyThreads()) { if (replyLocations == null) { replyLocations = findAnchors(); } Integer location = replyLocations.get(reply.getId()); inlineReplyThreads.add(new LocatedReplyThread(reply, (location != null) ? location : Blips.INVALID_INLINE_LOCATION)); } Collections.sort(inlineReplyThreads); return Collections.unmodifiableList(inlineReplyThreads); }