Class CommentCollection


  • public class CommentCollection
    extends java.lang.Object
    Class to wrap the functions to handle the Comments of a component.
    • Method Summary

      Modifier and Type Method Description
      void add​(Comment comment)
      Adds a new Comment to the collection.
      java.util.List<Comment> getAll()
      Return the list of Comments
      java.util.Optional<Comment> getByName​(java.lang.String name)
      Try to find the Comment in the collection with the given name.
      void set​(java.util.List<Comment> comments)
      Deletes all saved comments and adds the ones from the passed list.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CommentCollection

        public CommentCollection()
    • Method Detail

      • add

        public void add​(Comment comment)
        Adds a new Comment to the collection.
        Parameters:
        comment - Cannot be null, only one Comment per name allowed, otherwise a RedundantItemException will be thrown.
      • getAll

        public java.util.List<Comment> getAll()
        Return the list of Comments
        Returns:
        the comments
      • getByName

        public java.util.Optional<Comment> getByName​(java.lang.String name)
        Try to find the Comment in the collection with the given name.
        Parameters:
        name - the searched Comment
        Returns:
        a container with the searched Comment or an empty object if no one with the given name was found.
      • set

        public void set​(java.util.List<Comment> comments)
        Deletes all saved comments and adds the ones from the passed list. List cannot contain nulls or multiple comments with the same name.
        Parameters:
        comments - the List of Comments to set
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object