public Order getById(String orderId) { List<Order> orders = storage.getOrders(); for (Order order : orders) { if (order.getOrderId().equals(orderId)) { return order; } } return null; }
public List<Order> getOlderThanDate(Date date) { List<Order> orders = storage.getOrders(); List<Order> result = new ArrayList<Order>(); for (Order order : orders) { if (order.getPurchaseDate().after(date)) { result.add(order); } } return result; }
public Map<Date, List<Order>> getOrdersByDate() { List<Order> orders = storage.getOrders(); Map<Date, List<Order>> result = new HashMap<Date, List<Order>>(); for (Order order : orders) { if (result.containsKey(order.getPurchaseDate())) { result.get(order.getPurchaseDate()).add(order); } else { List<Order> t = new ArrayList<Order>(); t.add(order); result.put(order.getPurchaseDate(), t); } } return result; }