Package edu.ie3.datamodel.io.processor
Class ProcessorProvider
java.lang.Object
edu.ie3.datamodel.io.processor.ProcessorProvider
Wrapper providing the class specific processor to convert an instance of a
UniqueEntity
into a mapping from attribute to value which can be used to write data e.g. into .csv files. This
wrapper can always be used if it's not clear which specific instance of a subclass of UniqueEntity
is received in the implementation. It can either be used for specific entity
processors only or as a general provider for all known entity processors.- Since:
- 20.03.20
-
Constructor Summary
ConstructorDescriptionGet an instance of this class with all existing entity processorsProcessorProvider
(Collection<EntityProcessor<? extends UniqueEntity>> entityProcessors, Map<TimeSeriesProcessorKey, TimeSeriesProcessor<TimeSeries<TimeSeriesEntry<Value>, Value>, TimeSeriesEntry<Value>, Value>> timeSeriesProcessors) Get an instance of this class based on the provided collection of processors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<EntityProcessor<? extends UniqueEntity>>
Build a collection of all existing processorsstatic Collection<EntityProcessor<? extends UniqueEntity>>
Build a collection of all input processorsstatic Collection<EntityProcessor<? extends UniqueEntity>>
Build a collection of all result processorsstatic Map<TimeSeriesProcessorKey,
TimeSeriesProcessor<TimeSeries<TimeSeriesEntry<Value>, Value>, TimeSeriesEntry<Value>, Value>> Create processors for all known eligible combinations and map themString[]
getHeaderElements
(TimeSeriesProcessorKey processorKey) Returns the header of a given time series combination or throws an exception if no processor for the given combination is known by this provider.String[]
getHeaderElements
(Class<? extends UniqueEntity> clazz) Returns the header of a given entity class or throws an exception if no processor for the given class is known by this provider.List<Class<? extends UniqueEntity>>
Returns all classes that are registered within entity processors known by this provider<T extends UniqueEntity>
Optional<LinkedHashMap<String,String>> handleEntity
(T entity) <T extends TimeSeries<E,
V>, E extends TimeSeriesEntry<V>, V extends Value>
Optional<Set<LinkedHashMap<String,String>>> handleTimeSeries
(T timeSeries) Searches for the right processor and returns its result
-
Constructor Details
-
ProcessorProvider
public ProcessorProvider()Get an instance of this class with all existing entity processors -
ProcessorProvider
public ProcessorProvider(Collection<EntityProcessor<? extends UniqueEntity>> entityProcessors, Map<TimeSeriesProcessorKey, TimeSeriesProcessor<TimeSeries<TimeSeriesEntry<Value>, Value>, TimeSeriesEntry<Value>, Value>> timeSeriesProcessors) Get an instance of this class based on the provided collection of processors- Parameters:
entityProcessors
- the processors for entities that should be known by this providertimeSeriesProcessors
- the processors for time series that should be known by this provider
-
-
Method Details
-
handleEntity
-
handleTimeSeries
public <T extends TimeSeries<E,V>, Optional<Set<LinkedHashMap<String,E extends TimeSeriesEntry<V>, V extends Value> String>>> handleTimeSeries(T timeSeries) Searches for the right processor and returns its result- Type Parameters:
T
- Type of the time seriesE
- Type of the time series entriesV
- Type of the value inside the time series entries- Parameters:
timeSeries
- Time series to process- Returns:
- A set of mappings from field name to value
-
getRegisteredClasses
Returns all classes that are registered within entity processors known by this provider- Returns:
- all classes this provider hols a processor for
-
getRegisteredTimeSeriesCombinations
-
getHeaderElements
public String[] getHeaderElements(Class<? extends UniqueEntity> clazz) throws ProcessorProviderException Returns the header of a given entity class or throws an exception if no processor for the given class is known by this provider.- Parameters:
clazz
- the class the header elements are requested for- Returns:
- the header elements of the requested class
- Throws:
ProcessorProviderException
- If no matching processor can be found
-
getHeaderElements
public String[] getHeaderElements(TimeSeriesProcessorKey processorKey) throws ProcessorProviderException Returns the header of a given time series combination or throws an exception if no processor for the given combination is known by this provider.- Parameters:
processorKey
- Time series combination- Returns:
- the header elements of the requested class
- Throws:
ProcessorProviderException
- If no matching processor can be found
-
allEntityProcessors
Build a collection of all existing processors- Returns:
- a collection of all existing processors
-
allInputEntityProcessors
Build a collection of all input processors- Returns:
- a collection of all input processors
-
allResultEntityProcessors
Build a collection of all result processors- Returns:
- a collection of all result processors
-
allTimeSeriesProcessors
public static Map<TimeSeriesProcessorKey,TimeSeriesProcessor<TimeSeries<TimeSeriesEntry<Value>, allTimeSeriesProcessors()Value>, TimeSeriesEntry<Value>, Value>> Create processors for all known eligible combinations and map them- Returns:
- A mapping from eligible combinations to processors
-