How to override module

35 views
Skip to first unread message

Sammy

unread,
Jan 29, 2019, 6:21:32 AM1/29/19
to google-guice
Hi,
I got below final module

public final class WriterModule extends AbstractModule {

with below provides

@ProvidesIntoOptional(Type.DEFAULT)
public TopicNameFactory provideDefaultTopicNameFactory() {
return new TopicNameFactory.Default();
}


This is from in-house library which can't be changed without affecting/testing many other application. 

How do I override this TopicNameFactory to custom ABCTopicNameFactory.


Stephan Classen

unread,
Jan 29, 2019, 6:27:16 AM1/29/19
to google...@googlegroups.com
Look at the class Modules. There is a method "override"

Usage:
Modules.override(new WriterModule()).with(new AbcWriterModule())
--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/f1263a43-e3dc-4be6-bff7-d50d50f54d70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages