title: VAVR compose Try and List
body: <p>I'm trying to figure out what are the idiomatic ways of using VAVR's Try.
  The use case I'm looking at has to following steps:<br>
  - fetch a list of shoes (the invocation can throw a checked exception)<br>
  - clean each shoe (the invocation can throw a checked exception)<br>
  - restore each shoe (the invocation can throw a checked exception)<br>
  - return a list of cleaned/restored shoes</p>
  
  <p>Here is my sample toy code where processRequest method buys n pairs of shoes, cleans &amp; restores them; prints errors if any:</p>
  
  <pre><code>// definitions
  ShoeStore java.util.List&lt;Shoe&gt; buy(int numberOfPairs) throws OutOfStockException;
  ShoeCleaningService Shoe clean(Shoe dirtyShoe) throws OutOfShoePolishException;
  ShoeRestoreService Shoe restore(Shoe oldShoe) throws OutOfSparePartsException;
  
  class EnterpriseShoeService {
      // constructor
      ...
  
      public List&lt;Shoe&gt; processRequest(int numberOfPairs) {
          Try&lt;List&lt;Shoe&gt;&gt; shoes = Try.of(() -&gt; shoeStore.buy(numberOfPairs));
          Try&lt;List&lt;Try&lt;Shoe&gt;&gt;&gt; cleanedAndRestoredShoes = shoes.map(xs -&gt; xs.stream().map(shoe -&gt;
                  Try.success(shoe)
                          .andThenTry(shoeCleaningService::clean)
                          .andThenTry(shoeRestoreService::restore))
                  .collect(Collectors.toList()));
  
          List&lt;Shoe&gt; result = cleanedAndRestoredShoes
                  .getOrElseGet(err -&gt; {
                      System.out.println(err.getMessage());
                      return Collections.emptyList();
                  })
                  .stream()
                  .map(shoeTry -&gt; shoeTry.onFailure(err -&gt; System.out.println(err.getMessage())))
                  .filter(Try::isSuccess)
                  .map(Try::get)
                  .collect(Collectors.toList());
  
          return result;
  
      }
  }
  
  </code></pre>
  
  <p>My question is: how could this logic be simplified? are there any method calls that could be eliminated? could the readability be improved?</p>