Converted some Scala to Java