es.prodevelop.pui9.export.DataExporterRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of es.prodevelop.pui9.services Show documentation
Show all versions of es.prodevelop.pui9.services Show documentation
Support for business layer (BO)
package es.prodevelop.pui9.export;
import java.util.EnumMap;
import java.util.Map;
import es.prodevelop.pui9.search.ExportType;
/**
* A registry with the available data exporters
*
* @author Marc Gil - [email protected]
*/
public class DataExporterRegistry {
private static DataExporterRegistry singleton;
public static DataExporterRegistry getSingleton() {
if (singleton == null) {
singleton = new DataExporterRegistry();
}
return singleton;
}
private Map map;
private DataExporterRegistry() {
map = new EnumMap<>(ExportType.class);
}
/**
* Register a new data exporter
*
* @param dataExporter The data exporter to be registered
*/
public void registerExporter(IDataExporter dataExporter) {
if (map.containsKey(dataExporter.getExportType())) {
throw new IllegalArgumentException(
"There exists more than one data exporter for '" + dataExporter.getExportType() + "' type");
}
map.put(dataExporter.getExportType(), dataExporter);
}
/**
* Get the registered exporter for the given type
*
* @param exportType The export type
* @return The data exporter associated with the given type
*/
public IDataExporter getExporter(ExportType exportType) {
return map.get(exportType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy