title: Using Scala in Java - how to convert a Java Object to Option<Object>
body: <p>I'm writing in java, and I need to use external library that is written in scala. In particular, I need the following <a href="http://apache.mirrors.tds.net/kafka/0.8.2.1/scaladoc/index.html#kafka.api.PartitionMetadata" rel="nofollow noreferrer">constructor</a>:</p>
  <pre><code>new PartitionMetadata(partitionId: Int, leader: Option[Broker], replicas: Seq[Broker], isr: Seq[Broker] = collection.this.Seq.empty[Nothing], errorCode: Short = kafka.common.ErrorMapping.NoError)
  </code></pre>
  <p>I was able to convert all but the <code>leader : Option[Broker]</code> and the <code>Seq</code> parameters in my java code:</p>
  <pre><code>partitionMetadata = new kafka.api.PartitionMetadata(
    partitionId, leader.getBroker(),(Seq)brokerReplicas, (Seq)brokerIsr, errorCode);
  </code></pre>
  <p>I'm getting the following error in my editor:</p>
  <pre><code>'PartitionMetadata(int, scala.Option&lt;kafka.cluster.Broker&gt;, scala.collection.Seq&lt;kafka.cluster.Broker&gt;, scala.collection.Seq&lt;kafka.cluster.Broker&gt;, short)' in 'kafka.api.PartitionMetadata'
  cannot be applied to (int, kafka.cluster.Broker, scala.collection.Seq, scala.collection.Seq, short)
  </code></pre>
  <p>Is it possible to use a Scala constructor in Java? Also, how do I convert a Java Object (leader) to a Option?</p>
  <p>Lastly, am I converting the ArrayList -&gt; Scala.collection.Seq fields correctly?</p>
  <p>Thanks</p>