// Path: src/main/java/io/dazraf/vertx/futures/processors/FutureProcessor.java
// @FunctionalInterface
// public interface FutureProcessor<T1, T2> extends Function<Future<T1>, Future<T2>> {
// }


import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
import io.dazraf.vertx.futures.processors.FutureProcessor;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.impl.NoStackTraceThrowable;
      return new FuturesImpl<>(future, future);
    }
  }

  public FuturesImpl(Future parent) {
    this.parent = parent;
  }

  public FuturesImpl(Future<T> future, Future parent) {
    this(parent);
    initialise(future);
  }

  private FuturesImpl<T> initialise(Future<T> future) {
    future.setHandler(asyncResult -> {
      if (asyncResult.failed()) {
        fail(asyncResult.cause());
      } else if (asyncResult.succeeded()) {
        complete(asyncResult.result());
      }
      notifyAllDependents(this);
    });
    return this;
  }

  private void notifyAllDependents(Future<T> future) {
    dependents.forEach(dependent -> dependent.accept(future));
  }

  @Override
// Path: src/main/java/io/dazraf/vertx/futures/processors/FutureProcessor.java
// @FunctionalInterface
// public interface FutureProcessor<T1, T2> extends Function<Future<T1>, Future<T2>> {
// }


// Path: src/main/java/io/dazraf/vertx/futures/FuturesImpl.java
import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
import io.dazraf.vertx.futures.processors.FutureProcessor;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.impl.NoStackTraceThrowable;

      return new FuturesImpl<>(future, future);
    }
  }

  public FuturesImpl(Future parent) {
    this.parent = parent;
  }

  public FuturesImpl(Future<T> future, Future parent) {
    this(parent);
    initialise(future);
  }

  private FuturesImpl<T> initialise(Future<T> future) {
    future.setHandler(asyncResult -> {
      if (asyncResult.failed()) {
        fail(asyncResult.cause());
      } else if (asyncResult.succeeded()) {
        complete(asyncResult.result());
      }
      notifyAllDependents(this);
    });
    return this;
  }

  private void notifyAllDependents(Future<T> future) {
    dependents.forEach(dependent -> dependent.accept(future));
  }

  @Override
  public <R> Futures<R> then(FutureProcessor<T, R> processor) {