translate java to scala