@Entity public class Product extends AbstractEntity<ProductIdentifier> implements Comparable<Product>
Modifier | Constructor and Description |
---|---|
protected |
Product() |
|
Product(String name,
javax.money.MonetaryAmount price)
Creates a new
Product with the given name and price. |
|
Product(String name,
javax.money.MonetaryAmount price,
Metric metric)
|
Modifier and Type | Method and Description |
---|---|
boolean |
addCategory(String category)
Adds the
Product to the given category. |
int |
compareTo(Product other) |
Quantity |
createQuantity(double amount)
|
Quantity |
createQuantity(long amount)
|
Streamable<String> |
getCategories()
Returns the categories the
Product is assigned to. |
ProductIdentifier |
getId() |
String |
getName() |
javax.money.MonetaryAmount |
getPrice() |
boolean |
removeCategory(String category) |
void |
setName(String name) |
void |
setPrice(javax.money.MonetaryAmount price) |
boolean |
supports(Quantity quantity)
|
String |
toString() |
void |
verify(Quantity quantity)
|
equals, hashCode, isNew
public Product(String name, javax.money.MonetaryAmount price)
Product
with the given name and price.name
- must not be null or empty.price
- must not be null.@Generated(value="lombok") protected Product()
public ProductIdentifier getId()
getId
in interface org.springframework.data.domain.Persistable<ProductIdentifier>
public final Streamable<String> getCategories()
Product
is assigned to.public final boolean addCategory(String category)
Product
to the given category.category
- must not be null or empty.public final boolean removeCategory(String category)
public boolean supports(Quantity quantity)
quantity
- public void verify(Quantity quantity)
quantity
- MetricMismatchException
- in case the Product
does not support the given Quantity
.public Quantity createQuantity(double amount)
amount
- must not be null.public Quantity createQuantity(long amount)
amount
- must not be null.public int compareTo(Product other)
compareTo
in interface Comparable<Product>
@Generated(value="lombok") public String toString()
@NonNull @Generated(value="lombok") public String getName()
@Generated(value="lombok") public void setName(@NonNull String name)
@NonNull @Generated(value="lombok") public javax.money.MonetaryAmount getPrice()
@Generated(value="lombok") public void setPrice(@NonNull javax.money.MonetaryAmount price)
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.