Last active
February 18, 2020 10:30
-
-
Save skvithalani/2d68b667bfaccecc6a4b84252bccfdc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait JacksonSerializable | |
final case class Zoo(primaryAttraction: Animal) extends JacksonSerializable | |
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") | |
@JsonSubTypes( | |
Array( | |
new JsonSubTypes.Type(value = classOf[Lion], name = "lion"), | |
new JsonSubTypes.Type(value = classOf[Elephant], name = "elephant") | |
) | |
) | |
sealed abstract class Animal | |
object Animal { | |
final case class Lion(name: String) extends Animal | |
final case class Elephant(name: String, age: Int) extends Animal | |
final case object Tiger extends Animal | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment