Java to Scala transformation