diff --git a/release-notes/VERSION b/release-notes/VERSION index 4bcb857613..41e5c1c593 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -25,4 +25,5 @@ Versions: 3.x (for earlier see VERSION-2.x) #1889: Merge `ContextualSerializer` into `JsonSerializer`, `ContextualDeserializer` into `JsonDeserializer` #1916: Change `MapperFeature.USE_GETTERS_AS_SETTERS)` default to `false` +#1917: Remove `canSerialize` and `canDeserialize` methods from `ObjectMapper` - Remove `MappingJsonFactory` diff --git a/src/main/java/com/fasterxml/jackson/databind/DeserializationContext.java b/src/main/java/com/fasterxml/jackson/databind/DeserializationContext.java index df4857dc0b..ffc32e6976 100644 --- a/src/main/java/com/fasterxml/jackson/databind/DeserializationContext.java +++ b/src/main/java/com/fasterxml/jackson/databind/DeserializationContext.java @@ -4,7 +4,6 @@ import java.text.DateFormat; import java.text.ParseException; import java.util.*; -import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.ObjectIdGenerator; @@ -535,26 +534,6 @@ public final JsonNodeFactory getNodeFactory() { /********************************************************** */ - /** - * Method for checking whether we could find a deserializer - * for given type. - */ - public boolean hasValueDeserializerFor(JavaType type, AtomicReference cause) { - try { - return _cache.hasValueDeserializerFor(this, _factory, type); - } catch (JsonMappingException e) { - if (cause != null) { - cause.set(e); - } - } catch (RuntimeException e) { - if (cause == null) { // earlier behavior - throw e; - } - cause.set(e); - } - return false; - } - /** * Method for finding a value deserializer, and creating a contextual * version if necessary, for value reached via specified property. diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java index ea8a60677e..59cfc8457e 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java +++ b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java @@ -8,7 +8,6 @@ import java.text.DateFormat; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.core.*; @@ -2571,46 +2570,8 @@ public T valueToTree(Object fromValue) throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; - } - - /* - /********************************************************** - /* Public API, accessors - /********************************************************** - */ - - /** - * Method that can be called to check whether mapper thinks - * it could deserialize an Object of given type. - * Check is done by checking whether a registered deserializer can - * be found or built for the type; if not (either by no mapping being - * found, or through an Exception being thrown, false - * is returned. - *

- * NOTE: in case an exception is thrown during course of trying - * co construct matching deserializer, it will be effectively swallowed. - * If you want access to that exception, call - * {@link #canDeserialize(JavaType, AtomicReference)} instead. - * - * @return True if mapper can find a serializer for instances of - * given class (potentially serializable), false otherwise (not - * serializable) - */ - public boolean canDeserialize(JavaType type) - { - return createDeserializationContext().hasValueDeserializerFor(type, null); } - /** - * Method similar to {@link #canDeserialize(JavaType)} but that can return - * actual {@link Throwable} that was thrown when trying to construct - * serializer: this may be useful in figuring out what the actual problem is. - */ - public boolean canDeserialize(JavaType type, AtomicReference cause) - { - return createDeserializationContext().hasValueDeserializerFor(type, cause); - } - /* /********************************************************** /* Public API, deserialization, diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/DeserializerCache.java b/src/main/java/com/fasterxml/jackson/databind/deser/DeserializerCache.java index 217a85a370..00c078c459 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/DeserializerCache.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/DeserializerCache.java @@ -172,24 +172,25 @@ public KeyDeserializer findKeyDeserializer(DeserializationContext ctxt, return kd; } + // as per [databind#1917], not needed any more: /** * Method called to find out whether provider would be able to find * a deserializer for given type, using a root reference (i.e. not * through fields or membership in an array or collection) - */ public boolean hasValueDeserializerFor(DeserializationContext ctxt, DeserializerFactory factory, JavaType type) throws JsonMappingException { - /* Note: mostly copied from findValueDeserializer, except for - * handling of unknown types - */ + // Note: mostly copied from findValueDeserializer, except for + // handling of unknown types JsonDeserializer deser = _findCachedDeserializer(type); if (deser == null) { deser = _createAndCacheValueDeserializer(ctxt, factory, type); } return (deser != null); } +*/ + /* /**********************************************************