I have created the following enum objects
sealed trait MsgMapping[T] {def mycode: T;}
object Type1 {
sealed trait msg[Int] extends MsgMapping[Int]
case object A extends msg[Int]{val myCode = 0;}
case object B extends msg[Int]{val myCode = 1;}
}
object Type2 {
sealed trait msgtype[String] extends MsgMapping[String]
case object C extends msgtype[String]{val myCode = "xyz";}
case object D extends msgtype[String]{val myCode = "def";}
}
I want to create a generic case class that can except any type of MessageMapping ,it can be an Integer/String or any data type
But this line gives error as it expects the type.
case class EumType(valueType: MsgMapping [T])
The below works
case class EumType1(valueType: MsgMapping [Int])
case class EumType2(valueType: MsgMapping [String])
case class TestEnum(value:EumType1)
case class Test(val:TestEnum)
But I do not want to create EumType1 and EumType2 .Can anyone help to me to create a generic code for this
Update
As per suggestion
case class EnumType[T](valueType: MsgMapping[T])
case class TestEnum(value:EnumType[T])
It will throw compile error since it expects type
here but i want to pass the type on this line
case class Test(val:TestEnum) ,whether it is Type1 /Type2
case class EnumType[T](valueType: MessageMapping[T])
? - slouc