Interface DataSource<SelectorType,​DataType>

  • Type Parameters:
    SelectorType - The type which is used to select the data
    DataType - The type provided by this data source
    All Known Implementing Classes:
    AbstractCsvDataSource, AbstractDataSource

    public interface DataSource<SelectorType,​DataType>
    Data Sources act as bridge between tapir and arbitrary data formats.
    Since:
    3.0.0
    Author:
    Oliver Libutzki <[email protected]>
    • Method Detail

      • canHandle

        boolean canHandle​(SelectorType selector)
        This method is called by the framework in order to determine if the DataSource is able to provide data based on the given selector. If the method returns true, getData(Object) is called in order to obtain the data.

        canHandle is only called if the the selector is compatible with the Class returned by getSelectorType().

        Concrete data sources should rather extend AbstractDataSource than implementing this interface directly.

        Parameters:
        selector - the selector which is used to determine the data to be provided
        Returns:
        true, if the DataSource can provide data fpr the given selector, otherweise false.
        Since:
        3.0.0
      • getSelectorType

        java.lang.Class<SelectorType> getSelectorType()
        This method is called when a suitable DataSource is determined. DataSources can specify which selector types are supported.
        Returns:
        the supported selector type.
        Since:
        3.0.0
      • getData

        java.lang.Iterable<DataType> getData​(SelectorType selector)
        Returns the data for the given selector.
        Parameters:
        selector - the selector which is used to determine the data to be provided
        Returns:
        the data
        Since:
        3.0.0