コード例 #1
0
 public Order getById(String orderId) {
   List<Order> orders = storage.getOrders();
   for (Order order : orders) {
     if (order.getOrderId().equals(orderId)) {
       return order;
     }
   }
   return null;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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;
 }