From 0763dee6a3acfd1be1fb943d3fb07aecb137b885 Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 27 Nov 2023 17:53:31 +0100 Subject: [PATCH] provide explanation comment --- .../java/org/matsim/core/controler/AbstractModule.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java b/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java index fec41cc88f6..d6d3eb94efa 100644 --- a/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java +++ b/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java @@ -113,6 +113,14 @@ public final void configure(Binder binder) { // not in this class. this.binder = binder.skipSources(AbstractModule.class); + initializeMultibinders(); + + this.install(); + } + + private void initializeMultibinders() { + // We do need to make these calls here in order to register the multi binders. Otherwise, guice doesn't know, that they exist. In particular, + // if none of the corresponding addXXXBinding methods was called, the set binder would not be registered, and guice would complain. this.mobsimListenerMultibinder = Multibinder.newSetBinder(this.binder, MobsimListener.class); this.snapshotWriterMultibinder = Multibinder.newSetBinder(this.binder, SnapshotWriter.class); this.eventHandlerMultibinder = Multibinder.newSetBinder(this.binder, EventHandler.class); @@ -124,7 +132,6 @@ public final void configure(Binder binder) { new TypeLiteral>() {} ); this.qsimModulesMultibinder = Multibinder.newSetBinder(this.binder, AbstractQSimModule.class); this.qsimOverridingModulesMultibinder = Multibinder.newSetBinder( this.binder, AbstractQSimModule.class, Names.named( "overridesFromAbstractModule" ) ); - this.install(); } public abstract void install();