Scalaには、ケースクラスがあります。
case class MonthSelectionInfo(monthSelection: MonthSelection.Value, customMonth:Int = 0, customYear:Int = 0) {
def this(monthSelection: MonthSelection.Value) = {
this(monthSelection, 0, 0)
}
}
object MonthSelection extends Enumeration {
type MonthSelection = Value
val LastMonth, ThisMonth, NextMonth, CustomMonth = Value
}
ケースクラスのインスタンスがある場合、使用する必要があります
myMonthSelectionInfo.monthSelection
と
myMonthSelectionInfo.eq(newMonthSelection)
に含まれるMonthSelectionインスタンスを取得および設定します。
ゲッターとセッターを通常のJavaPOJOのようにフォーマットするためのScalaの優れた方法はありますか?例えば
myMonthSelectionInfo.setMonthSelection(newMonthSelection)