/**
  * do a head request on the StackMob platform
  *
  * @param query the query to run
  * @param options additional options, such as headers, to modify the request
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 public void head(StackMobQuery query, StackMobOptions options, StackMobRawCallback callback) {
   this.head(
       "/" + query.getObjectName(),
       query.getArguments(),
       options.withHeaders(query.getHeaders()).getHeaders(),
       callback);
 }
 /**
  * atomically remove elements from an array or has many relationship
  *
  * @param path the path to get
  * @param primaryId id of the object with the relation
  * @param field name of the relation or array field to delete from
  * @param idsToDelete list of ids to atomically remove from field. ids should be same type as the
  *     primary id of the related type (most likely String or Integer)
  * @param cascadeDeletes true if related objects specified in idsToDelete should also be deleted
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 public <T> void deleteIdsFrom(
     String path,
     String primaryId,
     String field,
     List<T> idsToDelete,
     boolean cascadeDeletes,
     StackMobRawCallback callback) {
   StringBuilder ids = new StringBuilder();
   for (int i = 0; i < idsToDelete.size(); i++) {
     ids.append(idsToDelete.get(i).toString());
     if (i < idsToDelete.size() - 1) {
       ids.append(",");
     }
   }
   List<Map.Entry<String, String>> headers = new ArrayList<Map.Entry<String, String>>();
   if (cascadeDeletes) {
     headers.add(new Pair<String, String>("X-StackMob-CascadeDelete", "true"));
   }
   new StackMobRequestWithoutPayload(
           this.executor,
           this.session,
           HttpVerbWithoutPayload.DELETE,
           StackMobOptions.headers(headers),
           StackMobRequest.EmptyParams,
           String.format("%s/%s/%s/%s", path, primaryId, field, ids.toString()),
           callback,
           this.redirectedCallback)
       .setUrlFormat(this.host)
       .sendRequest();
 }
 /**
  * do a DELETE request to the StackMob platform, with query parameters.
  *
  * <p>warning! this has the ability to delete a substantial amount of data in one request. use
  * with care!
  *
  * @param query the query on which to match elements to be deleted
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 public void delete(StackMobQuery query, StackMobRawCallback callback) {
   new StackMobRequestWithoutPayload(
           this.executor,
           this.session,
           HttpVerbWithoutPayload.DELETE,
           StackMobOptions.none(),
           query.getArguments(),
           query.getObjectName(),
           callback,
           this.redirectedCallback)
       .setUrlFormat(this.host)
       .sendRequest();
 }
 /**
  * do a get request on the StackMob platform
  *
  * @param path the path to get
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 public void get(String path, StackMobRawCallback callback) {
   new StackMobRequestWithoutPayload(
           this.executor,
           this.session,
           HttpVerbWithoutPayload.GET,
           StackMobOptions.none(),
           StackMobRequest.EmptyParams,
           path,
           callback,
           this.redirectedCallback)
       .setUrlFormat(this.host)
       .sendRequest();
 }
 /**
  * do a put request on the StackMob platform
  *
  * @param path the path to put
  * @param id the id of the object to put
  * @param body the json body
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 public void put(String path, String id, String body, StackMobRawCallback callback) {
   new StackMobRequestWithPayload(
           this.executor,
           this.session,
           HttpVerbWithPayload.PUT,
           StackMobOptions.none(),
           StackMobRequest.EmptyParams,
           body,
           path + "/" + id,
           callback,
           this.redirectedCallback)
       .setUrlFormat(this.host)
       .sendRequest();
 }
 /**
  * do a post request on the StackMob platform with a list of objects
  *
  * @param path the path to get
  * @param requestObjects List of objects to serialize and send in the POST body. the list will be
  *     serialized with Gson
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 public <T> void postBulk(String path, List<T> requestObjects, StackMobRawCallback callback) {
   new StackMobRequestWithPayload(
           this.executor,
           this.session,
           HttpVerbWithPayload.POST,
           StackMobOptions.none(),
           StackMobRequest.EmptyParams,
           requestObjects,
           path,
           callback,
           this.redirectedCallback)
       .setUrlFormat(this.host)
       .sendRequest();
 }
 /**
  * do a head request on the StackMob platform
  *
  * @param path the path to head
  * @param arguments arguments to be encoded into the query string of the head request
  * @param headers any additional headers to send
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 private void head(
     String path,
     List<Map.Entry<String, String>> arguments,
     List<Map.Entry<String, String>> headers,
     StackMobRawCallback callback) {
   new StackMobRequestWithoutPayload(
           this.executor,
           this.session,
           HttpVerbWithoutPayload.HEAD,
           StackMobOptions.headers(headers),
           arguments,
           path,
           callback,
           this.redirectedCallback)
       .setUrlFormat(this.host)
       .sendRequest();
 }
 /**
  * do a an atomic put request on the StackMob platform with the contents of the has-many relation
  *
  * @param path the path to get
  * @param primaryId id of the object with the relation
  * @param relatedField name of the relation
  * @param relatedIds list of ids to atomically add to the relation. The type should be the same
  *     type as the primary key field of the related object
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 public <T> void putRelated(
     String path,
     String primaryId,
     String relatedField,
     List<T> relatedIds,
     StackMobRawCallback callback) {
   new StackMobRequestWithPayload(
           this.executor,
           this.session,
           HttpVerbWithPayload.PUT,
           StackMobOptions.none(),
           StackMobRequest.EmptyParams,
           relatedIds,
           String.format("%s/%s/%s", path, primaryId, relatedField),
           callback,
           this.redirectedCallback)
       .setUrlFormat(this.host)
       .sendRequest();
 }
 /**
  * atomically remove elements from an array or has many relationship
  *
  * @param path the path to get
  * @param primaryId id of the object with the relation
  * @param field name of the relation or array field to delete from
  * @param idToDelete id to atomically remove from field. should be same type as the primary id of
  *     the related type (most likely String or Integer)
  * @param cascadeDelete true if related object specified in idToDelete should also be deleted
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 public <T> void deleteIdFrom(
     String path,
     String primaryId,
     String field,
     T idToDelete,
     boolean cascadeDelete,
     StackMobRawCallback callback) {
   List<Map.Entry<String, String>> headers = new ArrayList<Map.Entry<String, String>>();
   if (cascadeDelete) {
     headers.add(new Pair<String, String>("X-StackMob-CascadeDelete", "true"));
   }
   new StackMobRequestWithoutPayload(
           this.executor,
           this.session,
           HttpVerbWithoutPayload.DELETE,
           StackMobOptions.headers(headers),
           StackMobRequest.EmptyParams,
           String.format("%s/%s/%s/%s", path, primaryId, field, idToDelete),
           callback,
           this.redirectedCallback)
       .setUrlFormat(this.host)
       .sendRequest();
 }
 /**
  * do a get request on the StackMob platform
  *
  * @param query the query to run
  * @param callback callback to be called when the server returns. may execute in a separate thread
  */
 public void get(StackMobQuery query, StackMobRawCallback callback) {
   StackMobOptions options = StackMobOptions.headers(query.getHeaders());
   this.get("/" + query.getObjectName(), query.getArguments(), options.getHeaders(), callback);
 }