All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.gef.ReflectionHelper Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2012 Gerhardt Informatics Kft.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Gerhardt Informatics Kft. - GEFGWT port
 *******************************************************************************/
package org.eclipse.gef;

import java.util.HashMap;
import java.util.Map;

public class ReflectionHelper {

	private static Map helpers = new HashMap();

	public interface Instantiator {
		Object newInstance(Class c);
	}

	public static Object newInstance(Class type) {
		Instantiator instantiator = helpers.get(type);
		if (instantiator == null) {
			System.err.println("No instantiator for: " + type);
		}
		Object newInstance = instantiator.newInstance(type);
		if (newInstance == null) {
			System.err.println("No instance for: " + type);
		}
		return newInstance;
	}

	public static void registerHelper(Class c, Instantiator instantiator) {
		helpers.put(c, instantiator);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy