I have the following Objects
Class Trade{
private Integer tradeId;
private Event eventId;
private Integer tradeVersion;
}
Class Event{
private Integer value;
}
- For the above scenario I am trying to write something like
Comparator.comparing(Trade::getEventId().getValue()) - The above did not work
So for now I went with the usual lambda which is the following
someList.sort((Trade o1, Trade o2) -> o1.getEventId().getValue().compareTo(o2.getEventId().getValue()));
and it worked but curious to know if #1 is possible?
- Tried
Comparator.comparing(Trade::getEventId).thenComparing(Event::getValue)but no joy. - Note that both of these classes are third party so I cannot alter them.