/**
  * 把list转为map 方便查找
  *
  * @param list 数据库有效数据列表
  * @return map
  */
 private <T extends TrendValue> Map<String, T> tomap(List<T> list) {
   Map<String, T> map = new LinkedHashMap<>();
   for (T value : list) {
     map.put(value.getDate(), value);
   }
   return map;
 }
Example #2
0
 protected T chooseLatest(T ae, String identifier) {
   T chosen;
   T existing = get(identifier);
   final Date inputDate = ae.getDate("updated_at");
   final Date existingDate = (existing == null ? null : existing.getDate("updated_at"));
   if (existing == null
       || (inputDate != null && existingDate == null)
       || (inputDate != null && inputDate.after(existingDate))) {
     if (mEntryList.get(identifier) instanceof SoftReference) {
       mEntryList.put(identifier, new SoftReference<T>(ae));
     } else {
       mEntryList.put(identifier, new WeakReference<T>(ae));
     }
     chosen = ae;
   } else {
     chosen = existing;
   }
   return chosen;
 }