All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.easimart.OfflineQueryController Maven / Gradle / Ivy

package co.easimart;

import java.util.List;

import bolts.Task;

/** package */ class OfflineQueryController extends AbstractQueryController {

  private final OfflineStore offlineStore;
  private final EasimartQueryController networkController;

  public OfflineQueryController(OfflineStore store, EasimartQueryController network) {
    offlineStore = store;
    networkController = network;
  }

  @Override
  public  Task> findAsync(
      EasimartQuery.State state,
      EasimartUser user,
      Task cancellationToken) {
    if (state.isFromLocalDatastore()) {
      return offlineStore.findFromPinAsync(state.pinName(), state, user);
    } else {
      return networkController.findAsync(state, user, cancellationToken);
    }
  }

  @Override
  public  Task countAsync(
      EasimartQuery.State state,
      EasimartUser user,
      Task cancellationToken) {
    if (state.isFromLocalDatastore()) {
      return offlineStore.countFromPinAsync(state.pinName(), state, user);
    } else {
      return networkController.countAsync(state, user, cancellationToken);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy