All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zwobble.mammoth.internal.documents.Notes Maven / Gradle / Ivy

The newest version!
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> notes;

    public Notes(List notes) {
        this.notes = eagerMapValues(
            toMultiMapWithKey(notes, Note::getNoteType),
            notesOfType -> toMapWithKey(notesOfType, Note::getId));
    }

    public Optional findNote(NoteType noteType, String noteId) {
        return lookup(notes, noteType)
            .flatMap(notesOfType -> lookup(notesOfType, noteId));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy