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, when implementing the Serde interface, it's not possible to check the class of the deserializable value (for example - an enum class) to deserialize the value to that specific class, because in CoerceUtil class the register(Class<T> targetType, Serde<S, T> serde) method doesn't pass the class to serde.deserialize:
publicstatic <S, T> voidregister(Class<T> targetType, Serde<S, T> serde) {
initializeCurrentClassLoaderIfNecessary();
SERDES.put(targetType, serde);
ConvertUtils.register(newConverter() {
@Overridepublic <T> Tconvert(Class<T> aClass, Objecto) {
return (T) serde.deserialize((S) o);
// here we could pass the class as well - return (T) serde.deserialize(aClass, (S) o);
}
}, targetType);
}
If the class is also passed to the serde.deserialize method, maybe the Serde interface could have another deserializeWithType (or similar) method instead?
Here's an example @ElideTypeConverter annotated class that could be used to deserialize enum classes that extend or implement a BaseEnum class:
Current Behavior
Currently, when implementing the
Serde
interface, it's not possible to check the class of the deserializable value (for example - an enum class) to deserialize the value to that specific class, because inCoerceUtil
class theregister(Class<T> targetType, Serde<S, T> serde)
method doesn't pass the class toserde.deserialize
:If the class is also passed to the
serde.deserialize
method, maybe theSerde
interface could have anotherdeserializeWithType
(or similar) method instead?Here's an example
@ElideTypeConverter
annotated class that could be used to deserialize enum classes that extend or implement aBaseEnum
class:Your Environment
The text was updated successfully, but these errors were encountered: