Skip to content

Commit

Permalink
Add it again
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenWoltmann committed Jun 1, 2023
1 parent 1ba1895 commit 34f1d98
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions model/src/main/java/eu/happycoders/shop/model/cart/Cart.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import java.util.List;
import java.util.Map;

/**
* A shopping cart of a particular customer, containing several line items.
*
* @author Sven Woltmann
*/
public class Cart {

private final CustomerId id; // cart ID = customer ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import eu.happycoders.shop.model.money.Money;
import eu.happycoders.shop.model.product.Product;

/**
* A shopping cart line item with a product and quantity.
*
* @author Sven Woltmann
*/
public class CartLineItem {

private final Product product;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package eu.happycoders.shop.model.cart;

/**
* An exception indicating that a customer wanted to add more items of a product to the cart than
* were available.
*
* @author Sven Woltmann
*/
public class NotEnoughItemsInStockException extends Exception {

private final int itemsInStock;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package eu.happycoders.shop.model.customer;

/**
* A customer ID value object (enabling type-safety and validation).
*
* @author Sven Woltmann
*/
public record CustomerId(int value) {

public CustomerId {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import java.util.Currency;
import java.util.Objects;

/**
* A money value object consisting of a currency and an amount.
*
* @author Sven Woltmann
*/
public record Money(Currency currency, BigDecimal amount) {

public static final Currency EUR = Currency.getInstance("EUR");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import eu.happycoders.shop.model.cart.NotEnoughItemsInStockException;
import eu.happycoders.shop.model.money.Money;

/**
* A product listed in the shop.
*
* @author Sven Woltmann
*/
@SuppressWarnings("PMD.ImmutableField") // name, description, etc... should eventually be modifiable
public class Product {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;

/**
* A product ID value object (enabling type-safety and validation).
*
* @author Sven Woltmann
*/
public record ProductId(String value) {

private static final String ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
Expand Down

0 comments on commit 34f1d98

Please sign in to comment.