title: Why use Optional.of over Optional.ofNullable?
body: <p>When using the Java 8 <code>Optional</code> class, there are two ways in which a value can be wrapped in an optional.</p>
  
  <pre><code>String foobar = &lt;value or null&gt;;
  Optional.of(foobar);         // May throw NullPointerException
  Optional.ofNullable(foobar); // Safe from NullPointerException
  </code></pre>
  
  <p>I understand <code>Optional.ofNullable</code> is the only safe way of using <code>Optional</code>, but why does <code>Optional.of</code> exist at all? Why not just use <code>Optional.ofNullable</code>  and be on the safe side at all times?</p>