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

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

The 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.function.Supplier;
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
   * @return a future notified when the operation completes
   */
  public io.vertx.core.Future delete(java.lang.String id) { 
    io.vertx.core.Future ret = delegate.delete(id).map(val -> val);
    return ret;
  }

    /**
   * Deletes a file by it's ID
   * @param id the identifier of the file
   * @return a future notified when the operation completes
   */
  public rx.Single rxDelete(java.lang.String id) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      this.delete(id).onComplete(fut);
    }));
  }

  /**
   * Read file by name to ReadStream
   * @param fileName 
   * @return 
   */
  public io.vertx.rxjava.core.streams.ReadStream readByFileName(java.lang.String fileName) { 
    io.vertx.rxjava.core.streams.ReadStream ret = io.vertx.rxjava.core.streams.ReadStream.newInstance((io.vertx.core.streams.ReadStream)delegate.readByFileName(fileName), TypeArg.unknown());
    return ret;
  }

  /**
   * Read file by name to ReadStream with options
   * @param fileName 
   * @param options 
   * @return 
   */
  public io.vertx.rxjava.core.streams.ReadStream readByFileNameWithOptions(java.lang.String fileName, io.vertx.ext.mongo.GridFsDownloadOptions options) { 
    io.vertx.rxjava.core.streams.ReadStream ret = io.vertx.rxjava.core.streams.ReadStream.newInstance((io.vertx.core.streams.ReadStream)delegate.readByFileNameWithOptions(fileName, options), TypeArg.unknown());
    return ret;
  }

  /**
   * Read file by id to ReadStream
   * @param id 
   * @return 
   */
  public io.vertx.rxjava.core.streams.ReadStream readById(java.lang.String id) { 
    io.vertx.rxjava.core.streams.ReadStream ret = io.vertx.rxjava.core.streams.ReadStream.newInstance((io.vertx.core.streams.ReadStream)delegate.readById(id), TypeArg.unknown());
    return ret;
  }

  public io.vertx.core.Future downloadByFileName(io.vertx.rxjava.core.streams.WriteStream stream, java.lang.String fileName) { 
    io.vertx.core.Future ret = delegate.downloadByFileName(stream.getDelegate(), fileName).map(val -> val);
    return ret;
  }

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

  public io.vertx.core.Future downloadByFileNameWithOptions(io.vertx.rxjava.core.streams.WriteStream stream, java.lang.String fileName, io.vertx.ext.mongo.GridFsDownloadOptions options) { 
    io.vertx.core.Future ret = delegate.downloadByFileNameWithOptions(stream.getDelegate(), fileName, options).map(val -> val);
    return ret;
  }

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

  public io.vertx.core.Future downloadById(io.vertx.rxjava.core.streams.WriteStream stream, java.lang.String id) { 
    io.vertx.core.Future ret = delegate.downloadById(stream.getDelegate(), id).map(val -> val);
    return ret;
  }

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

  /**
   * Downloads a file.
   * @param fileName the name of the file to download
   * @return a future notified with the result
   */
  public io.vertx.core.Future downloadFile(java.lang.String fileName) { 
    io.vertx.core.Future ret = delegate.downloadFile(fileName).map(val -> val);
    return ret;
  }

    /**
   * Downloads a file.
   * @param fileName the name of the file to download
   * @return a future notified with the result
   */
  public rx.Single rxDownloadFile(java.lang.String fileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      this.downloadFile(fileName).onComplete(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
   * @return a future notified with the result
   */
  public io.vertx.core.Future downloadFileAs(java.lang.String fileName, java.lang.String newFileName) { 
    io.vertx.core.Future ret = delegate.downloadFileAs(fileName, newFileName).map(val -> val);
    return ret;
  }

    /**
   * 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 a future notified with the result
   */
  public rx.Single rxDownloadFileAs(java.lang.String fileName, java.lang.String newFileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      this.downloadFileAs(fileName, newFileName).onComplete(fut);
    }));
  }

  /**
   * Downloads a file using the ID generated by GridFs.
   * @param id the GridFs Object ID of the file to download
   * @param fileName 
   * @return a future notified with the result
   */
  public io.vertx.core.Future downloadFileByID(java.lang.String id, java.lang.String fileName) { 
    io.vertx.core.Future ret = delegate.downloadFileByID(id, fileName).map(val -> val);
    return ret;
  }

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

  /**
   * Drops the entire file bucket with all of its contents
   * @return a future notified when the operation completes
   */
  public io.vertx.core.Future drop() { 
    io.vertx.core.Future ret = delegate.drop().map(val -> val);
    return ret;
  }

    /**
   * Drops the entire file bucket with all of its contents
   * @return a future notified when the operation completes
   */
  public rx.Single rxDrop() { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      this.drop().onComplete(fut);
    }));
  }

  /**
   * Finds all file ids in the bucket
   * @return a future notified with the result
   */
  public io.vertx.core.Future> findAllIds() { 
    io.vertx.core.Future> ret = delegate.findAllIds().map(val -> val);
    return ret;
  }

    /**
   * Finds all file ids in the bucket
   * @return a future notified with the result
   */
  public rx.Single> rxFindAllIds() { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      this.findAllIds().onComplete(fut);
    }));
  }

  /**
   * Finds all file ids that match a query.
   * @param query a bson query expressed as json that will be used to match files
   * @return a future notified with the result
   */
  public io.vertx.core.Future> findIds(io.vertx.core.json.JsonObject query) { 
    io.vertx.core.Future> ret = delegate.findIds(query).map(val -> val);
    return ret;
  }

    /**
   * Finds all file ids that match a query.
   * @param query a bson query expressed as json that will be used to match files
   * @return a future notified with the result
   */
  public rx.Single> rxFindIds(io.vertx.core.json.JsonObject query) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      this.findIds(query).onComplete(fut);
    }));
  }

  public io.vertx.core.Future uploadByFileName(io.vertx.rxjava.core.streams.ReadStream stream, java.lang.String fileName) { 
    io.vertx.core.Future ret = delegate.uploadByFileName(stream.getDelegate(), fileName).map(val -> val);
    return ret;
  }

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

  public io.vertx.core.Future uploadByFileName(rx.Observable stream, java.lang.String fileName) { 
    io.vertx.core.Future ret = delegate.uploadByFileName(io.vertx.rx.java.ReadStreamSubscriber.asReadStream(stream,Function.identity()).resume(), fileName).map(val -> val);
    return ret;
  }

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

  public io.vertx.core.Future uploadByFileNameWithOptions(io.vertx.rxjava.core.streams.ReadStream stream, java.lang.String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) { 
    io.vertx.core.Future ret = delegate.uploadByFileNameWithOptions(stream.getDelegate(), fileName, options).map(val -> val);
    return ret;
  }

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

  public io.vertx.core.Future uploadByFileNameWithOptions(rx.Observable stream, java.lang.String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) { 
    io.vertx.core.Future ret = delegate.uploadByFileNameWithOptions(io.vertx.rx.java.ReadStreamSubscriber.asReadStream(stream,Function.identity()).resume(), fileName, options).map(val -> val);
    return ret;
  }

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

  /**
   * Upload a file to gridfs
   * @param fileName the name of the file to store in gridfs
   * @return a future notified with the result
   */
  public io.vertx.core.Future uploadFile(java.lang.String fileName) { 
    io.vertx.core.Future ret = delegate.uploadFile(fileName).map(val -> val);
    return ret;
  }

    /**
   * Upload a file to gridfs
   * @param fileName the name of the file to store in gridfs
   * @return a future notified with the result
   */
  public rx.Single rxUploadFile(java.lang.String fileName) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      this.uploadFile(fileName).onComplete(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
   * @return a future notified with the result
   */
  public io.vertx.core.Future uploadFileWithOptions(java.lang.String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) { 
    io.vertx.core.Future ret = delegate.uploadFileWithOptions(fileName, options).map(val -> val);
    return ret;
  }

    /**
   * 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 a future notified with the result
   */
  public rx.Single rxUploadFileWithOptions(java.lang.String fileName, io.vertx.ext.mongo.GridFsUploadOptions options) { 
    return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
      this.uploadFileWithOptions(fileName, options).onComplete(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