SHARE
TWEET

Untitled

a guest Jun 26th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     private List<Stock> getExpiringStockMap(List<Stock> stocks) {
  2.         Map<String, Stock> stockMap = new HashMap<>();
  3.         for (Stock stock : stocks) {
  4.             long notificationDate = DateUtils.subtractDays(stock.getExpirationDate(), stock.getDaysUntilNotif());
  5.             if (DateUtils.onOrBeforeDate(notificationDate, now())) {
  6.                 if (stockMap.containsKey(stock.getSupplyCode())) {
  7.                     Stock oldStock = stockMap.get(stock.getSupplyCode());
  8.                     if (oldStock.getExpirationDate() < stock.getExpirationDate()) {
  9.                         stockMap.put(stock.getSupplyCode(), oldStock);
  10.                     } else {
  11.                         stockMap.put(stock.getSupplyCode(), stock);
  12.                     }
  13.                 } else {
  14.                     stockMap.put(stock.getSupplyCode(), stock);
  15.                 }
  16.             }
  17.         }
  18.         return new ArrayList<>(stockMap.values());
  19.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top