How can I get IntellijIDEA to find the 'andThen' method of the main java 8 'Function' interface when using the Funciton :: andThen notation? I have tried many things unsuccessfully.
My intellijIDEA module is configured for java 8, used by sdk - this is oracle java 8, I invalidated caches and tried several other things, but still the editor notes, and then as: "the method cannot be resolved" and "then", ".
I can run and build this sample, so I think it has something to do with a static code analyzer. Maybe a mistake?
package foo.bar;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
public class Meh {
public static void main(String... args) {
final List<Function<String, String>> fs = new ArrayList<>();
fs.add(s -> s + "1");
fs.add(s -> s + "2");
final Function<String, String> f =
fs.stream()
//copmiles from cli and project->make, but editor shows: Cannot resolve method 'andThen'
.reduce(Function::andThen)
.get();
System.out.println(f.apply(""));
final Function<String,String> f2 = f.andThen(s-> s+"a");
System.out.println(f2.apply(""));
}
}
- , f.andThen, . , :: andThen.
eclipse. , , → make