Code example for TreeMap

0
/** 
 *  
 */ 
public class PortfolioPaymentDiary { 
 
  private final SortedMap<LocalDate, List<PositionPayment>> _paymentDiary = new TreeMap<LocalDate, List<PositionPayment>>();
   
  public void add(LocalDate date, PositionPayment payment) {
    List<PositionPayment> payments = _paymentDiary.get(date);
    if (payments == null) {
      payments = new ArrayList<PositionPayment>();
      _paymentDiary.put(date, payments);
    } 
    payments.add(payment);
  } 
   
  public List<LocalDate> getPaymentDates() {
    return new ArrayList<LocalDate>(_paymentDiary.keySet());
  } 
   
  public List<PositionPayment> getPayments(LocalDate date) {