Package org.salespointframework.catalog
Class Product
java.lang.Object
org.salespointframework.core.AbstractEntity<ID>
org.salespointframework.core.AbstractAggregateRoot<Product.ProductIdentifier>
org.salespointframework.catalog.Product
- All Implemented Interfaces:
Comparable<Product>
,Persistable<Product.ProductIdentifier>
@Entity
public class Product
extends AbstractAggregateRoot<Product.ProductIdentifier>
implements Comparable<Product>
A product.
- Author:
- Paul Henke, Oliver Gierke
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
{link ProductIdentifier} serves as an identifier type forProduct
objects. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
addCategory
(String category) Adds theProduct
to the given category.int
createQuantity
(double amount) createQuantity
(long amount) Returns the categories theProduct
is assigned to.getId()
@NonNull String
getName()
@NonNull javax.money.MonetaryAmount
getPrice()
final boolean
removeCategory
(String category) setPrice
(@NonNull javax.money.MonetaryAmount price) boolean
toString()
void
Methods inherited from class org.salespointframework.core.AbstractAggregateRoot
registerEvent
Methods inherited from class org.salespointframework.core.AbstractEntity
equals, hashCode, hasId, isNew
-
Constructor Details
-
Product
Creates a newProduct
with the given name and price.- Parameters:
name
- must not be null or empty.price
- must not be null.
-
Product
-
Product
Deprecated.
-
-
Method Details
-
getId
- Specified by:
getId
in interfacePersistable<Product.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
- Returns:
this
.
-
getPrice
@NonNull public @NonNull javax.money.MonetaryAmount getPrice() -
setPrice
- Returns:
this
.
-