diff --git a/src/main/java/com/fasterxml/jackson/databind/DeserializationFeature.java b/src/main/java/com/fasterxml/jackson/databind/DeserializationFeature.java index 5fd5ca48ee..004ea436f5 100644 --- a/src/main/java/com/fasterxml/jackson/databind/DeserializationFeature.java +++ b/src/main/java/com/fasterxml/jackson/databind/DeserializationFeature.java @@ -359,8 +359,6 @@ public enum DeserializationFeature implements ConfigFeature * to be equivalent of JSON null. *

* Feature is disabled by default. - * - * @since 2.5 */ ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT(false), @@ -373,8 +371,6 @@ public enum DeserializationFeature implements ConfigFeature * will be thrown. *

* Feature is enabled by default. - * - * @since 2.6 */ ACCEPT_FLOAT_AS_INT(true), @@ -401,8 +397,6 @@ public enum DeserializationFeature implements ConfigFeature * cases). *

* Feature is disabled by default. - * - * @since 2.0 */ READ_UNKNOWN_ENUM_VALUES_AS_NULL(false), @@ -413,8 +407,6 @@ public enum DeserializationFeature implements ConfigFeature * If enabled, but no predefined default Enum value is specified, an exception will be thrown as well. *

* Feature is disabled by default. - * - * @since 2.8 */ READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE(false), @@ -430,8 +422,6 @@ public enum DeserializationFeature implements ConfigFeature * This is the counterpart to {@link SerializationFeature#WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS}. *

* Feature is enabled by default, to support most accurate time values possible. - * - * @since 2.2 */ READ_DATE_TIMESTAMPS_AS_NANOSECONDS(true), @@ -454,8 +444,6 @@ public enum DeserializationFeature implements ConfigFeature *

* Taking above into account, this feature is supported only by extension modules for * Joda and Java 8 date/tyime datatypes. - * - * @since 2.2 */ ADJUST_DATES_TO_CONTEXT_TIME_ZONE(true), @@ -476,8 +464,6 @@ public enum DeserializationFeature implements ConfigFeature * feature: only consider that if there are actual perceived problems. *

* Feature is enabled by default. - * - * @since 2.1 */ EAGER_DESERIALIZER_FETCH(true) diff --git a/src/main/java/com/fasterxml/jackson/databind/MapperFeature.java b/src/main/java/com/fasterxml/jackson/databind/MapperFeature.java index ab64e26e29..c997c94da6 100644 --- a/src/main/java/com/fasterxml/jackson/databind/MapperFeature.java +++ b/src/main/java/com/fasterxml/jackson/databind/MapperFeature.java @@ -58,8 +58,6 @@ public enum MapperFeature implements ConfigFeature * Feature is disabled by default, meaning that existence of `transient` * for a field does not necessarily lead to ignoral of getters or setters * but just ignoring the use of field for access. - * - * @since 2.6 */ PROPAGATE_TRANSIENT_MARKER(false), @@ -83,8 +81,6 @@ public enum MapperFeature implements ConfigFeature * explicitly annotated for such use. *

* Feature is enabled by default, for backwards compatibility reasons. - * - * @since 2.2 */ ALLOW_FINAL_FIELDS_AS_MUTATORS(true), @@ -101,8 +97,6 @@ public enum MapperFeature implements ConfigFeature * bean-style naming) or explicitly annotated. *

* Feature is enabled by default. - * - * @since 2.2 */ INFER_PROPERTY_MUTATORS(true), @@ -120,8 +114,6 @@ public enum MapperFeature implements ConfigFeature * for deserialization. *

* Feature is enabled by default. - * - * @since 2.9 */ INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES(true), @@ -170,8 +162,6 @@ public enum MapperFeature implements ConfigFeature *

* Feature is enabled by default, for legacy reasons (it was the behavior * until 2.6) - * - * @since 2.7 */ OVERRIDE_PUBLIC_ACCESS_MODIFIERS(true), @@ -262,8 +252,6 @@ public enum MapperFeature implements ConfigFeature * letters. Overhead for names that are already lower-case should be negligible however. *

* Feature is disabled by default. - * - * @since 2.5 */ ACCEPT_CASE_INSENSITIVE_PROPERTIES(false), @@ -275,8 +263,6 @@ public enum MapperFeature implements ConfigFeature * explicit override) do not need to match. *

* Feature is disabled by default. - * - * @since 2.9 */ ACCEPT_CASE_INSENSITIVE_ENUMS(false), @@ -289,8 +275,6 @@ public enum MapperFeature implements ConfigFeature * If disabled, wrapper name is only used for wrapping (if anything). *

* Feature is disabled by default. - * - * @since 2.1 */ USE_WRAPPER_NAME_AS_PROPERTY_NAME(false), @@ -300,8 +284,6 @@ public enum MapperFeature implements ConfigFeature * be re-named by a {@link PropertyNamingStrategy}, if one is configured. *

* Feature is disabled by default. - * - * @since 2.7 */ ALLOW_EXPLICIT_PROPERTY_RENAMING(false), @@ -328,8 +310,6 @@ public enum MapperFeature implements ConfigFeature *

* Feature is enabled by default (for backwards compatibility since this was the * default behavior) - * - * @since 2.9 */ ALLOW_COERCION_OF_SCALARS(true), @@ -353,8 +333,6 @@ public enum MapperFeature implements ConfigFeature * this feature is enabled). *

* Feature is enabled by default. - * - * @since 2.5 */ IGNORE_DUPLICATE_MODULE_REGISTRATIONS(true), @@ -367,8 +345,6 @@ public enum MapperFeature implements ConfigFeature * Feature is disabled by default since non-mergeable property types are ignored * even if defaults call for merging, and usually explicit per-type or per-property * settings for such types should result in an exception. - * - * @since 2.9 */ IGNORE_MERGE_FOR_UNMERGEABLE(true) diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java index ac6bd638fe..29437a9590 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java +++ b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java @@ -24,8 +24,8 @@ import com.fasterxml.jackson.databind.introspect.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.*; +import com.fasterxml.jackson.databind.jsontype.impl.DefaultTypeResolverBuilder; import com.fasterxml.jackson.databind.jsontype.impl.StdSubtypeResolver; -import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder; import com.fasterxml.jackson.databind.node.*; import com.fasterxml.jackson.databind.ser.*; import com.fasterxml.jackson.databind.type.*; @@ -176,94 +176,6 @@ public enum DefaultTyping { NON_FINAL } - /** - * Customized {@link TypeResolverBuilder} that provides type resolver builders - * used with so-called "default typing" - * (see {@link ObjectMapper#enableDefaultTyping()} for details). - *

- * Type resolver construction is based on configuration: implementation takes care - * of only providing builders in cases where type information should be applied. - * This is important since build calls may be sent for any and all types, and - * type information should NOT be applied to all of them. - */ - public static class DefaultTypeResolverBuilder - extends StdTypeResolverBuilder - implements java.io.Serializable - { - private static final long serialVersionUID = 1L; - - /** - * Definition of what types is this default typer valid for. - */ - protected final DefaultTyping _appliesFor; - - public DefaultTypeResolverBuilder(DefaultTyping t) { - _appliesFor = t; - } - - @Override - public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, - JavaType baseType, Collection subtypes) - { - return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes) : null; - } - - @Override - public TypeSerializer buildTypeSerializer(SerializationConfig config, - JavaType baseType, Collection subtypes) - { - return useForType(baseType) ? super.buildTypeSerializer(config, baseType, subtypes) : null; - } - - /** - * Method called to check if the default type handler should be - * used for given type. - * Note: "natural types" (String, Boolean, Integer, Double) will never - * use typing; that is both due to them being concrete and final, - * and since actual serializers and deserializers will also ignore any - * attempts to enforce typing. - */ - public boolean useForType(JavaType t) - { - // 03-Oct-2016, tatu: As per [databind#1395], need to skip - // primitive types too, regardless - if (t.isPrimitive()) { - return false; - } - - switch (_appliesFor) { - case NON_CONCRETE_AND_ARRAYS: - while (t.isArrayType()) { - t = t.getContentType(); - } - // fall through - case OBJECT_AND_NON_CONCRETE: - // 19-Apr-2016, tatu: ReferenceType like Optional also requires similar handling: - while (t.isReferenceType()) { - t = t.getReferencedType(); - } - return t.isJavaLangObject() - || (!t.isConcrete() - // [databind#88] Should not apply to JSON tree models: - && !TreeNode.class.isAssignableFrom(t.getRawClass())); - - case NON_FINAL: - while (t.isArrayType()) { - t = t.getContentType(); - } - // 19-Apr-2016, tatu: ReferenceType like Optional also requires similar handling: - while (t.isReferenceType()) { - t = t.getReferencedType(); - } - // [databind#88] Should not apply to JSON tree models: - return !t.isFinal() && !TreeNode.class.isAssignableFrom(t.getRawClass()); - default: - //case JAVA_LANG_OBJECT: - return t.isJavaLangObject(); - } - } - } - /* /********************************************************** /* Internal constants, singletons @@ -436,7 +348,7 @@ public boolean useForType(JavaType t) * (should very quickly converge to zero after startup), let's * explicitly define a low concurrency setting. *

- * Since version 1.5, these may are either "raw" deserializers (when + * These may are either "raw" deserializers (when * no type information is needed for base type), or type-wrapped * deserializers (if it is needed) */ diff --git a/src/main/java/com/fasterxml/jackson/databind/cfg/BaseSettings.java b/src/main/java/com/fasterxml/jackson/databind/cfg/BaseSettings.java index 49d80fe677..c6b1edc053 100644 --- a/src/main/java/com/fasterxml/jackson/databind/cfg/BaseSettings.java +++ b/src/main/java/com/fasterxml/jackson/databind/cfg/BaseSettings.java @@ -21,17 +21,12 @@ public final class BaseSettings implements java.io.Serializable { - // for 2.6 private static final long serialVersionUID = 1L; /** * We will use a default TimeZone as the baseline. */ private static final TimeZone DEFAULT_TIMEZONE = - // TimeZone.getDefault() - /* [databind#915] 05-Nov-2015, tatu: Changed to UTC, from earlier - * baseline of GMT (up to 2.6) - */ TimeZone.getTimeZone("UTC"); /* diff --git a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/DefaultTypeResolverBuilder.java b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/DefaultTypeResolverBuilder.java new file mode 100644 index 0000000000..b4847ad6cc --- /dev/null +++ b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/DefaultTypeResolverBuilder.java @@ -0,0 +1,102 @@ +package com.fasterxml.jackson.databind.jsontype.impl; + +import java.util.Collection; + +import com.fasterxml.jackson.core.TreeNode; +import com.fasterxml.jackson.databind.DeserializationConfig; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationConfig; +import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; +import com.fasterxml.jackson.databind.jsontype.NamedType; +import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; +import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; +import com.fasterxml.jackson.databind.jsontype.TypeSerializer; + +/** + * Customized {@link TypeResolverBuilder} that provides type resolver builders + * used with so-called "default typing" + * (see {@link ObjectMapper#enableDefaultTyping()} for details). + *

+ * Type resolver construction is based on configuration: implementation takes care + * of only providing builders in cases where type information should be applied. + * This is important since build calls may be sent for any and all types, and + * type information should NOT be applied to all of them. + */ +public class DefaultTypeResolverBuilder + extends StdTypeResolverBuilder + implements java.io.Serializable +{ + private static final long serialVersionUID = 1L; + + /** + * Definition of what types is this default typer valid for. + */ + protected final DefaultTyping _appliesFor; + + public DefaultTypeResolverBuilder(DefaultTyping t) { + _appliesFor = t; + } + + @Override + public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, + JavaType baseType, Collection subtypes) + { + return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes) : null; + } + + @Override + public TypeSerializer buildTypeSerializer(SerializationConfig config, + JavaType baseType, Collection subtypes) + { + return useForType(baseType) ? super.buildTypeSerializer(config, baseType, subtypes) : null; + } + + /** + * Method called to check if the default type handler should be + * used for given type. + * Note: "natural types" (String, Boolean, Integer, Double) will never + * use typing; that is both due to them being concrete and final, + * and since actual serializers and deserializers will also ignore any + * attempts to enforce typing. + */ + public boolean useForType(JavaType t) + { + // 03-Oct-2016, tatu: As per [databind#1395], need to skip + // primitive types too, regardless + if (t.isPrimitive()) { + return false; + } + + switch (_appliesFor) { + case NON_CONCRETE_AND_ARRAYS: + while (t.isArrayType()) { + t = t.getContentType(); + } + // fall through + case OBJECT_AND_NON_CONCRETE: + // 19-Apr-2016, tatu: ReferenceType like Optional also requires similar handling: + while (t.isReferenceType()) { + t = t.getReferencedType(); + } + return t.isJavaLangObject() + || (!t.isConcrete() + // [databind#88] Should not apply to JSON tree models: + && !TreeNode.class.isAssignableFrom(t.getRawClass())); + + case NON_FINAL: + while (t.isArrayType()) { + t = t.getContentType(); + } + // 19-Apr-2016, tatu: ReferenceType like Optional also requires similar handling: + while (t.isReferenceType()) { + t = t.getReferencedType(); + } + // [databind#88] Should not apply to JSON tree models: + return !t.isFinal() && !TreeNode.class.isAssignableFrom(t.getRawClass()); + default: + //case JAVA_LANG_OBJECT: + return t.isJavaLangObject(); + } + } +} \ No newline at end of file diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/creators/jdk8/PersonTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/creators/jdk8/PersonTest.java index 80fa51176c..9ea99aec4f 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/creators/jdk8/PersonTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/creators/jdk8/PersonTest.java @@ -35,12 +35,10 @@ public String getSurname() { } public String getNickname() { - return nickname; } public void setNickname(String nickname) { - this.nickname = nickname; } } diff --git a/src/test/java/com/fasterxml/jackson/databind/jsontype/TestDefaultForMaps.java b/src/test/java/com/fasterxml/jackson/databind/jsontype/TestDefaultForMaps.java index aa5ada478f..78517d2a38 100644 --- a/src/test/java/com/fasterxml/jackson/databind/jsontype/TestDefaultForMaps.java +++ b/src/test/java/com/fasterxml/jackson/databind/jsontype/TestDefaultForMaps.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; +import com.fasterxml.jackson.databind.jsontype.impl.DefaultTypeResolverBuilder; import com.fasterxml.jackson.databind.jsontype.impl.TypeNameIdResolver; import com.fasterxml.jackson.databind.type.TypeFactory; @@ -72,7 +73,7 @@ public void testJackson428() throws Exception { ObjectMapper serMapper = new ObjectMapper(); - TypeResolverBuilder serializerTyper = new ObjectMapper.DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL); + TypeResolverBuilder serializerTyper = new DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL); serializerTyper = serializerTyper.init(JsonTypeInfo.Id.NAME, createTypeNameIdResolver(true)); serializerTyper = serializerTyper.inclusion(JsonTypeInfo.As.PROPERTY); serMapper.setDefaultTyping(serializerTyper); @@ -87,7 +88,7 @@ public void testJackson428() throws Exception // Then deserialize: need separate mapper to initialize type id resolver appropriately ObjectMapper deserMapper = new ObjectMapper(); - TypeResolverBuilder deserializerTyper = new ObjectMapper.DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL); + TypeResolverBuilder deserializerTyper = new DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL); deserializerTyper = deserializerTyper.init(JsonTypeInfo.Id.NAME, createTypeNameIdResolver(false)); deserializerTyper = deserializerTyper.inclusion(JsonTypeInfo.As.PROPERTY); deserMapper.setDefaultTyping(deserializerTyper); diff --git a/src/test/java/com/fasterxml/jackson/databind/ser/TestKeySerializers.java b/src/test/java/com/fasterxml/jackson/databind/ser/TestKeySerializers.java index 0712aa6fe7..2e35e39c96 100644 --- a/src/test/java/com/fasterxml/jackson/databind/ser/TestKeySerializers.java +++ b/src/test/java/com/fasterxml/jackson/databind/ser/TestKeySerializers.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; +import com.fasterxml.jackson.databind.jsontype.impl.DefaultTypeResolverBuilder; import com.fasterxml.jackson.databind.module.SimpleModule; public class TestKeySerializers extends BaseMapTest @@ -208,7 +209,7 @@ public void testUnWrappedMapWithDefaultType() throws Exception{ mod.addKeySerializer(ABC.class, new ABCKeySerializer()); mapper.registerModule(mod); - TypeResolverBuilder typer = new ObjectMapper.DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL); + TypeResolverBuilder typer = new DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL); typer = typer.init(JsonTypeInfo.Id.NAME, null); typer = typer.inclusion(JsonTypeInfo.As.PROPERTY); //typer = typer.typeProperty(TYPE_FIELD);