/* * Moonlight|3D Copyright (C) 2006 The Moonlight|3D team * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Created on May 27, 2006 */ package ml.core.helper; /** * A default factory implementation. This factory takes a java.lang.Class * object for the type that it should instantiate and a type name. * * @see java.lang.Class, ml.core.helper.Factory * * @author gregor */ public class DefaultFactory implements Factory { private final Class product; private final String name; public DefaultFactory(String name, Class product) { this.name=name; this.product=product; } public Object createNew() { try { return product.newInstance(); } catch (InstantiationException e) { // TODO find a better way of handling this exception e.printStackTrace(); } catch (IllegalAccessException e) { // TODO find a better way of handling this exceptoin e.printStackTrace(); } return null; } public String getName() { return name; } }