A quick comparison and step by step refactor of some Java code to Scala