Class Review
java.lang.Object
com.goldenleaf.shop.model.Review
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetId()intvoidSets a new author for the review.voidsetContent(String content) Sets the content of the review.voidsetRating(int rating) Sets the numeric rating for the review.
-
Constructor Details
-
Review
public Review()Default constructor required by JPA.
-
Review
public Review(Customer author, String content, int rating, Product product) throws IncorrectRatingException, EmptyAuthorException, EmptyContentException, EmptyProductException Constructs a new review with the given parameters. Validates all fields to ensure correctness.
- Parameters:
author- the customer who wrote the review; must not be nullcontent- the text content of the review; must not be null or blankrating- the rating from 1 to 5product- the product being reviewed; must not be null- Throws:
EmptyAuthorException- ifauthoris nullEmptyContentException- ifcontentis null or blankIncorrectRatingException- ifratingis outside the range 1–5EmptyProductException- ifproductis null- See Also:
-
-
Method Details
-
getId
- Returns:
- the unique identifier of the review
-
getAuthor
- Returns:
- the customer who authored the review
- See Also:
-
getContent
- Returns:
- the review content
-
getRating
public int getRating()- Returns:
- the numeric rating from 1 to 5
-
setAuthor
Sets a new author for the review.
- Parameters:
author- must not be null- Throws:
EmptyAuthorException- ifauthoris null- See Also:
-
setContent
Sets the content of the review.
- Parameters:
content- must not be null or blank- Throws:
EmptyContentException- ifcontentis null or blank
-
setRating
Sets the numeric rating for the review.
- Parameters:
rating- must be between 1 and 5- Throws:
IncorrectRatingException- ifratingis outside valid range
-