protected Map<ParticipantId, Set<Range<Integer>>> getAndPrintAnnotations(PluggableMutableDocument document, SimpleAnnotationSet annotationSet) { Map<ParticipantId, Set<Range<Integer>>> rangesPerParticipant = new HashMap<ParticipantId, Set<Range<Integer>>>(); Iterable<AnnotationInterval<Object>> intervals = annotationSet.annotationIntervals(0, document.size(), CollectionUtils.newStringSet(WaveletContributions.ANNOTATION_KEY)); intervals.forEach(interval -> { System.out.println("Interval ("+interval.start()+","+interval.end()+") "); final Range<Integer> r = Range.closed(interval.start(), interval.end()); interval.annotations().each(new ProcV<Object>() { @Override public void apply(String key, Object value) { if (value != null) { ParticipantId p = (ParticipantId) value; if (!rangesPerParticipant.containsKey(p)) { rangesPerParticipant.put(p, new HashSet<Range<Integer>>()); } Set<Range<Integer>> rangeSet = rangesPerParticipant.get(p); rangeSet.add(r); System.out.println("\t "+key+"="+value.toString()); } } }); }); return rangesPerParticipant; }