I have class that contains a set of folders and names of a database which will be used as a constructor parameter.
case class DatabaseStructure(originalDir: String){
val name: String = "toto"
val folder: String = originalDir + "/DATA/"
}
I have another class with getter/setter functions ( I am new to Scala, so those functions may not be correct).
case class Database(databaseFilename: String, dataStruct: DatabaseStructure) {
def getData: dataType = {
val dataFilename = new File(datastruct.folder, datastruct.name)
IO.readData(dataFilename).get
}
def getData(folder: String): dataType = {
val dataFilename = new File(folder, datastruct.name)
IO.readData(dataFilename).get
}
def getData(name: String, folder: String): dataType = {
val dataFilename = new File(folder, name)
IO.readData(dataFilename).get
}
}
I'd like to refactor the method getData() so as I can use it with variable number of parameters.
How can this this be done in Scala ?
Is it a good idea to put those name/folder from the DataStructure in the getData() function ?
For a more general question, how to create setter/getter in Scala ?
Thank you very much