franta-hg@28: /** franta-hg@28: * parameter-lister franta-hg@28: * Copyright © 2015 František Kučera (frantovo.cz) franta-hg@28: * franta-hg@28: * This program is free software: you can redistribute it and/or modify franta-hg@28: * it under the terms of the GNU General Public License as published by franta-hg@28: * the Free Software Foundation, either version 3 of the License, or franta-hg@28: * (at your option) any later version. franta-hg@28: * franta-hg@28: * This program is distributed in the hope that it will be useful, franta-hg@28: * but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@28: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@28: * GNU General Public License for more details. franta-hg@28: * franta-hg@28: * You should have received a copy of the GNU General Public License franta-hg@28: * along with this program. If not, see . franta-hg@28: */ franta-hg@21: package info.glogalcode.parameterLister.modules; franta-hg@21: franta-hg@21: import info.glogalcode.parameterLister.OutputModule; franta-hg@21: import info.glogalcode.parameterLister.OutputModuleFactory; franta-hg@21: import info.glogalcode.parameterLister.OutputModuleFactoryException; franta-hg@21: franta-hg@21: /** franta-hg@21: * franta-hg@21: * @author Ing. František Kučera (frantovo.cz) franta-hg@21: */ franta-hg@21: public abstract class AbstractModuleFactory implements OutputModuleFactory { franta-hg@21: franta-hg@21: private final Class clazz; franta-hg@21: private final String name; franta-hg@21: franta-hg@21: public AbstractModuleFactory(String name, Class clazz) { franta-hg@21: this.clazz = clazz; franta-hg@21: this.name = name; franta-hg@21: } franta-hg@21: franta-hg@21: @Override franta-hg@21: public String getName() { franta-hg@21: return name; franta-hg@21: } franta-hg@21: franta-hg@21: @Override franta-hg@21: public OutputModule createModule() throws OutputModuleFactoryException { franta-hg@21: try { franta-hg@21: return clazz.newInstance(); franta-hg@21: } catch (IllegalAccessException | InstantiationException e) { franta-hg@21: throw new OutputModuleFactoryException("Error while creating instance of class " + clazz + " for module " + name, e); franta-hg@21: } franta-hg@21: } franta-hg@21: franta-hg@21: }