java - Compile error in toMap() function of Stream on array of PropertyDescriptors -
i have following code:
propertydescriptor[] propertydescriptors = introspector.getbeaninfo(mailingadresse.class).getpropertydescriptors(); map<string, propertydescriptor> m = arrays .stream(propertydescriptors) .filter(pd -> pd.getreadmethod() != null) .collect(collectors.tomap(pd -> pd.getname().tolowercase(), function::identity));
eclipse shows
the method tomap(function, function) in type collectors not applicable arguments (( pd) -> {}, function::identity)
why this?
function.identity()
returns functional interface (function
), don't need method reference, need call method:
propertydescriptor[] propertydescriptors = introspector.getbeaninfo(mailingadresse.class).getpropertydescriptors(); map<string, propertydescriptor> m = arrays .stream(propertydescriptors) .filter(pd -> pd.getreadmethod() != null) .collect(collectors.tomap(pd -> pd.getname().tolowercase(), function.identity()));
Comments
Post a Comment