Sort array of objects by one property of nested object
This is the part of the code that causes an error
Sell::getClient.name
Your can create a reference to a (static or non-static) method of an arbitrary object of a particular type. A reference to the getClient
method of any object of Sell
type looks like this :
Sell::getClient
But method references are not objects and don't have members to access. With this code you are trying to access a member variable of the reference (and can't)
Sell::getClient.name
Also, method references are not classes so you can't get another method reference from them. You couldn't do something like that if you tried :
Sell::getClient::getName
Correct syntax for your particular case was provided by @mlk :
x -> x.getClient().name
Sell::getClientName
(doesn't have to be a static method)