blob: fdfa8141ba993b31044ec937035ee5d5269d53ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package org.zwobble.mammoth.internal.documents;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.zwobble.mammoth.internal.util.MammothLists.list;
import static org.zwobble.mammoth.internal.util.MammothMaps.*;
public class Notes {
public final static Notes EMPTY = new Notes(list());
private final Map<NoteType, Map<String, Note>> notes;
public Notes(List<Note> notes) {
this.notes = eagerMapValues(
toMultiMapWithKey(notes, Note::getNoteType),
notesOfType -> toMapWithKey(notesOfType, Note::getId));
}
public Optional<Note> findNote(NoteType noteType, String noteId) {
return lookup(notes, noteType)
.flatMap(notesOfType -> lookup(notesOfType, noteId));
}
}
|