001
002/* *********************************************************************** *
003 * project: org.matsim.*
004 * ExplodedConfigModule.java
005 *                                                                         *
006 * *********************************************************************** *
007 *                                                                         *
008 * copyright       : (C) 2019 by the members listed in the COPYING,        *
009 *                   LICENSE and WARRANTY file.                            *
010 * email           : info at matsim dot org                                *
011 *                                                                         *
012 * *********************************************************************** *
013 *                                                                         *
014 *   This program is free software; you can redistribute it and/or modify  *
015 *   it under the terms of the GNU General Public License as published by  *
016 *   the Free Software Foundation; either version 2 of the License, or     *
017 *   (at your option) any later version.                                   *
018 *   See also COPYING, LICENSE and WARRANTY file                           *
019 *                                                                         *
020 * *********************************************************************** */
021
022 package org.matsim.core.controler;
023
024import com.google.inject.Binder;
025import com.google.inject.Module;
026import org.matsim.core.config.Config;
027import org.matsim.core.config.ConfigGroup;
028
029public final class ExplodedConfigModule implements Module {
030        private final Config config;
031
032        public ExplodedConfigModule(Config config) {
033                this.config = config;
034        }
035
036        @Override
037        public void configure(Binder binder) {
038                binder.bind(Config.class).toInstance(config);
039                for (ConfigGroup configGroup : config.getModules().values()) {
040                        Class materializedConfigGroupSubclass = configGroup.getClass();
041                        if (materializedConfigGroupSubclass != ConfigGroup.class) {
042                                binder.bind(materializedConfigGroupSubclass).toInstance(configGroup);
043                        }
044                }
045        }
046}