mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-06-30 21:03:42 +02:00
38 lines
785 B
Java
38 lines
785 B
Java
package catering.order;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* This class is only used for the prototype to avoid using the bloated Salespoint API
|
|
*/
|
|
@Component
|
|
public class CustomOrderRepository {
|
|
private Set<CustomOrder> orders;
|
|
|
|
public CustomOrderRepository() {
|
|
this.orders = new HashSet<>();
|
|
}
|
|
|
|
public boolean addOrder(CustomOrder order) {
|
|
return this.orders.add(order);
|
|
}
|
|
|
|
public boolean removeOrder(int orderID) {
|
|
for (CustomOrder order : orders) {
|
|
if (order.getId() == orderID) {
|
|
return this.orders.remove(order);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public Collection<CustomOrder> getOrders() {
|
|
return new ArrayList<>(this.orders);
|
|
}
|
|
}
|