I have a few objects created with a function called .clean in each one:
HiveCleanerTbl
HiveCleanerDb
These Objects need to be called dynamically based on a record based on an API call being made that will let my Job know what object to call for instance I have it hard coded right now:
def matchSchema(schema:Int): Any = schema match {
case 1 => HiveCleanerTbl.clean(rawRecord)
case 32 => HiveCleanerDb.clean(rawRecord)
...
Earlier in the code instead of hardcoding the possible Objects is there a way to dynamically have the object populated like:
val systems = List[(String, String, Int)] = List((hiveTbl,HiveTblCleaner,6), (hiveDb,HiveDbCleaner,7))
And I have code that looks like this:
systems.foreach(x => if(x._1 == systemName) {
cleanObject = x._2
})
How will I make the cleanObject defined as the object I want to use that can call its .clean function?