Class DataSource<E extends DataEntity,​D>

    • Field Detail

      • id

        public final String id
        The ID of the data source.
      • decoder

        final IDecoder<D> decoder
        The decoder of the data source.
      • encoder

        final IEncoder<D> encoder
        The encoder of the data source.
    • Constructor Detail

      • DataSource

        DataSource​(String id,
                   IDecoder<D> decoder,
                   IEncoder<D> encoder)
        DataSource constructor.
        Parameters:
        id - the ID of the data source
        decoder - the decoder of the data source
        encoder - the encoder of the data source
      • DataSource

        DataSource​(String id,
                   IDecoder<D> decoder)
        DataSource constructor.
        Parameters:
        id - the ID of the data source
        decoder - the decoder of the data source
      • DataSource

        DataSource​(String id,
                   IEncoder<D> encoder)
        DataSource constructor.
        Parameters:
        id - the ID of the data source
        encoder - the encoder of the data source
    • Method Detail

      • getData

        List<E> getData​(Context context)
                 throws Exception
        Returns the list of data entities. Override this method to implement the get operation.
        Parameters:
        context - the context of the request
        Returns:
        the list of data entities
        Throws:
        UnsupportedOperationException - if not implemented
        Exception - if an error occurs
      • setData

        void setData​(Context context,
                     List<E> data)
              throws Exception
        Sets the list of data entities. Override this method to implement the set operation.
        Parameters:
        context - the context of the request
        data - the list of data entities
        Throws:
        UnsupportedOperationException - if not implemented
        Exception - if an error occurs
      • filter

        private List<E> filter​(Context context,
                               List<E> data)
        Filters the list of data entities by query, from date and to date, if supported. Uses parallel streams to filter the list of data entities in a faster way. Internally used by get(Context).
        Parameters:
        context - the context of the request
        data - the list of data entities
        Returns:
        the filtered list of data entities