Switch from java to scala