I want to create a chain of CompletableFutures. 

I'm trying to build things up as follows.

Task 1 performs something and returns a String as result when Task 1 is done I want to start Task 2 with as input the result of Task 1. Task 2 when this is ready it returns an Integer and so on...

So it should be very dynamical so I already have this:

```
      try {
            CompletableFuture<String> task1Future = CompletableFuture.supplyAsync(new Task1());
            CompletableFuture<String> result = task1Future.thenCompose(task1Result -> CompletableFuture.supplyAsync(new Task2(task1Result)));
            System.out.println(result.get());
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }

        public class Task1 implements Supplier<String> {

    public Task1() {
        System.out.println("Task 1 started");
    }

    @Override
    public String get() {
        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            throw new IllegalStateException(e);
        }
        return "Result Task 1";
    }
}

```

What I know try to achieve is build a Wrapper (a sort of linked list):

List of Task where Task should be:

```
public class Task {
    private Supplier startTask;
    private Task followUpTask;

    public Task(Supplier startTask, Task followUpTask) {
        this.startTask = startTask;
        this.followUpTask = followUpTask;
    }
}

```

But I'm now stuck because I don't know how to do the chaining and to make Task more generic that it can be initiated with whatever is the result of the previous task. 

So I need to have a method to contruct the CompletableFuture and to just say start() and that everything happens.

Can someone help me on the way?