utility method for safe dereference in Java
<p>Groovy allows me to say</p>

<pre><code>x?.getY()
</code></pre>

<p>instead of the verbose</p>

<pre><code>x==null ? null : x.getY().
</code></pre>

<p>Java does not allow custom operators, but I can imagine a utility method that's used like so:</p>

<pre><code>safe(x).getY();
</code></pre>

<p>Is there any standard library in the world's Maven repos that does this kind of thing? If no, and I wanted to include it in an open source library (like apache.commons.lang), where would it best fit?</p>

<p>Edit: sample implementation of <code>safe()</code>:</p>

<pre><code>public static &lt;T&gt; T safe(T x) {
    if (x==null) {
        return new NullReturningMock&lt;T&gt;();
    } else {
        return x;
    }
}
</code></pre>
