Java Reference
In-Depth Information
to obtain desired
* stocks
* @return
*/
public List<Stock> alertListLegacy() {
System.out.println("==Legacy technique for filtering
and collecting==");
List<Stock> alertList = new ArrayList<>();
for (Stock stock : portfolio.values()) {
if (!StockScreener.screen(stock.getSymbol(),
StockScreener.Screen.PE, 20)) {
alertList.add(stock);
}
}
return alertList;
}
/**
* Utilize stream and filters to obtain desired stocks
* @return
*/
public List<Stock> alertList(){
return
portfolio.values().stream()
.filter(s->!StockScreener.screen(s.getSymbol(),
StockScreener.Screen.PE, 20))
.collect(Collectors.toList());
}
public void remove(List<String> sellList) {
Iterator<String> keyIter
= portfolio.keySet().iterator();
while (keyIter.hasNext()) {
if (sellList.contains(keyIter.next())) {
keyIter.remove();
}
Search WWH ::




Custom Search