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

de.intarsys.tools.factory.StandardOutlet Maven / Gradle / Ivy

There is a newer version: 4.11
Show newest version
package de.intarsys.tools.factory;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class StandardOutlet implements IOutlet {

	private Map factories = new HashMap();

	public IFactory[] getFactories() {
		return factories.values().toArray(new IFactory[factories.size()]);
	}

	public IFactory[] lookupFactories(Class type) {
		Set result = new HashSet();
		for (IFactory factory : factories.values()) {
			Class resultType = factory.getResultType();
			if (resultType != null && type.isAssignableFrom(resultType)) {
				result.add(factory);
			}
		}
		return result.toArray(new IFactory[result.size()]);
	}

	public IFactory lookupFactory(String id) {
		return factories.get(id);
	}

	public void registerFactory(IFactory factory) {
		factories.put(factory.getId(), factory);
	}

	public void unregisterFactory(IFactory factory) {
		factories.remove(factory.getId());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy