Package de.bmiag.tapir.datasource.api
Class AbstractDataSource<SelectorType,SourceDataType,TargetDataType>
- java.lang.Object
-
- de.bmiag.tapir.datasource.api.AbstractDataSource<SelectorType,SourceDataType,TargetDataType>
-
- Type Parameters:
SelectorType
-SourceDataType
-TargetDataType
-
- All Implemented Interfaces:
DataSource<SelectorType,TargetDataType>
- Direct Known Subclasses:
AbstractCsvDataSource
public abstract class AbstractDataSource<SelectorType,SourceDataType,TargetDataType> extends java.lang.Object implements DataSource<SelectorType,TargetDataType>
AbstractDataSource
is a convenience abstract class which fits well forIterator
based results. It ensures thatgetData(Object)
returns an immutableList
.- Since:
- 3.0.0
- Author:
- Oliver Libutzki <[email protected]>
-
-
Constructor Summary
Constructors Constructor Description AbstractDataSource()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<TargetDataType>
getData(SelectorType selector)
Returns the data for the given selector.protected abstract java.util.Iterator<SourceDataType>
getIterator(SelectorType selector)
Returns an iterator which traverses the source data types.protected abstract TargetDataType
mapDataSet(SourceDataType dataset)
Maps from the source type to the target type.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.bmiag.tapir.datasource.api.DataSource
canHandle, getSelectorType
-
-
-
-
Method Detail
-
getIterator
protected abstract java.util.Iterator<SourceDataType> getIterator(SelectorType selector)
Returns an iterator which traverses the source data types. Each entry is processed bymapDataSet(Object)
.- Parameters:
selector
- the selector which is used to determine the data to be provided- Returns:
- an iterator which reflects the provided data sets
- Since:
- 3.0.0
-
mapDataSet
protected abstract TargetDataType mapDataSet(SourceDataType dataset)
Maps from the source type to the target type. This method is invoked for every data set returned bygetIterator(Object)
.- Parameters:
dataset
- the object to be mapped- Returns:
- the mapped object
- Since:
- 3.0.0
-
getData
public java.lang.Iterable<TargetDataType> getData(SelectorType selector)
Description copied from interface:DataSource
Returns the data for the given selector.- Specified by:
getData
in interfaceDataSource<SelectorType,SourceDataType>
- Parameters:
selector
- the selector which is used to determine the data to be provided- Returns:
- the data
-
-