title: Java8 Null-safe comparison
body: <p>Having issues with comparing two products. I wish to compare the vintage (which is optional) attribute of each of them. But whenever this attribute is null, a NPE is thrown. I thought with Comparator.nullsLast(..) I can deal with null values... But it seems I either have a misunderstanding of how this works or there's something wrong with the code. What do I need to change to get this work null-friendly? </p>
  
  <pre><code>@Override
  public int compare(IProduct product1, IProduct product2) throws ProductComparisonException {
  
      Comparator&lt;IShopProduct&gt; comparator =
          Comparator.nullsLast(Comparator.comparing(IShopProduct::getVintage));
  
      return comparator.compare((IShopProduct)product1.getProvidedProductData(),
                                (IShopProduct)product2.getProvidedProductData());
  }
  </code></pre>
  
  <p>Thanks in advance</p>