I have a case as below:
RowDataSet rdsHavingMaxNumericValue = dataList.stream()
.filter(r -> r.getLong(NUMERIC_VALUE) != null)
.max((r1, r2) -> r1.getId().compareTo(r2.getId()))
.get();
I've two cases where I need to find either min or max depending on a case? how can i replace the call max at third line by a Function so that it direcly uses .apply() method and performs the operation?
I'v successfully assigned Collection.max or Collection min as below:
BiFunction<List<RowDataSet>, Comparator<RowDataSet>, RowDataSet> mrOrlrOperation = expComponents[0] == 'M' ? Collections::max : Collections::min;
and i use it as below:
RowDataSet rds = mrOrlrOperation.apply(dataList, <some comparator>);