Scala, Design Patterns, Programming, Factory Pattern.
{ private val default: AbstractFactory = new CsvFactory private val factories: mutable.HashMap[String, AbstractFactory] = mutable.HashMap("json"->new JsonFactory, "csv"->default) def factory = factories.getOrElse(System.getProperty("fileType"), default) } It is preferable to grant access for