This page documents the two key enumerations in the FoodTech Kitchen domain model: Station and TaskStatus. These enums define the fixed set of kitchen stations and the lifecycle states a task can be in.
Enums are used instead of strings to provide compile-time type safety and prevent invalid values from entering the system.
The Station enum represents the physical kitchen stations where food and beverages are prepared. Each station is responsible for specific types of products.
// Using Station in task creationTask task = new Task( orderId, Station.BAR, // Assign to bar "T-15", drinkProducts, LocalDateTime.now());// Checking station assignmentif (task.getStation() == Station.HOT_KITCHEN) { // Handle hot kitchen specific logic}// Getting station from product typeProduct drink = new Product("Mojito", ProductType.DRINK);Station station = drink.getType().getStation(); // Returns Station.BAR
Task task = new Task(orderId, station, "T-15", products, LocalDateTime.now());// Try to complete without startingtry { task.complete(); // Will throw IllegalStateException} catch (IllegalStateException e) { // "Task must be in IN_PREPARATION status to complete"}// Try to start twicetask.start();try { task.start(); // Will throw IllegalStateException} catch (IllegalStateException e) { // "Task must be in PENDING status to start"}
// Query current statusswitch (task.getStatus()) { case PENDING: System.out.println("Task is waiting to be started"); break; case IN_PREPARATION: System.out.println("Task is being prepared"); break; case COMPLETED: System.out.println("Task is finished"); break;}// Filter tasks by statusList<Task> pendingTasks = allTasks.stream() .filter(t -> t.getStatus() == TaskStatus.PENDING) .collect(Collectors.toList());
Adding new stations or status values requires code changes. This is intentional—station and status values are core to the business logic and should be carefully controlled.
To add a new station:
Add the new enum value to Station
Add a corresponding ProductType value
Update the ProductType to map to the new station
Update any UI or API documentation
// Example: Adding a dessert stationpublic enum Station { BAR, HOT_KITCHEN, COLD_KITCHEN, DESSERT_STATION // New station}public enum ProductType { DRINK(Station.BAR), HOT_DISH(Station.HOT_KITCHEN), COLD_DISH(Station.COLD_KITCHEN), DESSERT(Station.DESSERT_STATION); // New product type // ... rest of implementation}
Enums are usually persisted as strings or ordinal values:
@Entitypublic class TaskEntity { @Enumerated(EnumType.STRING) private Station station; @Enumerated(EnumType.STRING) private TaskStatus status;}
Use EnumType.STRING rather than EnumType.ORDINAL for database persistence. This makes the database more readable and prevents issues when reordering enum values.