question

Upvotes
Accepted
1 1 2 6

How to rewrite the Flat Chain example in Java 7

How to rewrite the Flat Chain example in Java 7

e.g.

FlatChain theChain = new FlatChain.Builder()
.withOmmConsumer(ommConsumer)
.withChainName(chainName)
.withServiceName(serviceName)
.withNameGuessingOptimization(nbOfNamesToGuessForOptimization)
.onChainComplete(
(chain) ->
printChain(chain)
)
.onChainError(
(errorMessage, chain) ->
System.out.println("\tError received for <" + chain.getName() + ">: " + errorMessage)
)
.build();

elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
Accepted
942 8 9 13

Hi @OX,

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.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
942 8 9 13

Hi @OX,

These lambda expressions can be replaced by instance of classes that implement the different interfaces (ElementAddedFunction, ElementChangedFunction…).

Let me do some tests and I’ll expand on this solution.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea