Translation from java to scala