blob: c88c31af38017ca03551d59f5d2cef7e56939c16 (
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.Lists.list;
import static org.zwobble.mammoth.internal.util.Maps.*;
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));
}
}
|