package com.getbase.android.db.provider;

import com.getbase.android.db.common.QueryData;
import com.getbase.android.db.cursors.FluentCursor;

import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.RemoteException;

public class Query extends ProviderAction<FluentCursor> {

  private final Selection selection = new Selection();
  private final Projection projection = new Projection();
  private String orderBy;

  Query(Uri uri) {
    super(uri);
  }

  public Query projection(String... projection) {
    this.projection.append(projection);
    return this;
  }

  public Query where(String selection, Object... selectionArgs) {
    this.selection.append(selection, selectionArgs);
    return this;
  }

  public Query orderBy(String orderBy) {
    this.orderBy = orderBy;
    return this;
  }

  public QueryData getQueryData() {
    return new QueryData(getUri(),
        projection.getProjection(),
        selection.getSelection(),
        selection.getSelectionArgs(),
        orderBy
    );
  }

  @Override
  public FluentCursor perform(CrudHandler crudHandler) throws RemoteException {
    final Cursor queryResult = crudHandler.query(getUri(),
        projection.getProjection(),
        selection.getSelection(),
        selection.getSelectionArgs(),
        orderBy
    );
    return new FluentCursor(queryResult);
  }
}
@@ -134,16 +134,54 @@
 tCursor;
+%0Aimport com.google.common.base.Joiner;
 %0A%0Aimport
@@ -306,16 +306,76 @@
 ption;%0A%0A
+import java.util.Collection;%0Aimport java.util.Collections;%0A%0A
 public c
@@ -850,32 +850,264 @@
 turn this;%0A  %7D%0A%0A
+  public %3CT%3E Query whereIn(String column, Collection%3CT%3E collection) %7B%0A    this.selection.append(column + %22 IN (%22 + Joiner.on(%22,%22).join(Collections.nCopies(collection.size(), %22?%22)) + %22)%22, collection.toArray());%0A    return this;%0A  %7D%0A%0A
   public Query o

Introduce whereIn