 <p>I hope you access your fields by pair of get/set methods. Just make null-checking logic inside getter:</p> <pre><code>public Second getRelated(){ if( second == null ) return defaultValue; } </code></pre> <p>Please also see this answer <a href="http://stackoverflow.com/a/757330/149818">http://stackoverflow.com/a/757330/149818</a></p>