I have seen some examples to use ADT to extend data types to fit into either of the options but I am little confused on how to implement it in this kind of use case. In case classes I would create them and just add extends TraitName
but what about primitive data types?
My sealed trait is AEMExpectedPayload
which could be Booolean, Int, String, Seq[String],Seq[Boolean], or Seq[Int].
I want to do something like this:
sealed trait StringInt
String extends StringInt
Int extends StringInt
I see one way as:
sealed trait StringInt
case class Stringy(s : String) extends StringInt
case class Inty(s : Int) extends StringInt
However I wanted to confirm if this is the only way and nothing else?
Here's how I would want to use it:
val stringResult:StringInt = "test-string"
val intResult:StringInt = 22