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

nl.tudelft.ewi.auta.srf.model.NoteCollection Maven / Gradle / Ivy

The newest version!
package nl.tudelft.ewi.auta.srf.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;

/**
 * The collection of notes returned by a script.
 */
public class NoteCollection {
    /**
     * The note messages generated by the script.
     */
    private Collection notes = new ArrayList<>();

    /**
     * Returns all notes in the collection.
     *
     * @return all notes
     */
    public Collection getNotes() {
        return this.notes;
    }

    /**
     * Replaces the notes in the collection.
     *
     * @param notes the new notes
     */
    public void setNotes(final Collection notes) {
        this.notes = notes;
    }

    /**
     * Returns all notes with the given severity in the collection.
     *
     * @param severity the severity to filter by
     *
     * @return all notes with that severity
     */
    public Collection getNotesBySeverity(final Severity severity) {
        return this.notes.stream()
                       .filter(n -> n.getSeverity() == severity)
                       .collect(Collectors.toList());
    }

    /**
     * Adds a note to the collection.
     *
     * @param note the note to add
     */
    public void addNote(final Note note) {
        this.notes.add(note);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy