Class CommentsImpl
- java.lang.Object
-
- eu.kartoffelquadrat.bookstoreinternals.CommentsImpl
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addComment(long isbn, String comment)
Add a comment to an existing book.void
deleteComment(long isbn, long commentId)
Removes a previously stored comment for a specific book.void
editComment(long isbn, long commentId, String updatedComment)
Overwrites an already existing specific comment for a specific book.Map<Long,String>
getAllCommentsForBook(long isbn)
Returns all comments stored for a specific book.static Comments
getInstance()
Singleton access for CommentsImpl.void
removeAllCommentsForBook(long isbn)
Removes all previously stored comments for a specific book.String
toString()
Helper method to convert all stored comments into human readable format.
-
-
-
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 interfaceComments
- 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 interfaceComments
- Parameters:
isbn
- as the identifier of the book in questioncomment
- 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 interfaceComments
- Parameters:
isbn
- as the identifier of the book in questioncommentId
- 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 interfaceComments
- 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 interfaceComments
- Parameters:
isbn
- as the identifier of the book in questioncommentId
- as the id of the comment to be overwrittenupdatedComment
- as a string representing the updated comment
-
-