title: What's the point of Guava checkNotNull
body: <p>I'm pretty new to Guava (let's be honest, I'm not "pretty new", I'm a complete rookie on that subject) and so I decided to go through some documentation and got quite amazed while reading this:</p>
  
  <p><a href="https://google.github.io/guava/releases/23.0/api/docs/com/google/common/base/Preconditions.html#checkNotNull-T-" rel="noreferrer"><code>com.google.common.base.Preconditions.checkNotNull(...)</code></a></p>
  
  <p>I don't get the point of this method.
  This means that instead of doing : </p>
  
  <pre><code>myObject.getAnything();
  </code></pre>
  
  <p><em>(which might cause a <code>NullPointerException</code> if myObject is null)</em></p>
  
  <p>I should use</p>
  
  <pre><code>checkNotNull(myObject).getAnything();
  </code></pre>
  
  <p>which <strong>will</strong> throw a <code>NullPointerException</code> if <code>myObject</code> is null and return <code>myObject</code> if it is not null.</p>
  
  <p>I'm puzzled and this might be the stupidest question ever but ...</p>
  
  <p>What is the point of this?
  Those two lines do the exact same thing as for outcomes given any situations I can think of.</p>
  
  <p>I don't even think that the latter is more readable.</p>
  
  <p>So I must be missing something. What is it?</p>