The Product class represents a food or beverage item that can be ordered by customers. Each product has a name and a type that determines which kitchen station will prepare it. Products are immutable value objects in the domain model.
Product follows the Value Object pattern from Domain-Driven Design. Two products with the same name and type are considered equal.
private void validate(String name, ProductType type) { if (name == null || name.isBlank()) { throw new IllegalArgumentException("Product name cannot be null or empty"); } if (type == null) { throw new IllegalArgumentException("Product type cannot be null"); }}
The ProductType enum defines the three types of products and their associated stations:
public enum ProductType { DRINK(Station.BAR), HOT_DISH(Station.HOT_KITCHEN), COLD_DISH(Station.COLD_KITCHEN); private final Station station; ProductType(Station station) { this.station = station; } public Station getStation() { return station; }}
The implementation includes a design comment explaining an architectural decision:
//HUMAN REVIEW: Agregué campo station a ProductType para eliminar violación OCP.//Ahora cada ProductType conoce su Station, eliminando necesidad de ProductStationMapper.//Cumple OCP: agregar nuevo tipo no requiere modificar otras clases.
This design choice:
Eliminates the need for a separate ProductStationMapper class
Follows OCP (Open-Closed Principle) - new product types can be added without modifying existing code
Encapsulates the station mapping logic within the enum itself
Reduces coupling between domain classes
This is an example of refactoring toward better adherence to SOLID principles. The station mapping is now a property of the product type itself, not an external mapping.