title: Nullsafe Long valueOf
body: <p>Imagine the following scenario
  <code>Long critId = Long.valueOf(criteriaIdentifier);</code></p>
  
  <p>If the view is initially loaded <code>criteriaIdentifier</code> may be null, afterwards I set the value depending of the <code>selectedItem</code> in the JSF View.</p>
  
  <p>However, <code>Long.valueOf(criteriaIdentifier)</code> throws a <code>NumberFormatException</code> - If the string cannot be parsed as a long(i.e <code>null</code>).</p>
  
  <p>I've thought of default setting the Id to default <code>-1</code>, but I wanted to know if there is better practice .</p>
  
  <p><em>PS: technically the <code>criteriaIdentifier</code> can't be -1, since these values are set from the Database, with a Sequence Generator, so I should know -1 was the default value and properly do the default operations</em></p>