From 33ba4ad08ee2220b62028101b026e29ed4167d52 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 10 May 2016 20:03:26 -0700 Subject: Added DeserializationContext.handleUnknownTypeId() --- .../deser/DeserializationProblemHandler.java | 47 ++++++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/fasterxml/jackson/databind/deser/DeserializationProblemHandler.java') diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/DeserializationProblemHandler.java b/src/main/java/com/fasterxml/jackson/databind/deser/DeserializationProblemHandler.java index 453a16758..22a2d1775 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/DeserializationProblemHandler.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/DeserializationProblemHandler.java @@ -5,6 +5,7 @@ import java.io.IOException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationConfig; import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.ObjectMapper; @@ -73,8 +74,8 @@ public abstract class DeserializationProblemHandler /** * Method called when a property name from input can not be converted to a - * non-Java-String key type (passed as rawKeyType) due to format - * problem. Handler may choose to do one of 3 things: + * non-Java-String key type (passed as rawKeyType) due to format problem. + * Handler may choose to do one of 3 things: * * - * @since 2.8 - * * @param failureMsg Message that will be used by caller (by calling * {@link DeserializationContext#weirdKeyException(Class, String, String)}) * to indicate type of failure unless handler produces key to use @@ -94,6 +93,8 @@ public abstract class DeserializationProblemHandler * @return Either {@link #NOT_HANDLED} to indicate that handler does not know * what to do (and exception may be thrown), or value to use as key (possibly * null + * + * @since 2.8 */ public Object handleWeirdKey(DeserializationContext ctxt, Class rawKeyType, String keyValue, @@ -102,4 +103,42 @@ public abstract class DeserializationProblemHandler { return NOT_HANDLED; } + + /** + * Handler method called if resolution of type id from given String failed + * to produce a subtype; usually because logical id is not mapped to actual + * implementation class. + * Handler may choose to do one of following things: + * + * + * @param ctxt Deserialization context to use for accessing information or + * constructing exception to throw + * @param baseType Base type to use for resolving subtype id + * @param subTypeId Subtype id that failed to resolve + * @param failureMsg Informational message that would be thrown as part of + * exception, if resolution still fails + * + * @return Actual type to use, if resolved; `null` if handler does not know what + * to do; or `Void.class` to indicate that nothing should be deserialized for + * type with the id (which caller may choose to do... or not) + * + * @since 2.8 + */ + public JavaType handleUnknownTypeId(DeserializationContext ctxt, + JavaType baseType, String subTypeId, + String failureMsg) + throws IOException + { + return null; + } } -- cgit v1.2.3