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

pl.edu.icm.unity.engine.endpoint.EndpointFactoriesRegistry Maven / Gradle / Ivy

/*
 * Copyright (c) 2013 ICM Uniwersytet Warszawski All rights reserved.
 * See LICENCE.txt file for licensing information.
 */
package pl.edu.icm.unity.engine.endpoint;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import pl.edu.icm.unity.engine.api.endpoint.EndpointFactory;
import pl.edu.icm.unity.types.endpoint.EndpointTypeDescription;


/**
 * Registry of available {@link EndpointFactory}ies
 * @author K. Benedyczak
 */
@Component
public class EndpointFactoriesRegistry
{
	private Map factoriesById = new HashMap();
	private List factoriesDescriptions = new ArrayList();
	
	@Autowired
	public EndpointFactoriesRegistry(Optional> endpointFactories)
	{
		for (EndpointFactory factory: endpointFactories.orElseGet(ArrayList::new))
		{
			factoriesById.put(factory.getDescription().getName(), factory);
			factoriesDescriptions.add(factory.getDescription());
		}
	}
	
	public List getDescriptions()
	{
		List ret = new ArrayList(factoriesDescriptions.size());
		ret.addAll(factoriesDescriptions);
		return ret;
	}
	
	public EndpointFactory getById(String id)
	{
		return factoriesById.get(id);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy