trying json polymorphism stuff...
This commit is contained in:
parent
4ca40afa09
commit
5cdc9e8dc7
1 changed files with 4 additions and 5 deletions
|
|
@ -9,8 +9,6 @@ import java.math.BigInteger
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data class FactorioServerLogRecord<DataType : FactorioObjectData>(
|
data class FactorioServerLogRecord<DataType : FactorioObjectData>(
|
||||||
@JsonProperty("mod_version")
|
@JsonProperty("mod_version")
|
||||||
val modVersion: String,
|
val modVersion: String,
|
||||||
|
|
@ -22,12 +20,11 @@ data class FactorioServerLogRecord<DataType : FactorioObjectData>(
|
||||||
val data: DataType,
|
val data: DataType,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@JsonTypeInfo(
|
@JsonTypeInfo(
|
||||||
use = JsonTypeInfo.Id.NAME,
|
use = JsonTypeInfo.Id.NAME,
|
||||||
include = JsonTypeInfo.As.PROPERTY,
|
include = JsonTypeInfo.As.EXISTING_PROPERTY,
|
||||||
property = "object_name",
|
property = "object_name",
|
||||||
defaultImpl = Void::class, // equivalent to null
|
defaultImpl = UnknownFactorioObject::class,
|
||||||
visible = true,
|
visible = true,
|
||||||
)
|
)
|
||||||
sealed class FactorioObjectData(
|
sealed class FactorioObjectData(
|
||||||
|
|
@ -35,6 +32,8 @@ sealed class FactorioObjectData(
|
||||||
val objectName: String
|
val objectName: String
|
||||||
)
|
)
|
||||||
|
|
||||||
|
object UnknownFactorioObject : FactorioObjectData("unknown")
|
||||||
|
|
||||||
@JsonTypeName("LuaSurface")
|
@JsonTypeName("LuaSurface")
|
||||||
class LuaSurfaceData(
|
class LuaSurfaceData(
|
||||||
@JsonProperty("name")
|
@JsonProperty("name")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue