MATSIM
ExplodedConfigModule.java
Go to the documentation of this file.
1 
2 /* *********************************************************************** *
3  * project: org.matsim.*
4  * ExplodedConfigModule.java
5  * *
6  * *********************************************************************** *
7  * *
8  * copyright : (C) 2019 by the members listed in the COPYING, *
9  * LICENSE and WARRANTY file. *
10  * email : info at matsim dot org *
11  * *
12  * *********************************************************************** *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * See also COPYING, LICENSE and WARRANTY file *
19  * *
20  * *********************************************************************** */
21 
22  package org.matsim.core.controler;
23 
24 import com.google.inject.Binder;
25 import com.google.inject.Module;
26 import org.matsim.core.config.Config;
28 
29 public final class ExplodedConfigModule implements Module {
30  private final Config config;
31 
32  public ExplodedConfigModule(Config config) {
33  this.config = config;
34  }
35 
36  @Override
37  public void configure(Binder binder) {
38  binder.bind(Config.class).toInstance(config);
39  for (ConfigGroup configGroup : config.getModules().values()) {
40  Class materializedConfigGroupSubclass = configGroup.getClass();
41  if (materializedConfigGroupSubclass != ConfigGroup.class) {
42  binder.bind(materializedConfigGroupSubclass).toInstance(configGroup);
43  }
44  }
45  }
46 }
final TreeMap< String, ConfigGroup > getModules()
Definition: Config.java:288