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

io.vertx.rxjava.ext.mongo.MongoGridFsClient Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR2
Show newest version
/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.rxjava.ext.mongo;

import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;


@RxGen(io.vertx.ext.mongo.MongoGridFsClient.class)
public class MongoGridFsClient {

  @Override
  public String toString() {
    return delegate.toString();
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    MongoGridFsClient that = (MongoGridFsClient) o;
    return delegate.equals(that.delegate);
  }
  
  @Override
  public int hashCode() {
    return delegate.hashCode();
  }

  public static final TypeArg __TYPE_ARG = new TypeArg<>(    obj -> new MongoGridFsClient((io.vertx.ext.mongo.MongoGridFsClient) obj),
    MongoGridFsClient::getDelegate
  );

  private final io.vertx.ext.mongo.MongoGridFsClient delegate;
  
  public MongoGridFsClient(io.vertx.ext.mongo.MongoGridFsClient delegate) {
    this.delegate = delegate;
  }

  public MongoGridFsClient(Object delegate) {
    this.delegate = (io.vertx.ext.mongo.MongoGridFsClient)delegate;
  }

  public io.vertx.ext.mongo.MongoGridFsClient getDelegate() {
    return delegate;
  }

  /**
   * Deletes a file by it's ID
   * @param id the identifier of the file
   * @param resultHandler will be called when the file is deleted
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient delete(String id, Handler> resultHandler) { 
    delegate.delete(id, resultHandler);
    return this;
  }

  /**
   * Deletes a file by it's ID
   * @param id the identifier of the file
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient delete(String id) {
    return 
delete(id, ar -> { });
  }

    /**
   * Deletes a file by it's ID
   * @param id the identifier of the file
   * @return 
   */
  public Single rxDelete(String id) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      delete(id, fut);
    }));
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadByFileName(io.vertx.rxjava.core.streams.WriteStream stream, String fileName, Handler> resultHandler) { 
    delegate.downloadByFileName(stream.getDelegate(), fileName, resultHandler);
    return this;
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadByFileName(io.vertx.rxjava.core.streams.WriteStream stream, String fileName) {
    return 
downloadByFileName(stream, fileName, ar -> { });
  }

    public Single rxDownloadByFileName(io.vertx.rxjava.core.streams.WriteStream stream, String fileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      downloadByFileName(stream, fileName, fut);
    }));
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadByFileNameWithOptions(io.vertx.rxjava.core.streams.WriteStream stream, String fileName, io.vertx.ext.mongo.GridFsDownloadOptions options, Handler> resultHandler) { 
    delegate.downloadByFileNameWithOptions(stream.getDelegate(), fileName, options, resultHandler);
    return this;
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadByFileNameWithOptions(io.vertx.rxjava.core.streams.WriteStream stream, String fileName, io.vertx.ext.mongo.GridFsDownloadOptions options) {
    return 
downloadByFileNameWithOptions(stream, fileName, options, ar -> { });
  }

    public Single rxDownloadByFileNameWithOptions(io.vertx.rxjava.core.streams.WriteStream stream, String fileName, io.vertx.ext.mongo.GridFsDownloadOptions options) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      downloadByFileNameWithOptions(stream, fileName, options, fut);
    }));
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadById(io.vertx.rxjava.core.streams.WriteStream stream, String id, Handler> resultHandler) { 
    delegate.downloadById(stream.getDelegate(), id, resultHandler);
    return this;
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadById(io.vertx.rxjava.core.streams.WriteStream stream, String id) {
    return 
downloadById(stream, id, ar -> { });
  }

    public Single rxDownloadById(io.vertx.rxjava.core.streams.WriteStream stream, String id) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      downloadById(stream, id, fut);
    }));
  }

  /**
   * Downloads a file.
   * @param fileName the name of the file to download
   * @param resultHandler called when the file is downloaded and returns the length in bytes
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadFile(String fileName, Handler> resultHandler) { 
    delegate.downloadFile(fileName, resultHandler);
    return this;
  }

  /**
   * Downloads a file.
   * @param fileName the name of the file to download
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadFile(String fileName) {
    return 
downloadFile(fileName, ar -> { });
  }

    /**
   * Downloads a file.
   * @param fileName the name of the file to download
   * @return 
   */
  public Single rxDownloadFile(String fileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      downloadFile(fileName, fut);
    }));
  }

  /**
   * Downloads a file and gives it a new name.
   * @param fileName the name of the file to download
   * @param newFileName the name the file should be saved as
   * @param resultHandler called when the file is downloaded and returns the length in bytes
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadFileAs(String fileName, String newFileName, Handler> resultHandler) { 
    delegate.downloadFileAs(fileName, newFileName, resultHandler);
    return this;
  }

  /**
   * Downloads a file and gives it a new name.
   * @param fileName the name of the file to download
   * @param newFileName the name the file should be saved as
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadFileAs(String fileName, String newFileName) {
    return 
downloadFileAs(fileName, newFileName, ar -> { });
  }

    /**
   * Downloads a file and gives it a new name.
   * @param fileName the name of the file to download
   * @param newFileName the name the file should be saved as
   * @return 
   */
  public Single rxDownloadFileAs(String fileName, String newFileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      downloadFileAs(fileName, newFileName, fut);
    }));
  }

  /**
   * Downloads a file using the ID generated by GridFs.
   * @param id the GridFs Object ID of the file to download
   * @param fileName 
   * @param resultHandler called when the file is downloaded and returns the length in bytes
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadFileByID(String id, String fileName, Handler> resultHandler) { 
    delegate.downloadFileByID(id, fileName, resultHandler);
    return this;
  }

  /**
   * Downloads a file using the ID generated by GridFs.
   * @param id the GridFs Object ID of the file to download
   * @param fileName 
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient downloadFileByID(String id, String fileName) {
    return 
downloadFileByID(id, fileName, ar -> { });
  }

    /**
   * Downloads a file using the ID generated by GridFs.
   * @param id the GridFs Object ID of the file to download
   * @param fileName 
   * @return 
   */
  public Single rxDownloadFileByID(String id, String fileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      downloadFileByID(id, fileName, fut);
    }));
  }

  /**
   * Drops the entire file bucket with all of its contents
   * @param resultHandler called when the bucket is dropped
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient drop(Handler> resultHandler) { 
    delegate.drop(resultHandler);
    return this;
  }

  /**
   * Drops the entire file bucket with all of its contents
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient drop() {
    return 
drop(ar -> { });
  }

    /**
   * Drops the entire file bucket with all of its contents
   * @return 
   */
  public Single rxDrop() { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      drop(fut);
    }));
  }

  /**
   * Finds all file ids in the bucket
   * @param resultHandler called when the list of file ids is available
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient findAllIds(Handler>> resultHandler) { 
    delegate.findAllIds(resultHandler);
    return this;
  }

  /**
   * Finds all file ids in the bucket
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient findAllIds() {
    return 
findAllIds(ar -> { });
  }

    /**
   * Finds all file ids in the bucket
   * @return 
   */
  public Single> rxFindAllIds() { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      findAllIds(fut);
    }));
  }

  /**
   * Finds all file ids that match a query.
   * @param query a bson query expressed as json that will be used to match files
   * @param resultHandler called when the list of file ids is available
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient findIds(JsonObject query, Handler>> resultHandler) { 
    delegate.findIds(query, resultHandler);
    return this;
  }

  /**
   * Finds all file ids that match a query.
   * @param query a bson query expressed as json that will be used to match files
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient findIds(JsonObject query) {
    return 
findIds(query, ar -> { });
  }

    /**
   * Finds all file ids that match a query.
   * @param query a bson query expressed as json that will be used to match files
   * @return 
   */
  public Single> rxFindIds(JsonObject query) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      findIds(query, fut);
    }));
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadByFileName(io.vertx.rxjava.core.streams.ReadStream stream, String fileName, Handler> resultHandler) { 
    delegate.uploadByFileName(stream.getDelegate(), fileName, resultHandler);
    return this;
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadByFileName(io.vertx.rxjava.core.streams.ReadStream stream, String fileName) {
    return 
uploadByFileName(stream, fileName, ar -> { });
  }

    public Single rxUploadByFileName(io.vertx.rxjava.core.streams.ReadStream stream, String fileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      uploadByFileName(stream, fileName, fut);
    }));
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadByFileName(Observable stream, String fileName, Handler> resultHandler) { 
    delegate.uploadByFileName(io.vertx.rx.java.ReadStreamSubscriber.asReadStream(stream,obj -> (io.vertx.core.buffer.Buffer)obj.getDelegate()).resume(), fileName, resultHandler);
    return this;
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadByFileName(Observable stream, String fileName) {
    return 
uploadByFileName(stream, fileName, ar -> { });
  }

    public Single rxUploadByFileName(Observable stream, String fileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      uploadByFileName(stream, fileName, fut);
    }));
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadByFileNameWithOptions(io.vertx.rxjava.core.streams.ReadStream stream, String fileName, io.vertx.ext.mongo.GridFsUploadOptions options, Handler> resultHandler) { 
    delegate.uploadByFileNameWithOptions(stream.getDelegate(), fileName, options, resultHandler);
    return this;
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadByFileNameWithOptions(io.vertx.rxjava.core.streams.ReadStream stream, String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) {
    return 
uploadByFileNameWithOptions(stream, fileName, options, ar -> { });
  }

    public Single rxUploadByFileNameWithOptions(io.vertx.rxjava.core.streams.ReadStream stream, String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      uploadByFileNameWithOptions(stream, fileName, options, fut);
    }));
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadByFileNameWithOptions(Observable stream, String fileName, io.vertx.ext.mongo.GridFsUploadOptions options, Handler> resultHandler) { 
    delegate.uploadByFileNameWithOptions(io.vertx.rx.java.ReadStreamSubscriber.asReadStream(stream,obj -> (io.vertx.core.buffer.Buffer)obj.getDelegate()).resume(), fileName, options, resultHandler);
    return this;
  }

  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadByFileNameWithOptions(Observable stream, String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) {
    return 
uploadByFileNameWithOptions(stream, fileName, options, ar -> { });
  }

    public Single rxUploadByFileNameWithOptions(Observable stream, String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      uploadByFileNameWithOptions(stream, fileName, options, fut);
    }));
  }

  /**
   * Upload a file to gridfs
   * @param fileName the name of the file to store in gridfs
   * @param resultHandler the id of the file that was uploaded
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadFile(String fileName, Handler> resultHandler) { 
    delegate.uploadFile(fileName, resultHandler);
    return this;
  }

  /**
   * Upload a file to gridfs
   * @param fileName the name of the file to store in gridfs
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadFile(String fileName) {
    return 
uploadFile(fileName, ar -> { });
  }

    /**
   * Upload a file to gridfs
   * @param fileName the name of the file to store in gridfs
   * @return 
   */
  public Single rxUploadFile(String fileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      uploadFile(fileName, fut);
    }));
  }

  /**
   * Upload a file to gridfs with options
   * @param fileName the name of the file to store in gridfs
   * @param options {@link io.vertx.ext.mongo.GridFsUploadOptions} for specifying metadata and chunk size
   * @param resultHandler the id of the file that was uploaded
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadFileWithOptions(String fileName, io.vertx.ext.mongo.GridFsUploadOptions options, Handler> resultHandler) { 
    delegate.uploadFileWithOptions(fileName, options, resultHandler);
    return this;
  }

  /**
   * Upload a file to gridfs with options
   * @param fileName the name of the file to store in gridfs
   * @param options {@link io.vertx.ext.mongo.GridFsUploadOptions} for specifying metadata and chunk size
   * @return 
   */
  public io.vertx.rxjava.ext.mongo.MongoGridFsClient uploadFileWithOptions(String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) {
    return 
uploadFileWithOptions(fileName, options, ar -> { });
  }

    /**
   * Upload a file to gridfs with options
   * @param fileName the name of the file to store in gridfs
   * @param options {@link io.vertx.ext.mongo.GridFsUploadOptions} for specifying metadata and chunk size
   * @return 
   */
  public Single rxUploadFileWithOptions(String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      uploadFileWithOptions(fileName, options, fut);
    }));
  }

  /**
   * Close the client and release its resources
   */
  public void close() { 
    delegate.close();
  }

  public static MongoGridFsClient newInstance(io.vertx.ext.mongo.MongoGridFsClient arg) {
    return arg != null ? new MongoGridFsClient(arg) : null;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy