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

io.vertx.core.CompositeFuture Maven / Gradle / Ivy

There is a newer version: 4.5.10
Show newest version
/*
 * Copyright (c) 2011-2013 The original author or authors
 *  ------------------------------------------------------
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  and Apache License v2.0 which accompanies this distribution.
 *
 *      The Eclipse Public License is available at
 *      http://www.eclipse.org/legal/epl-v10.html
 *
 *      The Apache License v2.0 is available at
 *      http://www.opensource.org/licenses/apache2.0.php
 *
 *  You may elect to redistribute this code under either of these licenses.
 */

package io.vertx.core;

import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.impl.CompositeFutureImpl;

import java.util.List;

/**
 * The composite future wraps a list of {@link Future futures}, it is useful when several futures
 * needs to be coordinated.
 *
 * @author Julien Viet
 */
@VertxGen
public interface CompositeFuture extends Future {

  /**
   * Return a composite future, succeeded when all futures are succeeded, failed when any future is failed.
   *
   * @param f1 future
   * @param f2 future
   * @return the composite future
   */
  static  CompositeFuture all(Future f1, Future f2) {
    return CompositeFutureImpl.all(f1, f2);
  }

  /**
   * Like {@link #all(Future, Future)} but with 3 futures.
   */
  static  CompositeFuture all(Future f1, Future f2, Future f3) {
    return CompositeFutureImpl.all(f1, f2, f3);
  }

  /**
   * Like {@link #all(Future, Future)} but with 4 futures.
   */
  static  CompositeFuture all(Future f1, Future f2, Future f3, Future f4) {
    return CompositeFutureImpl.all(f1, f2, f3, f4);
  }

  /**
   * Like {@link #all(Future, Future)} but with 5 futures.
   */
  static  CompositeFuture all(Future f1, Future f2, Future f3, Future f4, Future f5) {
    return CompositeFutureImpl.all(f1, f2, f3, f4, f5);
  }

  /**
   * Like {@link #all(Future, Future)} but with 6 futures.
   */
  static  CompositeFuture all(Future f1, Future f2, Future f3, Future f4, Future f5, Future f6) {
    return CompositeFutureImpl.all(f1, f2, f3, f4, f5, f6);
  }

  /**
   * Like {@link #all(Future, Future)} but with a list of futures.
   */
  static CompositeFuture all(List futures) {
    return CompositeFutureImpl.all(futures.toArray(new Future[futures.size()]));
  }

  /**
   * Return a composite future, succeeded when any futures is succeeded, failed when all futures are failed.
   *
   * @param f1 future
   * @param f2 future
   * @return the composite future
   */
  static  CompositeFuture any(Future f1, Future f2) {
    return CompositeFutureImpl.any(f1, f2);
  }

  /**
   * Like {@link #any(Future, Future)} but with 3 futures.
   */
  static  CompositeFuture any(Future f1, Future f2, Future f3) {
    return CompositeFutureImpl.any(f1, f2, f3);
  }

  /**
   * Like {@link #any(Future, Future)} but with 4 futures.
   */
  static  CompositeFuture any(Future f1, Future f2, Future f3, Future f4) {
    return CompositeFutureImpl.any(f1, f2, f3, f4);
  }

  /**
   * Like {@link #any(Future, Future)} but with 5 futures.
   */
  static  CompositeFuture any(Future f1, Future f2, Future f3, Future f4, Future f5) {
    return CompositeFutureImpl.any(f1, f2, f3, f4, f5);
  }

  /**
   * Like {@link #any(Future, Future)} but with 6 futures.
   */
  static  CompositeFuture any(Future f1, Future f2, Future f3, Future f4, Future f5, Future f6) {
    return CompositeFutureImpl.any(f1, f2, f3, f4, f5, f6);
  }

  /**
   * Like {@link #any(Future, Future)} but with a list of futures.
   */
  static CompositeFuture any(List futures) {
    return CompositeFutureImpl.any(futures.toArray(new Future[futures.size()]));
  }

  @Override
  CompositeFuture setHandler(Handler> handler);

  /**
   * Returns a cause of a wrapped future
   *
   * @param index the wrapped future index
   */
  Throwable cause(int index);

  /**
   * Returns true if a wrapped future is succeeded
   *
   * @param index the wrapped future index
   */
  boolean succeeded(int index);

  /**
   * Returns true if a wrapped future is failed
   *
   * @param index the wrapped future index
   */
  boolean failed(int index);

  /**
   * Returns true if a wrapped future is completed
   *
   * @param index the wrapped future index
   */
  boolean isComplete(int index);

  /**
   * Returns the result of a wrapped future
   *
   * @param index the wrapped future index
   */
   T result(int index);

  /**
   * @return the number of wrapped future
   */
  int size();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy