Example #1
0
  @Override
  public List<Period> separate(Items items) {

    final SimpleDateFormat byMonthFormat = new SimpleDateFormat("yyyy-MM");

    final Map<String, Items> separatedItems = new TreeMap<String, Items>();

    for (Item item : items) {
      final String key = byMonthFormat.format(item.getDate());
      if (!separatedItems.containsKey(key)) {
        separatedItems.put(key, items.copyStructure());
      }
      separatedItems.get(key).add(item);
    }

    return toSortedList(separatedItems);
  }
 @Override
 public Object retrieve(Item item, String propertyName) {
   return item.getProperty(propertyName);
 }