title: How to check if a scala Option type is None in Java code
body: <p>I have Scala class that will generate an <code>Option[StructType]</code> value which will be used in a Java function. In that java function, I need to check if this <code>Option[StructType]</code> is Scala <code>None</code> or not. How do I do that?</p>
  
  <h3>Scala class:</h3>
  
  <pre><code>class Person(columns : String) {
      val recordStruct : Option[StructType] = {
          if ( columns != null &amp;&amp; !columns.isEmpty()) {
            Some(new StructType(fields.map(field =&gt; 
                                StructField(field, StringType, true)).toArray))
          } else {
              None
          }
      }   
  }
  </code></pre>
  
  <h3>Java function:</h3>
  
  <pre><code>StructType structure =  person.recordStruct().get();
  
  // how to check if structure is None (in scala) ????
  
  if (structure is None) {
      // ...
  }
  </code></pre>