Package org.salespointframework.catalog
Class Product
- java.lang.Object
-
- org.salespointframework.core.AbstractEntity<ProductIdentifier>
-
- org.salespointframework.catalog.Product
-
- All Implemented Interfaces:
Comparable<Product>,org.springframework.data.domain.Persistable<ProductIdentifier>
@Entity public class Product extends AbstractEntity<ProductIdentifier> implements Comparable<Product>
A product.- Author:
- Paul Henke, Oliver Gierke
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddCategory(String category)Adds theProductto the given category.intcompareTo(Product other)QuantitycreateQuantity(double amount)QuantitycreateQuantity(long amount)org.springframework.data.util.Streamable<String>getCategories()Returns the categories theProductis assigned to.ProductIdentifiergetId()@NonNull StringgetName()@NonNull javax.money.MonetaryAmountgetPrice()booleanremoveCategory(String category)voidsetName(@NonNull String name)voidsetPrice(@NonNull javax.money.MonetaryAmount price)booleansupports(Quantity quantity)StringtoString()voidverify(Quantity quantity)-
Methods inherited from class org.salespointframework.core.AbstractEntity
equals, hashCode, isNew
-
-
-
-
Constructor Detail
-
Product
public Product(String name, javax.money.MonetaryAmount price)
Creates a newProductwith the given name and price.- Parameters:
name- must not be null or empty.price- must not be null.
-
Product
protected Product()
-
-
Method Detail
-
getId
public ProductIdentifier getId()
- Specified by:
getIdin interfaceorg.springframework.data.domain.Persistable<ProductIdentifier>
-
getCategories
public org.springframework.data.util.Streamable<String> getCategories()
Returns the categories theProductis assigned to.- Returns:
- will never be null.
-
addCategory
public final boolean addCategory(String category)
Adds theProductto the given category.- Parameters:
category- must not be null or empty.- Returns:
-
removeCategory
public final boolean removeCategory(String category)
-
supports
public boolean supports(Quantity quantity)
- Parameters:
quantity-- Returns:
-
verify
public void verify(Quantity quantity)
- Parameters:
quantity-- Throws:
MetricMismatchException- in case theProductdoes not support the givenQuantity.
-
createQuantity
public Quantity createQuantity(double amount)
- Parameters:
amount- must not be null.- Returns:
-
createQuantity
public Quantity createQuantity(long amount)
- Parameters:
amount- must not be null.- Returns:
-
compareTo
public int compareTo(Product other)
- Specified by:
compareToin interfaceComparable<Product>
-
getName
@NonNull public @NonNull String getName()
-
setName
public void setName(@NonNull @NonNull String name)
-
getPrice
@NonNull public @NonNull javax.money.MonetaryAmount getPrice()
-
setPrice
public void setPrice(@NonNull @NonNull javax.money.MonetaryAmount price)
-
-