Convert Java to Scala