Class CommentsImpl

  • All Implemented Interfaces:
    Comments

    public class CommentsImpl
    extends Object
    implements Comments
    Full implementation Implementation of the Comments interface.
    Author:
    Maximilian Schiedermeier
    • Method Detail

      • getInstance

        public static Comments getInstance()
        Singleton access for CommentsImpl.
        Returns:
        the one ond only CommentsImpl instance.
      • getAllCommentsForBook

        public Map<Long,​String> getAllCommentsForBook​(long isbn)
        Returns all comments stored for a specific book.
        Specified by:
        getAllCommentsForBook in interface Comments
        Parameters:
        isbn - as the identifier of the book in question
        Returns:
        a map of commentIds to comments.
      • addComment

        public void addComment​(long isbn,
                               String comment)
        Add a comment to an existing book. Comments for non-indexed books (isbn not listed in assortmentMap) are rejected.
        Specified by:
        addComment in interface Comments
        Parameters:
        isbn - as the identifier of the book in question
        comment - as a string representing the comment to be added
      • deleteComment

        public void deleteComment​(long isbn,
                                  long commentId)
        Removes a previously stored comment for a specific book.
        Specified by:
        deleteComment in interface Comments
        Parameters:
        isbn - as the identifier of the book in question
        commentId - as the id of the comment to be removed
      • removeAllCommentsForBook

        public void removeAllCommentsForBook​(long isbn)
        Removes all previously stored comments for a specific book.
        Specified by:
        removeAllCommentsForBook in interface Comments
        Parameters:
        isbn - as the identifier of the book in question
      • editComment

        public void editComment​(long isbn,
                                long commentId,
                                String updatedComment)
        Overwrites an already existing specific comment for a specific book.
        Specified by:
        editComment in interface Comments
        Parameters:
        isbn - as the identifier of the book in question
        commentId - as the id of the comment to be overwritten
        updatedComment - as a string representing the updated comment
      • toString

        public String toString()
        Helper method to convert all stored comments into human readable format.
        Overrides:
        toString in class Object
        Returns:
        A nicely formatted string listing all comments for all books.