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
|
||||
|
||||
|
||||
|
||||
|
||||
data class FactorioServerLogRecord<DataType : FactorioObjectData>(
|
||||
@JsonProperty("mod_version")
|
||||
val modVersion: String,
|
||||
|
|
@ -22,12 +20,11 @@ data class FactorioServerLogRecord<DataType : FactorioObjectData>(
|
|||
val data: DataType,
|
||||
)
|
||||
|
||||
|
||||
@JsonTypeInfo(
|
||||
use = JsonTypeInfo.Id.NAME,
|
||||
include = JsonTypeInfo.As.PROPERTY,
|
||||
include = JsonTypeInfo.As.EXISTING_PROPERTY,
|
||||
property = "object_name",
|
||||
defaultImpl = Void::class, // equivalent to null
|
||||
defaultImpl = UnknownFactorioObject::class,
|
||||
visible = true,
|
||||
)
|
||||
sealed class FactorioObjectData(
|
||||
|
|
@ -35,6 +32,8 @@ sealed class FactorioObjectData(
|
|||
val objectName: String
|
||||
)
|
||||
|
||||
object UnknownFactorioObject : FactorioObjectData("unknown")
|
||||
|
||||
@JsonTypeName("LuaSurface")
|
||||
class LuaSurfaceData(
|
||||
@JsonProperty("name")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue