Package org.salespointframework.catalog
Class Product
java.lang.Object
org.salespointframework.core.AbstractEntity<Product.ProductIdentifier>
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 forProductobjects. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanaddCategory(String category) Adds theProductto the given category.intcreateQuantity(double amount) createQuantity(long amount) Returns the categories theProductis assigned to.getId()Returns the unique id of thisProduct.@NonNull StringgetName()@NonNull javax.money.MonetaryAmountgetPrice()final booleanremoveCategory(String category) setPrice(@NonNull javax.money.MonetaryAmount price) booleantoString()voidMethods inherited from class org.salespointframework.core.AbstractAggregateRoot
registerEventMethods inherited from class org.salespointframework.core.AbstractEntity
equals, hashCode, hasId, isNew
-
Constructor Details
-
Product
Creates a newProductwith the given name and price.- Parameters:
name- must not be null or empty.price- must not be null.
-
Product
-
Product
Deprecated.
-
-
Method Details
-
getId
Returns the unique id of thisProduct.- Specified by:
getIdin interfacePersistable<Product.ProductIdentifier>- Returns:
- will never be null
-
getCategories
Returns the categories theProductis assigned to.- Returns:
- will never be null.
-
addCategory
Adds theProductto the given category.- Parameters:
category- must not be null or empty.- Returns:
-
removeCategory
-
supports
- Parameters:
quantity-- Returns:
-
verify
- Parameters:
quantity-- Throws:
MetricMismatchException- in case theProductdoes not support the givenQuantity.
-
createQuantity
- Parameters:
amount- must not be null.- Returns:
-
createQuantity
- Parameters:
amount- must not be null.- Returns:
-
compareTo
- Specified by:
compareToin interfaceComparable<Product>
-
toString
-
getName
-
setName
- Returns:
this.
-
getPrice
@NonNull public @NonNull javax.money.MonetaryAmount getPrice() -
setPrice
- Returns:
this.
-