@Override public boolean isExplicitParticipant() { for (Conversation w : view.getConversations()) { if (w.getParticipantIds().contains(viewer)) { return true; } } return false; } }
void apply(ConversationView wave) { for (Conversation conversation : wave.getConversations()) { apply(conversation); } }
@Override public Iterable<WaveletId> getWavelets() { List<WaveletId> ids = new ArrayList<WaveletId>(); for (Conversation c : view.getConversations()) { ids.add(WaveletBasedConversation.widFor(c.getId())); } return ids; }
/** * Finds the main conversation in a wave. The main conversation is defined as * the root if there is one, or the first unanchored conversation otherwise. */ public static Conversation getMainConversation(ConversationView view) { Conversation root = view.getRoot(); if (root == null) { for (Conversation curr : view.getConversations()) { if (!curr.hasAnchor()) { root = curr; break; } } } return root; } }
/** @return the structure of a conversations in {@code wave}. */ public static ConversationStructure of(ConversationView wave) { IdentityMap<ConversationBlip, Collection<Conversation>> anchoring = null; Collection<Conversation> unanchored = null; Conversation mainConversation = getMainConversation(wave); for (Conversation conversation : wave.getConversations()) { if (conversation == mainConversation) { continue; } Anchor anchor = conversation.getAnchor(); ConversationBlip blip = anchor != null ? anchor.getBlip() : null; if (blip != null) { addLazily((anchoring = createIfNull(anchoring)), blip, conversation); } else { (unanchored = createIfNull(unanchored)).add(conversation); } } if (anchoring == null) { anchoring = CollectionUtils.emptyIdentityMap(); } if (unanchored == null) { unanchored = Collections.emptySet(); } return new ConversationStructure(anchoring, unanchored, mainConversation); }