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 boolean
addCategory(String category)
Adds theProduct
to the given category.int
compareTo(Product other)
Quantity
createQuantity(double amount)
Quantity
createQuantity(long amount)
org.springframework.data.util.Streamable<String>
getCategories()
Returns the categories theProduct
is assigned to.ProductIdentifier
getId()
@NonNull String
getName()
@NonNull javax.money.MonetaryAmount
getPrice()
boolean
removeCategory(String category)
void
setName(@NonNull String name)
void
setPrice(@NonNull javax.money.MonetaryAmount price)
boolean
supports(Quantity quantity)
String
toString()
void
verify(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 newProduct
with 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:
getId
in interfaceorg.springframework.data.domain.Persistable<ProductIdentifier>
-
getCategories
public org.springframework.data.util.Streamable<String> getCategories()
Returns the categories theProduct
is assigned to.- Returns:
- will never be null.
-
addCategory
public final boolean addCategory(String category)
Adds theProduct
to 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 theProduct
does 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:
compareTo
in 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)
-
-