Class Repository<S extends DataSource<E,​?>,​E extends DataEntity,​M extends IModel>

    • Field Detail

      • dataSource

        final S extends DataSource<E,​?> dataSource
        The data source.
    • Constructor Detail

      • Repository

        Repository​(S dataSource)
        Creates a new Repository.
        Parameters:
        dataSource - The data source
    • Method Detail

      • pull

        public final List<M> pull​(Context context)
                           throws Exception
        Pulls the models from the data source. If the models are cached, the cache is used to improve performance.
        Parameters:
        context - The context to use
        Returns:
        List of models
        Throws:
        UnsupportedOperationException - if not implemented
        Exception - if an error occurs
      • pullData

        List<M> pullData​(Context context)
                  throws Exception
        Pulls the models from the data source. Provides a default implementation that uses the data source. Override this method to implement a custom pull.
        Parameters:
        context - The context to use
        Returns:
        List of models
        Throws:
        Exception - if an error occurs
      • pushData

        void pushData​(Context context,
                      List<M> models)
               throws Exception
        Pushes the models to the data source. Provides a default implementation that uses the data source. Override this method to implement a custom push.
        Parameters:
        context - The context to use
        models - The models to push
        Throws:
        UnsupportedOperationException - if not implemented
        Exception - if an error occurs
      • adapt

        M adapt​(E dataEntity)
        Adapts a data entity to a model. Internally used by pull(Context).
        Parameters:
        dataEntity - The data entity
        Returns:
        The model
        Throws:
        UnsupportedOperationException - if not implemented