Skip to content

Instantly share code, notes, and snippets.

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/a738d7f83c8d11b9eff21ae796eb69a0 to your computer and use it in GitHub Desktop.
Save aleksandarzekovic/a738d7f83c8d11b9eff21ae796eb69a0 to your computer and use it in GitHub Desktop.
val vehicleFactory = PolymorphicJsonAdapterFactory.of(Vehicle::class.java, "type")
.withSubtype(Truck::class.java, VehicleType.TRUCK.name)
.withSubtype(Plane::class.java, VehicleType.PLANE.name)
.withDefaultValue(Unknown) // here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment