Understanding Gluon Ignite Lambda Idiom

249 views Asked by At

I set up a JavaFX Gluon Project using the Eclipse Gluon plugin and tried to get Gluon Ignite (Gluon Ignite; basically a wrapper framework to be able to use CDI in JavaFX) with Dagger going.

In an tutorial I found the following Java 8 Lambda expression to create a DaggerContext object:

private final DaggerContext context = new DaggerContext(this, () -> Arrays.asList(new DaggerModule()));

This confuses me a bit as I'm quite new to Lambda expressions. Though, if it had worked flawlessly I probably wouldn't ask this question - but it doesn't ;) Eclipse reports '

The constructor DaggerContext(GluonApplication, () -> {}) is undefined

So could someone tell me step by step what's going on there? Maybe the conservative version of code would help to understand it a bit better.

I know lambda expressions like this are used as a short form to create objects of anonymous classes. So when looking at the constructor of DaggerContext I see that the expression () -> Arrays.asList(new DaggerModule()) should create an object with type Supplier<Collection<Object>>, but this obviously doesn't work.

--- UPDATE ---

The problem was just a simple import problem. I had to add import java.util.Arrays; to resolve the error. Sill, It would be nice, if someone could provide some further explanation of the lambda expression.

0

There are 0 answers