You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently implementations of SerializationCustomSerializer need to be specific about the target type, so i end up with e.g.
class AppleSerializer(): FruitCustomSerializer<Apple>(),
SerializationCustomSerializer<Apple, JsonStringProxy<Apple>>
class OrangeSerializer(): FruitCustomSerializer<Orange>(),
SerializationCustomSerializer<Orange, JsonStringProxy<Orange>>
// repeat for all fruit types
Instead, i would like to create a generic serializer or factory like
class FruitCustomSerializer<T: Fruit> : SerializationCustomSerializer<T, JsonStringProxy<T>> {
override fun toProxy(obj: T): JsonStringProxy<T> {
return JsonStringProxy(
jsonString = FruitUtil.toJsonString(obj),
targetType = obj.javaClass)
}
override fun fromProxy(proxy: JsonStringProxy<T>) : T {
return FruitUtil.toFruit(proxy.jsonString, proxy.targetType)
}
}
I suppose the API could be enhanced with a method for the serializer to report if it supports a concrete class etc.
The text was updated successfully, but these errors were encountered:
Currently implementations of
SerializationCustomSerializer
need to be specific about the target type, so i end up with e.g.Instead, i would like to create a generic serializer or factory like
I suppose the API could be enhanced with a method for the serializer to report if it supports a concrete class etc.
The text was updated successfully, but these errors were encountered: