Java 7 will have closures ( finally ), and I wonder how the existing code using single method classes/interfaces ( like Runnable, Comparator, etc ) will be used now.
Would that code be replaced? Will be a conversion of some sort? An extra method using the closure will be added?
Does anyone knows how is this going to work/what the plans are?
For instance, to use the FileFilter today we do:
....
File [] files = directory.listFiles( new FileFilter()
public boolean accept( File file ) {
return file.getName().endsWith(".java");
}
});
Does anyone knows how is this going to work on Java7?
Maybe overloading the method File.listFiles to receive a closure?
File [] files = directory.listFiles(#(File file){
return file.getName().endsWith(".java");
});