Scenario:
I have two Enumerations type: Schema
and Table
.
I want to bind every Table
to a Specific Schema
. So, actually I have implemented this:
object Table extends Enumeration {
type Tabella = Value
val TABLE1 = Value("TABLE1")
val TABLE2 = Value("TABLE2")
def getTable(myTable: Tabella): String = {
myTable match {
case Table.TABLE1 =>
(Schema.SCHEMA1 + "." + Table.TABLE1)
case Table.TABLE2 =>
(Schema.SCHEMA1 + "." + Table.TABLE2)
}
}
}
and of course
object Schema extends Enumeration {
type Schemi = Value
val SCHEMA1 = Value("SCHEMA1")
}
Now everytime I need a table I call Table.getTable(Table.TABLE1)
, but it's pretty awful code, I know. I'd like to improve this. Any Help?
I'd love to have some sort of override def toString
in such way I just put my Table.TABLE1
in code and return SchemaName.TableName
, is this possible?