Consider:
public Map<String, Ethernet> foo() throws SocketException {
var networkInterfaces = NetworkInterface.getNetworkInterfaces();
return Collections.list(networkInterfaces).stream()
.filter(iFace -> **iFace.getName()**.startsWith("w"))
.map(this::getEthernet)
.collect(Collectors.toMap(**iFace.getName()????**, Function.identity()));
}
public Ethernet getEthernet(NetworkInterface networkInterface) {
//return Ethernet
}
How can I correctly execute collect to get iFace.getName()
as the key and the Ethernet object as the value for each stream element?