title: null safe alternative to ArrayList.addAll
body: <p>I need to safely add one collection(can be NULL) to another. </p>
  
  <p>Is any alternative for example in Apache Commons in order to avoid implementation of a my own custom method like this one:</p>
  
  <pre><code>public static &lt;E&gt; void addAllIfNotNull(List&lt;E&gt; list, Collection&lt;? extends E&gt; c) {
      if (c != null) {
          list.addAll(c);
      }
  }
  </code></pre>
  
  <p>I need it for the following case:</p>
  
  <p>I have a method:</p>
  
  <pre><code>@Override
  public CardPair createWithRandomCards(Board board, List&lt;Long&gt; exludeCardCategoryIds, List&lt;Long&gt; exludeCardIds) {
      if (board == null) {
          throw new EntityNotFoundException(ErrorMessage.BOARD_NOT_FOUND);
      }
  
      exludeCardIds = CollectionUtils.addAllIfNotNull(getCardIds(board), exludeCardIds);
  
  ...
  }
  </code></pre>
  
  <p>and I'm using this method somewhere in the code:</p>
  
  <pre><code>cardPair = boardCardService.createWithRandomCards(currentBoard, null, null);
  </code></pre>
  
  <p><code>exludeCardCategoryIds</code>, <code>exludeCardIds</code> - sometimes can be null and I don't want to create a dummy empty collections for them in this cases.</p>
  
  <p>The goal is to avoid redundant conditions for NULL and move out them to the util method.</p>
  
  <p>What is wrong with this api ?</p>