class FallbackImpl<R> implements Fallback<R>, FailurePolicy<R> {
  /**
   * A fallback that will return null if execution fails.
   */
  public static Fallback<Void> NONE = Fallback.<Void>builder(() -> null).build();

  private final FallbackConfig<R> config;

  public FallbackImpl(FallbackConfig<R> config) {
    this.config = config;
  }

  @Override
  public FallbackConfig<R> getConfig() {
    return config;
  }

  /**
   * Returns the applied fallback result.
   */
  protected R apply(R result, Throwable exception, ExecutionContext<R> context) throws Throwable {
    ExecutionAttemptedEvent<R> event = new ExecutionAttemptedEvent<>(result, exception, context);
    return config.getFallback() != null ?
      config.getFallback().apply(event) :
      config.getFallbackStage().apply(event).get();
  }

  /**
   * Returns a future applied fallback result.
   */
  protected CompletableFuture<R> applyStage(R result, Throwable exception, ExecutionContext<R> context) throws Throwable {<FILL_FUNCTION_BODY>}

  @Override
  public PolicyExecutor<R> toExecutor(int policyIndex) {
    return new FallbackExecutor<>(this, policyIndex);
  }
}

    ExecutionAttemptedEvent<R> event = new ExecutionAttemptedEvent<>(result, exception, context);
    return config.getFallback() != null ?
      CompletableFuture.completedFuture(config.getFallback().apply(event)) :
      config.getFallbackStage().apply(event);
  
<no_super_class>