I wrote it in Java becaue my Scala-to-Java mental conversion fu is abysmal, so this was the safe way :)