java - Not able to resolve the type of a lambda parameter -
so trying implement custom collector unfortunatelly stuck @ pretty interesting problem:
@override public biconsumer<map<localdate, list<tripresultdto>>, tripresultdto> accumulator() { return (acc,elem) -> { long departuretime = elem.getoutbound().getdeparturetimelocal(); localdate departuredate = new localdatetime(departuretime).tolocaldate(); list<tripresultdto> othersinthesameday = acc.getordefault(departuredate,new linkedlist<>()); othersinthesameday.add(elem); acc.put(departuredate,othersinthesameday); }; }
so in code above, compiler cannot resolve of methods of elem object of type tripresultdto
.
needless getoutbound
method highlighted in red , cannot resolved. quite strange looking @ intelli sense tripresultsdto
seems treated instance of object
rather tripresultdto
. have idea why might happening.
also idea doing doing in better way welcome.
so pretty noob mistake. had done in signature of collector was:
public class cheapestperdaycollector <tripresultdto> implements collector<tripresultdto, map<localdate, list<tripresultdto>>, list<tripresultdto>> {
which signified tripresultsdto generic type rather actual class. rewrote :
public class cheapestperdaycollector implements collector<tripresultdto, map<localdate, list<tripresultdto>>, list<tripresultdto>> {
and works fine.
Comments
Post a Comment