Package org.salespointframework.catalog
Class Product
java.lang.Object
org.salespointframework.core.AbstractEntity<ID>
org.salespointframework.core.AbstractAggregateRoot<ProductIdentifier>
org.salespointframework.catalog.Product
- All Implemented Interfaces:
Comparable<Product>
,Persistable<ProductIdentifier>
@Entity public class Product extends AbstractAggregateRoot<ProductIdentifier> implements Comparable<Product>
A product.
- Author:
- Paul Henke, Oliver Gierke
-
Constructor Summary
-
Method Summary
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)
Streamable<String>
getCategories()
Returns the categories theProduct
is assigned to.ProductIdentifier
getId()
@NonNull String
getName()
@NonNull javax.money.MonetaryAmount
getPrice()
boolean
removeCategory(String category)
Product
setName(@NonNull String name)
Product
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, hasId, isNew
-
Constructor Details
-
Method Details
-
getId
- Specified by:
getId
in interfacePersistable<ProductIdentifier>
-
getCategories
Returns the categories theProduct
is assigned to.- Returns:
- will never be null.
-
addCategory
Adds theProduct
to the given category.- Parameters:
category
- must not be null or empty.- Returns:
-
removeCategory
-
supports
- Parameters:
quantity
-- Returns:
-
verify
- Parameters:
quantity
-- Throws:
MetricMismatchException
- in case theProduct
does not support the givenQuantity
.
-
createQuantity
- Parameters:
amount
- must not be null.- Returns:
-
createQuantity
- Parameters:
amount
- must not be null.- Returns:
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Product>
-
toString
-
getName
-
setName
-
getPrice
@NonNull public @NonNull javax.money.MonetaryAmount getPrice() -
setPrice
-