Skip to content

Instantly share code, notes, and snippets.

@aleksandarzekovic
Last active July 9, 2022 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleksandarzekovic/b2f1039ca84c6678b07d5e287a0c8848 to your computer and use it in GitHub Desktop.
Save aleksandarzekovic/b2f1039ca84c6678b07d5e287a0c8848 to your computer and use it in GitHub Desktop.
enum class VehicleType {
TRUCK,
PLANE;
}
// 1
sealed interface Vehicle {
val type: VehicleType
}
// 2
@JsonClass(generateAdapter = true)
data class Truck (
@Json(name = "waterCannon") val waterCannon: Boolean
): Vehicle {
override val type = VehicleType.TRUCK
}
// 3
@JsonClass(generateAdapter = true)
data class Plane (
@Json(name = "wingsSpanInMeters") val wingsSpanInMeters: Int
): Vehicle {
override val type = VehicleType.PLANE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment