title: Java 8 - usage of Consumer's andThen
body: <p>I have below POC to  use Java 8 feature. </p>
  
  <p>I want to update DB after accept method. Is it good to go with <code>andThen()</code>? When is this method called? Who calls it? </p>
  
  <p>What is the basic use of <code>andThen()</code> method? Looking at the docs was confusing.</p>
  
  <pre><code>public class StockTest {
  
      public static void main(String[] args) {
  
      List&lt;Trader&gt; traders = new ArrayList&lt;&gt;();
  
      Random random = new Random();
  
      // Initializing trading a/c's.
      for (int i = 0; i &lt; 10; i++) {
          Trader trader = new Trader((random.nextInt(100) + 1) * 3);
          traders.add(trader);
      }
      // Display Trade accounts.
      System.out.println("Before Bonus, Units are:");
      for (Trader trader : traders) {
          System.out.print(trader.getUnits() + "\t");
      }
  
      // Add bonus to each trader.
      traders.forEach(new Consumer&lt;Trader&gt;() {
  
          @Override
          public void accept(Trader trader) {
              trader.updateBonus(2);
          }
  
          @Override
          public Consumer&lt;Trader&gt; andThen(Consumer&lt;? super Trader&gt; after) 
         {
              System.out.println("In andThen");
              return Consumer.super.andThen(after);
          }
          });
  
      // Display Trade accounts after bonus applied..
      System.out.println("\nAfter bonus:");
      for (Trader trader : traders) {
          System.out.print(trader.getUnits() + "\t");
       }
  
     }
  
   }
  
   class Trader {
      private int units;
  
      public Trader(int initialUnits) {
      this.units = initialUnits;
   }
  
     public int getUnits() {
          return units;
      }
  
  public void setUnits(int units) {
      this.units = units;
  }
  
   public void updateBonus(int bonusUnits) {
      this.units = this.units * bonusUnits;
    }
   }
  </code></pre>
  
  <p>Please help with some example or use cases to utilize this method </p>