Last active
July 9, 2022 14:22
-
-
Save aleksandarzekovic/b2f1039ca84c6678b07d5e287a0c8848 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
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