So I have been looking into Java's CompletableFuture as a requirement for performance work in our code base.
I understand the concept of how to use it to run things asynchronously.
I am having issues trying to implement it in a way that returns me a flat list, e.g.
List<T> myList = CompletableFuture.supplyAsync(...);
I can get the result if I just simply return a CompletableFuture List: CompletableFuture<List<T>> myList = ...
And then I can convert it to a List by using the .get() method provided by CompletableFuture, but this looks messy to me:
...
CompletableFuture<List<T>> myFuturesList = CompletableFuture.supplyAsync(() -> getData());
List<T> myList = myFuturesList.get();
...
Part of the issue I have is I want to call a method that returns a list of Integers, that I then pass into my method to retrieve an Object of AccountDetails.
So basically I do something like:
Get customer -> getAccountIds(customer) -> getAccountDetails(accountId)
return List<accountDetails>