Code refactoring implying code like Scala case class