How to rewrite the Flat Chain example in Java 7
FlatChain theChain = new FlatChain.Builder()
(errorMessage, chain) ->
System.out.println("\tError received for <" + chain.getName() + ">: " + errorMessage)
This Java 7 porting requires more work than I initially expected. Indeed, lambda expressions need to be removed from the FlatChain and RecursiveChain interfaces (this is the quick and easy part actually). But the internal source code and the example applications also need to be changed as they extensively use lambdas and other Java 8 features.
I’ve done all these changes in a spike solution that I committed in the feature-java7-compatibility branch of the GitHub repository. I built the project with JDK 8 (I do not have JDK 7) with the “-target 1.7” and “-source 1.7” options. I tested it with a JRE 7u67 that I had on my box. Everything, seems to work fine. Can you please give it a try in your own environment?
As you will see in the feature-java7-compatibility branch, the ported source code is less elegant and less readable than the Java 8 version. For these reasons I will not merge these changes into the master branch. But at least you have now a Java 7 compatible version that should work for your project. You can also use it as an example if you need to port future versions of the FlatChain to Java 7.