I'm new to scala and looking for the "scala" way to create the correct case class (trait conforming) taken from a stringed enum by an external source. Since the source is external there should be some validation that the input is correct, and given valid input will give back the correct case class. I would assume this to be a "factory" that returns an optional case class of the given trait
Example:
trait ProcessingMechanism
case object PMv1 extends ProcessingMechanism
case object PMv2 extends ProcessingMechanism
case object PMv3 extends ProcessingMechanism
...
...
I would like to have a factory to return the correct ProcessingMechanism
i.e.
object ProcessingMechanismFactory {
... switch on the input string to return the correct mechanism???
... is there a simple way to do this?
}