How to add default methods to Guice interface

Viewed 459

I've got the following interface:

public interface FooFactory {
    Foo create();

    default Foo createWithData(Data data){
        Foo foo = create();
        foo.addData(data);
        return foo;
    }
}

I'm installing it as follows:

install(new FactoryModuleBuilder().build(FooFactory.class));

However, the problem is that Guice overwrites my default method with its own factory method. The Foo I get back is the same Foo from create() (no data has been set). The default method never gets called.

Now, this is simply a convenience method, but is it possible for me to tell Guice not to overwrite my function?

1 Answers
Related