Class Product

java.lang.Object
com.goldenleaf.shop.model.Product

@Entity public class Product extends Object

Represents a product available for purchase in the system. A product contains core details such as name, brand, price, categories, associated image URLs, and user reviews.

The class ensures validation of required fields such as product name, brand, and price, preventing creation of invalid product objects.

See Also:
  • Constructor Details

  • Method Details

    • getId

      public Long getId()
      Returns:
      the unique product identifier
    • getName

      public String getName()
      Returns:
      the product name
    • setName

      public void setName(String name) throws EmptyNameException

      Sets a new name for the product.

      Parameters:
      name - must not be null or blank
      Throws:
      EmptyNameException - if name is null or blank
    • getBrand

      public String getBrand()
      Returns:
      the brand name
    • setBrand

      public void setBrand(String brand)

      Sets a new product brand.

      Parameters:
      brand - the brand to set
    • getPrice

      public double getPrice()
      Returns:
      the product price
    • setPrice

      public void setPrice(double price)

      Sets the price of the product.

      Parameters:
      price - must not be negative
    • getCategories

      public Set<Category> getCategories()
      Returns:
      categories assigned to this product
      See Also:
    • setCategories

      public void setCategories(Set<Category> categories)

      Sets the categories associated with this product.

      Parameters:
      categories - the categories to assign
    • getImageUrls

      public List<String> getImageUrls()
      Returns:
      list of image URLs
    • setImageUrls

      public void setImageUrls(List<String> imageUrls)

      Sets the image URLs associated with this product.

      Parameters:
      imageUrls - a list of image URL strings
    • getReviews

      public List<Review> getReviews()
      Returns:
      list of reviews for this product
      See Also:
    • setReviews

      public void setReviews(List<Review> reviews)

      Sets the list of reviews for this product.

      Parameters:
      reviews - the new list of reviews
      See Also:
    • addReview

      public void addReview(Review review)

      Adds a new review for this product.

      Parameters:
      review - the review to add
      See Also: