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

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -