From 4489bb50530600e0ebf735ca7a70782305819a3a Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 8 Aug 2017 11:07:58 -0700 Subject: [PATCH] more deprecated method removal --- pom.xml | 7 +- .../databind/AnnotationIntrospector.java | 288 ------------------ .../fasterxml/jackson/databind/JavaType.java | 32 +- .../AnnotationIntrospectorPair.java | 145 +-------- .../JacksonAnnotationIntrospector.java | 131 +------- .../jackson/databind/type/ArrayType.java | 14 - .../databind/type/CollectionLikeType.java | 8 - .../jackson/databind/type/CollectionType.java | 7 - .../jackson/databind/type/MapLikeType.java | 12 - .../jackson/databind/type/MapType.java | 8 - .../jackson/databind/type/ReferenceType.java | 16 - .../databind/type/ResolvedRecursiveType.java | 6 - .../jackson/databind/type/SimpleType.java | 48 --- .../jackson/databind/util/BeanUtil.java | 30 +- .../jackson/databind/util/TokenBuffer.java | 74 +---- .../jackson/databind/util/BeanUtilTest.java | 21 +- 16 files changed, 23 insertions(+), 824 deletions(-) diff --git a/pom.xml b/pom.xml index fc2acc196d..fe7d03427b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,14 @@ com.fasterxml.jackson jackson-bom - 2.9.0 + 3.0.0-SNAPSHOT com.fasterxml.jackson.core jackson-databind + jackson-databind bundle General data-binding functionality for Jackson: works on core streaming API @@ -48,10 +50,7 @@ usage seems to benefit from actually specifying version here in case it is dependent on transitively --> - - 3.0.0-SNAPSHOT com.fasterxml.jackson.core diff --git a/src/main/java/com/fasterxml/jackson/databind/AnnotationIntrospector.java b/src/main/java/com/fasterxml/jackson/databind/AnnotationIntrospector.java index bd83f0e8b9..4deda329f7 100644 --- a/src/main/java/com/fasterxml/jackson/databind/AnnotationIntrospector.java +++ b/src/main/java/com/fasterxml/jackson/databind/AnnotationIntrospector.java @@ -224,17 +224,9 @@ public PropertyName findRootName(AnnotatedClass ac) { /** * Method for finding information about properties to ignore either by * name, or by more general specification ("ignore all unknown"). - * This method combines multiple aspects of ignorals and deprecates - * earlier methods such as - * {@link #findPropertiesToIgnore(Annotated, boolean)} and - * {@link #findIgnoreUnknownProperties(AnnotatedClass)}. - * - * @since 2.8 */ public JsonIgnoreProperties.Value findPropertyIgnorals(Annotated ac) { - // 18-Oct-2016, tatu: Used to call deprecated methods for backwards - // compatibility in 2.8, but not any more in 2.9 return JsonIgnoreProperties.Value.empty(); } @@ -286,35 +278,6 @@ public JsonIgnoreProperties.Value findPropertyIgnorals(Annotated ac) */ public String findClassDescription(AnnotatedClass ac) { return null; } - /** - * @param forSerialization True if requesting properties to ignore for serialization; - * false if for deserialization - * - * @since 2.6 - * - * @deprecated Since 2.8, use {@link #findPropertyIgnorals} instead - */ - @Deprecated // since 2.8 - public String[] findPropertiesToIgnore(Annotated ac, boolean forSerialization) { - return null; - } - - /** - * @deprecated Since 2.6, use variant that takes second argument. - */ - @Deprecated // since 2.6 - public String[] findPropertiesToIgnore(Annotated ac) { - return null; - } - - /** - * Method for checking whether an annotation indicates that all unknown properties - * - * @deprecated Since 2.8, use {@link #findPropertyIgnorals} instead - */ - @Deprecated // since 2.8 - public Boolean findIgnoreUnknownProperties(AnnotatedClass ac) { return null; } - /* /********************************************************** /* Property auto-detection @@ -467,16 +430,8 @@ public TypeResolverBuilder findPropertyContentTypeResolver(MapperConfig co * * @return Identifier of value to inject, if any; null if no injection * indicator is found - * - * @since 2.9 */ public JacksonInject.Value findInjectableValue(AnnotatedMember m) { - // 05-Apr-2017, tatu: Just for 2.9, call deprecated method to help - // with some cases of overrides for legacy code - Object id = findInjectableValueId(m); - if (id != null) { - return JacksonInject.Value.forId(id); - } return null; } @@ -614,14 +569,6 @@ public AnnotatedMethod resolveSetterConflict(MapperConfig config, return null; } - /** - * @deprecated Since 2.9 Use {@link #findInjectableValue} instead - */ - @Deprecated // since 2.9 - public Object findInjectableValueId(AnnotatedMember m) { - return null; - } - /* /********************************************************** /* Serialization: general annotations @@ -736,49 +683,11 @@ public Object findSerializationContentConverter(AnnotatedMember a) { * name is bit unfortunate -- not just for properties!). * In case of class, acts as the default for properties POJO contains; for properties * acts as override for class defaults and possible global defaults. - * - * @since 2.6 */ public JsonInclude.Value findPropertyInclusion(Annotated a) { return JsonInclude.Value.empty(); } - /** - * Method for checking whether given annotated entity (class, method, - * field) defines which Bean/Map properties are to be included in - * serialization. - * If no annotation is found, method should return given second - * argument; otherwise value indicated by the annotation. - *

- * Note that meaning of inclusion value depends on whether it is for - * a Class or property (field/method/constructor): in former case, - * it is the default for all properties; in latter case it is specific - * override for annotated property. - * - * @return Enumerated value indicating which properties to include - * in serialization - * - * @deprecated Since 2.7 Use {@link #findPropertyInclusion} instead - */ - @Deprecated // since 2.7 - public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.Include defValue) { - return defValue; - } - - /** - * Method for checking whether content (entries) of a {@link java.util.Map} property - * are to be included during serialization or not. - * NOTE: this is NOT called for POJO properties, or array/Collection elements. - * - * @since 2.5 - * - * @deprecated Since 2.7 Use {@link #findPropertyInclusion} instead - */ - @Deprecated // since 2.7 - public JsonInclude.Include findSerializationInclusionForContent(Annotated a, JsonInclude.Include defValue) { - return defValue; - } - /* /********************************************************** /* Serialization: type refinements @@ -789,8 +698,6 @@ public JsonInclude.Include findSerializationInclusionForContent(Annotated a, Jso * Method called to find out possible type refinements to use * for deserialization, including not just value itself but * key and/or content type, if type has those. - * - * @since 2.7 */ public JavaType refineSerializationType(final MapperConfig config, final Annotated a, final JavaType baseType) throws JsonMappingException @@ -798,30 +705,6 @@ public JavaType refineSerializationType(final MapperConfig config, return baseType; } - /** - * @deprecated Since 2.7 call {@link #refineSerializationType} instead - */ - @Deprecated // since 2.7 - public Class findSerializationType(Annotated a) { - return null; - } - - /** - * @deprecated Since 2.7 call {@link #refineSerializationType} instead - */ - @Deprecated // since 2.7 - public Class findSerializationKeyType(Annotated am, JavaType baseType) { - return null; - } - - /** - * @deprecated Since 2.7 call {@link #refineSerializationType} instead - */ - @Deprecated // since 2.7 - public Class findSerializationContentType(Annotated am, JavaType baseType) { - return null; - } - /* /********************************************************** /* Serialization: class annotations @@ -888,16 +771,8 @@ public PropertyName findNameForSerialization(Annotated a) { * {@link Boolean#FALSE} if disabled annotation (block) is found (to indicate * accessor is definitely NOT to be used "as value"); or `null` if no * information found. - * - * @since 2.9 */ public Boolean hasAsValue(Annotated a) { - // 20-Nov-2016, tatu: Delegate in 2.9; remove redirect from later versions - if (a instanceof AnnotatedMethod) { - if (hasAsValueAnnotation((AnnotatedMethod) a)) { - return true; - } - } return null; } @@ -909,17 +784,8 @@ public Boolean hasAsValue(Annotated a) { * * @return True if such annotation is found (and is not disabled), * false otherwise - * - * @since 2.9 */ public Boolean hasAnyGetter(Annotated a) { - - // 21-Nov-2016, tatu: Delegate in 2.9; remove redirect from later versions - if (a instanceof AnnotatedMethod) { - if (hasAnyGetterAnnotation((AnnotatedMethod) a)) { - return true; - } - } return null; } @@ -927,15 +793,8 @@ public Boolean hasAnyGetter(Annotated a) { * Method for efficiently figuring out which if given set of Enum values * have explicitly defined name. Method will overwrite entries in incoming names * array with explicit names found, if any, leaving other entries unmodified. - *

- * Default implementation will simply delegate to {@link #findEnumValue}, which is close - * enough, although unfortunately NOT 100% equivalent (as it will also consider name() - * to give explicit value). - * - * @since 2.7 */ public String[] findEnumValues(Class enumType, Enum[] enumValues, String[] names) { - // 18-Oct-2016, tatu: In 2.8 delegated to deprecated method; not so in 2.9 and beyond return names; } @@ -944,46 +803,11 @@ public String[] findEnumValues(Class enumType, Enum[] enumValues, String[] * * @param enumCls The Enum class to scan for the default value. * @return null if none found or it's not possible to determine one. - * - * @since 2.8 */ public Enum findDefaultEnumValue(Class> enumCls) { return null; } - /** - * Method for determining the String value to use for serializing - * given enumeration entry; used when serializing enumerations - * as Strings (the standard method). - * - * @return Serialized enum value. - * - * @deprecated Since 2.8: use {@link #findEnumValues} instead because this method - * does not properly handle override settings (defaults to enum.name - * without indicating whether that is explicit or not), and is inefficient to - * call one-by-one. - */ - @Deprecated - public String findEnumValue(Enum value) { - return value.name(); - } - - /** - * @deprecated Since 2.9 Use {@link #hasAsValue(Annotated)} instead. - */ - @Deprecated // since 2.9 - public boolean hasAsValueAnnotation(AnnotatedMethod am) { - return false; - } - - /** - * @deprecated Since 2.9 Use {@link #hasAnyGetter} instead - */ - @Deprecated - public boolean hasAnyGetterAnnotation(AnnotatedMethod am) { - return false; - } - /* /********************************************************** /* Deserialization: general annotations @@ -1093,59 +917,6 @@ public JavaType refineDeserializationType(final MapperConfig config, return baseType; } - /** - * Method for accessing annotated type definition that a - * property can have, to be used as the type for deserialization - * instead of the static (declared) type. - * Type is usually narrowing conversion (i.e.subtype of declared type). - * Declared return type of the method is also considered acceptable. - * - * @param baseType Assumed type before considering annotations - * - * @return Class to use for deserialization instead of declared type - * - * @deprecated Since 2.7 call {@link #refineDeserializationType} instead - */ - @Deprecated - public Class findDeserializationType(Annotated am, JavaType baseType) { - return null; - } - - /** - * Method for accessing additional narrowing type definition that a - * method can have, to define more specific key type to use. - * It should be only be used with {@link java.util.Map} types. - * - * @param baseKeyType Assumed key type before considering annotations - * - * @return Class specifying more specific type to use instead of - * declared type, if annotation found; null if not - * - * @deprecated Since 2.7 call {@link #refineDeserializationType} instead - */ - @Deprecated - public Class findDeserializationKeyType(Annotated am, JavaType baseKeyType) { - return null; - } - - /** - * Method for accessing additional narrowing type definition that a - * method can have, to define more specific content type to use; - * content refers to Map values and Collection/array elements. - * It should be only be used with Map, Collection and array types. - * - * @param baseContentType Assumed content (value) type before considering annotations - * - * @return Class specifying more specific type to use instead of - * declared type, if annotation found; null if not - * - * @deprecated Since 2.7 call {@link #refineDeserializationType} instead - */ - @Deprecated - public Class findDeserializationContentType(Annotated am, JavaType baseContentType) { - return null; - } - /* /********************************************************** /* Deserialization: class annotations @@ -1171,16 +942,11 @@ public Object findValueInstantiator(AnnotatedClass ac) { * method does not allow returning instances: the reason is * that builders have state, and a separate instance needs * to be created for each deserialization call. - * - * @since 2.0 */ public Class findPOJOBuilder(AnnotatedClass ac) { return null; } - /** - * @since 2.0 - */ public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass ac) { return null; } @@ -1236,8 +1002,6 @@ public JsonSetter.Value findSetterInfo(Annotated a) { /** * Method for finding merge settings for property, if any. - * - * @since 2.9 */ public Boolean findMergeInfo(Annotated a) { return null; @@ -1255,61 +1019,11 @@ public Boolean findMergeInfo(Annotated a) { * * @param config Configuration settings in effect (for serialization or deserialization) * @param a Annotated accessor (usually constructor or static method) to check - * - * @since 2.9 */ public JsonCreator.Mode findCreatorAnnotation(MapperConfig config, Annotated a) { - // 13-Sep-2016, tatu: for backwards compatibility, implement using delegation - /// (remove from version AFTER 2.9) - if (hasCreatorAnnotation(a)) { - JsonCreator.Mode mode = findCreatorBinding(a); - if (mode == null) { - mode = JsonCreator.Mode.DEFAULT; - } - return mode; - } return null; } - /** - * Method for checking whether given annotated item (method, constructor) - * has an annotation - * that suggests that the method is a "creator" (aka factory) - * method to be used for construct new instances of deserialized - * values. - * - * @return True if such annotation is found (and is not disabled), - * false otherwise - * - * @deprecated Since 2.9 use {@link #findCreatorAnnotation} instead. - */ - @Deprecated - public boolean hasCreatorAnnotation(Annotated a) { - return false; - } - - /** - * Method for finding indication of creator binding mode for - * a creator (something for which {@link #hasCreatorAnnotation} returns - * true), for cases where there may be ambiguity (currently: single-argument - * creator with implicit but no explicit name for the argument). - * - * @since 2.5 - * @deprecated Since 2.9 use {@link #findCreatorAnnotation} instead. - */ - @Deprecated - public JsonCreator.Mode findCreatorBinding(Annotated a) { - return null; - } - - /** - * @deprecated Since 2.9 use {@link #hasAnySetter} instead. - */ - @Deprecated // since 2.9 - public boolean hasAnySetterAnnotation(AnnotatedMethod am) { - return false; - } - /* /********************************************************** /* Overridable methods: may be used as low-level extension @@ -1328,8 +1042,6 @@ public boolean hasAnySetterAnnotation(AnnotatedMethod am) { * * return annotated.getAnnotation(annoClass); * - * - * @since 2.5 */ protected A _findAnnotation(Annotated annotated, Class annoClass) { diff --git a/src/main/java/com/fasterxml/jackson/databind/JavaType.java b/src/main/java/com/fasterxml/jackson/databind/JavaType.java index ddd853cac4..db8ceb04fc 100644 --- a/src/main/java/com/fasterxml/jackson/databind/JavaType.java +++ b/src/main/java/com/fasterxml/jackson/databind/JavaType.java @@ -19,8 +19,8 @@ */ public abstract class JavaType extends ResolvedType - implements java.io.Serializable, // 2.1 - java.lang.reflect.Type // 2.2 + implements java.io.Serializable, + java.lang.reflect.Type { private static final long serialVersionUID = 1; @@ -196,26 +196,6 @@ public JavaType withHandlersFrom(JavaType src) { */ public abstract JavaType refine(Class rawType, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces); - - /** - * Legacy method used for forcing sub-typing of this type into - * type specified by specific type erasure. - * Deprecated as of 2.7 as such specializations really ought to - * go through {@link TypeFactory}, not directly via {@link JavaType}. - * - * @since 2.7 - */ - @Deprecated - public JavaType forcedNarrowBy(Class subclass) - { - if (subclass == _class) { // can still optimize for simple case - return this; - } - return _narrow(subclass); - } - - @Deprecated // since 2.7 - protected abstract JavaType _narrow(Class subclass); /* /********************************************************** @@ -238,23 +218,15 @@ public JavaType forcedNarrowBy(Class subclass) * Accessor that allows determining whether {@link #getContentType()} should * return a non-null value (that is, there is a "content type") or not. * True if {@link #isContainerType()} or {@link #isReferenceType()} return true. - * - * @since 2.8 */ public boolean hasContentType() { return true; } - /** - * @since 2.6 - */ public final boolean isTypeOrSubTypeOf(Class clz) { return (_class == clz) || clz.isAssignableFrom(_class); } - /** - * @since 2.9 - */ public final boolean isTypeOrSuperTypeOf(Class clz) { return (_class == clz) || _class.isAssignableFrom(clz); } diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationIntrospectorPair.java b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationIntrospectorPair.java index aa288b9e17..17d19c60ab 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationIntrospectorPair.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationIntrospectorPair.java @@ -164,37 +164,6 @@ public String findClassDescription(AnnotatedClass ac) { return str; } - @Override - @Deprecated // since 2.6 - public String[] findPropertiesToIgnore(Annotated ac) { - String[] result = _primary.findPropertiesToIgnore(ac); - if (result == null) { - result = _secondary.findPropertiesToIgnore(ac); - } - return result; - } - - @Override - @Deprecated // since 2.8 - public String[] findPropertiesToIgnore(Annotated ac, boolean forSerialization) { - String[] result = _primary.findPropertiesToIgnore(ac, forSerialization); - if (result == null) { - result = _secondary.findPropertiesToIgnore(ac, forSerialization); - } - return result; - } - - @Override - @Deprecated // since 2.8 - public Boolean findIgnoreUnknownProperties(AnnotatedClass ac) - { - Boolean result = _primary.findIgnoreUnknownProperties(ac); - if (result == null) { - result = _secondary.findIgnoreUnknownProperties(ac); - } - return result; - } - /* /****************************************************** /* Property auto-detection @@ -308,13 +277,6 @@ public Boolean hasRequiredMarker(AnnotatedMember m) { return (r == null) ? _secondary.hasRequiredMarker(m) : r; } - @Override - @Deprecated // since 2.9 - public Object findInjectableValueId(AnnotatedMember m) { - Object r = _primary.findInjectableValueId(m); - return (r == null) ? _secondary.findInjectableValueId(m) : r; - } - // // // Serialization: general annotations @Override @@ -356,27 +318,6 @@ public Object findNullSerializer(Annotated a) { return _explicitClassOrOb(_secondary.findNullSerializer(a), JsonSerializer.None.class); } - - @Deprecated - @Override - public JsonInclude.Include findSerializationInclusion(Annotated a, - JsonInclude.Include defValue) - { - // note: call secondary first, to give lower priority - defValue = _secondary.findSerializationInclusion(a, defValue); - defValue = _primary.findSerializationInclusion(a, defValue); - return defValue; - } - - @Deprecated - @Override - public JsonInclude.Include findSerializationInclusionForContent(Annotated a, JsonInclude.Include defValue) - { - // note: call secondary first, to give lower priority - defValue = _secondary.findSerializationInclusionForContent(a, defValue); - defValue = _primary.findSerializationInclusionForContent(a, defValue); - return defValue; - } @Override public JsonInclude.Value findPropertyInclusion(Annotated a) @@ -529,28 +470,7 @@ public JavaType refineSerializationType(MapperConfig config, JavaType t = _secondary.refineSerializationType(config, a, baseType); return _primary.refineSerializationType(config, a, t); } - - @Override - @Deprecated - public Class findSerializationType(Annotated a) { - Class r = _primary.findSerializationType(a); - return (r == null) ? _secondary.findSerializationType(a) : r; - } - - @Override - @Deprecated - public Class findSerializationKeyType(Annotated am, JavaType baseType) { - Class r = _primary.findSerializationKeyType(am, baseType); - return (r == null) ? _secondary.findSerializationKeyType(am, baseType) : r; - } - @Override - @Deprecated - public Class findSerializationContentType(Annotated am, JavaType baseType) { - Class r = _primary.findSerializationContentType(am, baseType); - return (r == null) ? _secondary.findSerializationContentType(am, baseType) : r; - } - // // // Serialization: class annotations @Override @@ -622,25 +542,6 @@ public Enum findDefaultEnumValue(Class> enumCls) { return (en == null) ? _secondary.findDefaultEnumValue(enumCls) : en; } - @Override - @Deprecated // since 2.8 - public String findEnumValue(Enum value) { - String r = _primary.findEnumValue(value); - return (r == null) ? _secondary.findEnumValue(value) : r; - } - - @Override - @Deprecated // since 2.9 - public boolean hasAsValueAnnotation(AnnotatedMethod am) { - return _primary.hasAsValueAnnotation(am) || _secondary.hasAsValueAnnotation(am); - } - - @Override - @Deprecated // since 2.9 - public boolean hasAnyGetterAnnotation(AnnotatedMethod am) { - return _primary.hasAnyGetterAnnotation(am) || _secondary.hasAnyGetterAnnotation(am); - } - // // // Deserialization: general annotations @Override @@ -696,28 +597,7 @@ public JavaType refineDeserializationType(MapperConfig config, JavaType t = _secondary.refineDeserializationType(config, a, baseType); return _primary.refineDeserializationType(config, a, t); } - - @Override - @Deprecated - public Class findDeserializationType(Annotated am, JavaType baseType) { - Class r = _primary.findDeserializationType(am, baseType); - return (r != null) ? r : _secondary.findDeserializationType(am, baseType); - } - - @Override - @Deprecated - public Class findDeserializationKeyType(Annotated am, JavaType baseKeyType) { - Class result = _primary.findDeserializationKeyType(am, baseKeyType); - return (result == null) ? _secondary.findDeserializationKeyType(am, baseKeyType) : result; - } - @Override - @Deprecated - public Class findDeserializationContentType(Annotated am, JavaType baseContentType) { - Class result = _primary.findDeserializationContentType(am, baseContentType); - return (result == null) ? _secondary.findDeserializationContentType(am, baseContentType) : result; - } - // // // Deserialization: class annotations @Override @@ -773,7 +653,7 @@ public JsonSetter.Value findSetterInfo(Annotated a) { ? v1 : v2.withOverrides(v1); } - @Override // since 2.9 + @Override public Boolean findMergeInfo(Annotated a) { Boolean b = _primary.findMergeInfo(a); if (b == null) { @@ -782,34 +662,12 @@ public Boolean findMergeInfo(Annotated a) { return b; } - @Override - @Deprecated // since 2.9 - public boolean hasCreatorAnnotation(Annotated a) { - return _primary.hasCreatorAnnotation(a) || _secondary.hasCreatorAnnotation(a); - } - - @Override - @Deprecated // since 2.9 - public JsonCreator.Mode findCreatorBinding(Annotated a) { - JsonCreator.Mode mode = _primary.findCreatorBinding(a); - if (mode != null) { - return mode; - } - return _secondary.findCreatorBinding(a); - } - @Override public JsonCreator.Mode findCreatorAnnotation(MapperConfig config, Annotated a) { JsonCreator.Mode mode = _primary.findCreatorAnnotation(config, a); return (mode == null) ? _secondary.findCreatorAnnotation(config, a) : mode; } - @Override - @Deprecated // since 2.9 - public boolean hasAnySetterAnnotation(AnnotatedMethod am) { - return _primary.hasAnySetterAnnotation(am) || _secondary.hasAnySetterAnnotation(am); - } - protected boolean _isExplicitClassOrOb(Object maybeCls, Class implicit) { if ((maybeCls == null) || (maybeCls == implicit)) { return false; @@ -820,7 +678,6 @@ protected boolean _isExplicitClassOrOb(Object maybeCls, Class implicit) { return true; } - // @since 2.9 protected Object _explicitClassOrOb(Object maybeCls, Class implicit) { if ((maybeCls == null) || (maybeCls == implicit)) { return null; diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java b/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java index 0eae64f232..cfdb068f57 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java @@ -170,37 +170,6 @@ public boolean isAnnotationBundle(Annotation ann) { /********************************************************** */ - /** - * Since 2.6, we have supported use of {@link JsonProperty} for specifying - * explicit serialized name - */ - @Override - @Deprecated // since 2.8 - public String findEnumValue(Enum value) - { - // 11-Jun-2015, tatu: As per [databind#677], need to allow explicit naming. - // Unfortunately cannot quite use standard AnnotatedClass here (due to various - // reasons, including odd representation JVM uses); has to do for now - try { - // We know that values are actually static fields with matching name so: - Field f = value.getClass().getField(value.name()); - if (f != null) { - JsonProperty prop = f.getAnnotation(JsonProperty.class); - if (prop != null) { - String n = prop.value(); - if (n != null && !n.isEmpty()) { - return n; - } - } - } - } catch (SecurityException e) { - // 17-Sep-2015, tatu: Anything we could/should do here? - } catch (NoSuchFieldException e) { - // 17-Sep-2015, tatu: should not really happen. But... can we do anything? - } - return value.name(); - } - @Override // since 2.7 public String[] findEnumValues(Class enumType, Enum[] enumValues, String[] names) { HashMap expl = null; @@ -467,13 +436,6 @@ public JacksonInject.Value findInjectableValue(AnnotatedMember m) { return v; } - @Override - @Deprecated // since 2.9 - public Object findInjectableValueId(AnnotatedMember m) { - JacksonInject.Value v = findInjectableValue(m); - return (v == null) ? null : v.getId(); - } - @Override public Class[] findViews(Annotated a) { @@ -481,7 +443,7 @@ public Class[] findViews(Annotated a) return (ann == null) ? null : ann.value(); } - @Override // since 2.7 + @Override public AnnotatedMethod resolveSetterConflict(MapperConfig config, AnnotatedMethod setter1, AnnotatedMethod setter2) { @@ -853,24 +815,6 @@ public JavaType refineSerializationType(final MapperConfig config, return type; } - @Override - @Deprecated // since 2.7 - public Class findSerializationType(Annotated am) { - return null; - } - - @Override - @Deprecated // since 2.7 - public Class findSerializationKeyType(Annotated am, JavaType baseType) { - return null; - } - - @Override - @Deprecated // since 2.7 - public Class findSerializationContentType(Annotated am, JavaType baseType) { - return null; - } - /* /********************************************************** /* Serialization: class annotations @@ -1029,21 +973,6 @@ public Boolean hasAnyGetter(Annotated a) { return ann.enabled(); } - @Override - @Deprecated // since 2.9 - public boolean hasAnyGetterAnnotation(AnnotatedMethod am) { - // No dedicated disabling; regular @JsonIgnore used if needs to be ignored (handled separately) - return _hasAnnotation(am, JsonAnyGetter.class); - } - - @Override - @Deprecated // since 2.9 - public boolean hasAsValueAnnotation(AnnotatedMethod am) { - JsonValue ann = _findAnnotation(am, JsonValue.class); - // value of 'false' means disabled... - return (ann != null) && ann.value(); - } - /* /********************************************************** /* Deserialization: general annotations @@ -1172,24 +1101,6 @@ public JavaType refineDeserializationType(final MapperConfig config, return type; } - @Override - @Deprecated // since 2.7 - public Class findDeserializationContentType(Annotated am, JavaType baseContentType) { - return null; - } - - @Override - @Deprecated // since 2.7 - public Class findDeserializationType(Annotated am, JavaType baseType) { - return null; - } - - @Override - @Deprecated // since 2.7 - public Class findDeserializationKeyType(Annotated am, JavaType baseKeyType) { - return null; - } - /* /********************************************************** /* Deserialization: Class annotations @@ -1260,45 +1171,6 @@ public Boolean findMergeInfo(Annotated a) { return (ann == null) ? null : ann.value().asBoolean(); } - @Override - @Deprecated // since 2.9 - public boolean hasAnySetterAnnotation(AnnotatedMethod am) { - return _hasAnnotation(am, JsonAnySetter.class); - } - - @Override - @Deprecated // since 2.9 - public boolean hasCreatorAnnotation(Annotated a) - { - /* No dedicated disabling; regular @JsonIgnore used if needs to be - * ignored (and if so, is handled prior to this method getting called) - */ - JsonCreator ann = _findAnnotation(a, JsonCreator.class); - if (ann != null) { - return (ann.mode() != JsonCreator.Mode.DISABLED); - } - // 19-Apr-2016, tatu: As per [databind#1197], [databind#1122] (and some related), - // may or may not consider it a creator - if (_cfgConstructorPropertiesImpliesCreator ) { - if (a instanceof AnnotatedConstructor) { - if (_java7Helper != null) { - Boolean b = _java7Helper.hasCreatorAnnotation(a); - if (b != null) { - return b.booleanValue(); - } - } - } - } - return false; - } - - @Override - @Deprecated // since 2.9 - public JsonCreator.Mode findCreatorBinding(Annotated a) { - JsonCreator ann = _findAnnotation(a, JsonCreator.class); - return (ann == null) ? null : ann.mode(); - } - @Override public JsonCreator.Mode findCreatorAnnotation(MapperConfig config, Annotated a) { JsonCreator ann = _findAnnotation(a, JsonCreator.class); @@ -1387,7 +1259,6 @@ protected PropertyName _findConstructorName(Annotated a) * Helper method called to construct and initialize instance of {@link TypeResolverBuilder} * if given annotated element indicates one is needed. */ - @SuppressWarnings("deprecation") protected TypeResolverBuilder _findTypeResolver(MapperConfig config, Annotated ann, JavaType baseType) { diff --git a/src/main/java/com/fasterxml/jackson/databind/type/ArrayType.java b/src/main/java/com/fasterxml/jackson/databind/type/ArrayType.java index ef3e6aafb5..db4b94b66a 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/ArrayType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/ArrayType.java @@ -106,16 +106,6 @@ public ArrayType withStaticTyping() { /********************************************************** */ - /** - * Handling of narrowing conversions for arrays is trickier: for now, - * it is not even allowed. - */ - @Override - @Deprecated // since 2.7 - protected JavaType _narrow(Class subclass) { - return _reportUnsupported(); - } - // Should not be called, as array types in Java are not extensible; but // let's not freak out even if it is called? @Override @@ -124,10 +114,6 @@ public JavaType refine(Class contentClass, TypeBindings bindings, return null; } - private JavaType _reportUnsupported() { - throw new UnsupportedOperationException("Cannot narrow or widen array types"); - } - /* /********************************************************** /* Overridden methods diff --git a/src/main/java/com/fasterxml/jackson/databind/type/CollectionLikeType.java b/src/main/java/com/fasterxml/jackson/databind/type/CollectionLikeType.java index 2bd9bbfaed..96243787b1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/CollectionLikeType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/CollectionLikeType.java @@ -89,14 +89,6 @@ public static CollectionLikeType upgradeFrom(JavaType baseType, JavaType element throw new IllegalArgumentException("Cannot upgrade from an instance of "+baseType.getClass()); } - @Override - @Deprecated // since 2.7 - protected JavaType _narrow(Class subclass) { - return new CollectionLikeType(subclass, _bindings, - _superClass, _superInterfaces, _elementType, - _valueHandler, _typeHandler, _asStatic); - } - @Override public JavaType withContentType(JavaType contentType) { if (_elementType == contentType) { diff --git a/src/main/java/com/fasterxml/jackson/databind/type/CollectionType.java b/src/main/java/com/fasterxml/jackson/databind/type/CollectionType.java index 7b38ab4908..c1f017f208 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/CollectionType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/CollectionType.java @@ -61,13 +61,6 @@ public static CollectionType construct(Class rawType, JavaType elemT) { null, null, false); } - @Deprecated // since 2.7 - @Override - protected JavaType _narrow(Class subclass) { - return new CollectionType(subclass, _bindings, - _superClass, _superInterfaces, _elementType, null, null, _asStatic); - } - @Override public JavaType withContentType(JavaType contentType) { if (_elementType == contentType) { diff --git a/src/main/java/com/fasterxml/jackson/databind/type/MapLikeType.java b/src/main/java/com/fasterxml/jackson/databind/type/MapLikeType.java index d62356b403..bbf2c746c1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/MapLikeType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/MapLikeType.java @@ -86,18 +86,6 @@ public static MapLikeType construct(Class rawType, JavaType keyT, null, keyT, valueT, null, null, false); } - @Deprecated - // since 2.7 - @Override - protected JavaType _narrow(Class subclass) { - return new MapLikeType(subclass, _bindings, _superClass, - _superInterfaces, _keyType, _valueType, _valueHandler, - _typeHandler, _asStatic); - } - - /** - * @since 2.7 - */ public MapLikeType withKeyType(JavaType keyType) { if (keyType == _keyType) { return this; diff --git a/src/main/java/com/fasterxml/jackson/databind/type/MapType.java b/src/main/java/com/fasterxml/jackson/databind/type/MapType.java index efaf238df2..1d8892c6a8 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/MapType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/MapType.java @@ -57,14 +57,6 @@ public static MapType construct(Class rawType, JavaType keyT, JavaType valueT keyT, valueT, null, null, false); } - @Deprecated // since 2.7 - @Override - protected JavaType _narrow(Class subclass) { - return new MapType(subclass, _bindings, - _superClass, _superInterfaces, _keyType, _valueType, - _valueHandler, _typeHandler, _asStatic); - } - @Override public MapType withTypeHandler(Object h) { return new MapType(_class, _bindings, diff --git a/src/main/java/com/fasterxml/jackson/databind/type/ReferenceType.java b/src/main/java/com/fasterxml/jackson/databind/type/ReferenceType.java index f9ed3f28d0..42de3b6e33 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/ReferenceType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/ReferenceType.java @@ -169,22 +169,6 @@ protected String buildCanonicalName() return sb.toString(); } - /* - /********************************************************** - /* Narrow/widen - /********************************************************** - */ - - @Override - @Deprecated // since 2.7 - protected JavaType _narrow(Class subclass) - { - // Should we check that there is a sub-class relationship? - return new ReferenceType(subclass, _bindings, - _superClass, _superInterfaces, _referencedType, _anchorType, - _valueHandler, _typeHandler, _asStatic); - } - /* /********************************************************** /* Public API overrides diff --git a/src/main/java/com/fasterxml/jackson/databind/type/ResolvedRecursiveType.java b/src/main/java/com/fasterxml/jackson/databind/type/ResolvedRecursiveType.java index d45e1d6fa6..ba79a3a0c4 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/ResolvedRecursiveType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/ResolvedRecursiveType.java @@ -76,12 +76,6 @@ public JavaType withStaticTyping() { return this; } - @Deprecated // since 2.7 - @Override - protected JavaType _narrow(Class subclass) { - return this; - } - @Override public JavaType refine(Class rawType, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) { diff --git a/src/main/java/com/fasterxml/jackson/databind/type/SimpleType.java b/src/main/java/com/fasterxml/jackson/databind/type/SimpleType.java index f1c8cdef34..096aeba690 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/SimpleType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/SimpleType.java @@ -118,54 +118,6 @@ public static SimpleType construct(Class cls) _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } - @Override - @Deprecated - protected JavaType _narrow(Class subclass) - { - if (_class == subclass) { - return this; - } - // Should we check that there is a sub-class relationship? - // 15-Jan-2016, tatu: Almost yes, but there are some complications with - // placeholder values (`Void`, `NoClass`), so cannot quite do yet. - // TODO: fix in 2.9 - if (!_class.isAssignableFrom(subclass)) { - /* - throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " - +_class.getName()); - */ - return new SimpleType(subclass, _bindings, this, _superInterfaces, - _valueHandler, _typeHandler, _asStatic); - } - // Otherwise, stitch together the hierarchy. First, super-class - Class next = subclass.getSuperclass(); - if (next == _class) { // straight up parent class? Great. - return new SimpleType(subclass, _bindings, this, - _superInterfaces, _valueHandler, _typeHandler, _asStatic); - } - if ((next != null) && _class.isAssignableFrom(next)) { - JavaType superb = _narrow(next); - return new SimpleType(subclass, _bindings, superb, - null, _valueHandler, _typeHandler, _asStatic); - } - // if not found, try a super-interface - Class[] nextI = subclass.getInterfaces(); - for (Class iface : nextI) { - if (iface == _class) { // directly implemented - return new SimpleType(subclass, _bindings, null, - new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic); - } - if (_class.isAssignableFrom(iface)) { // indirect, so recurse - JavaType superb = _narrow(iface); - return new SimpleType(subclass, _bindings, null, - new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic); - } - } - // should not get here but... - throw new IllegalArgumentException("Internal error: Cannot resolve sub-type for Class "+subclass.getName()+" to " - +_class.getName()); - } - @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; cannot call withContentType()"); diff --git a/src/main/java/com/fasterxml/jackson/databind/util/BeanUtil.java b/src/main/java/com/fasterxml/jackson/databind/util/BeanUtil.java index 54462ceb4a..7ebfe609c1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/util/BeanUtil.java +++ b/src/main/java/com/fasterxml/jackson/databind/util/BeanUtil.java @@ -20,9 +20,6 @@ public class BeanUtil /********************************************************** */ - /** - * @since 2.5 - */ public static String okNameForGetter(AnnotatedMethod am, boolean stdNaming) { String name = am.getName(); String str = okNameForIsGetter(am, name, stdNaming); @@ -31,10 +28,7 @@ public static String okNameForGetter(AnnotatedMethod am, boolean stdNaming) { } return str; } - - /** - * @since 2.5 - */ + public static String okNameForRegularGetter(AnnotatedMethod am, String name, boolean stdNaming) { @@ -80,25 +74,9 @@ public static String okNameForIsGetter(AnnotatedMethod am, String name, return null; } - /** - * @since 2.5 - */ - @Deprecated // since 2.9, not used any more - public static String okNameForSetter(AnnotatedMethod am, boolean stdNaming) { - String name = okNameForMutator(am, "set", stdNaming); - if ((name != null) - // 26-Nov-2009, tatu: need to suppress this internal groovy method - && (!"metaClass".equals(name) || !isGroovyMetaClassSetter(am))) { - return name; - } - return null; - } - - /** - * @since 2.5 - */ public static String okNameForMutator(AnnotatedMethod am, String prefix, - boolean stdNaming) { + boolean stdNaming) + { String name = am.getName(); if (name.startsWith(prefix)) { return stdNaming @@ -124,8 +102,6 @@ public static String okNameForMutator(AnnotatedMethod am, String prefix, * and for structured (Maps, Collections, arrays) and reference types, criteria * {@link com.fasterxml.jackson.annotation.JsonInclude.Include#NON_DEFAULT} * is used. - * - * @since 2.7 */ public static Object getDefaultValue(JavaType type) { diff --git a/src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java b/src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java index 80c1151b83..fb48dcd147 100644 --- a/src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java +++ b/src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java @@ -18,10 +18,6 @@ * ones; but not significantly less efficient for larger), highly efficient * for linear iteration and appending. Implemented as segmented/chunked * linked list of tokens; only modifications are via appends. - *

- * Note that before version 2.0, this class was located in the "core" - * bundle, not data-binding; but since it was only used by data binding, - * was moved here to reduce size of core package */ public class TokenBuffer /* Won't use JsonGeneratorBase, to minimize overhead for validity @@ -63,26 +59,15 @@ public class TokenBuffer protected boolean _closed; - /** - * @since 2.3 - */ protected boolean _hasNativeTypeIds; - /** - * @since 2.3 - */ protected boolean _hasNativeObjectIds; - /** - * @since 2.3 - */ protected boolean _mayHaveNativeIds; /** * Flag set during construction, if use of {@link BigDecimal} is to be forced * on all floating-point values. - * - * @since 2.7 */ protected boolean _forceBigDecimal; @@ -160,9 +145,6 @@ public TokenBuffer(ObjectCodec codec, boolean hasNativeIds) _mayHaveNativeIds = _hasNativeTypeIds | _hasNativeObjectIds; } - /** - * @since 2.3 - */ public TokenBuffer(JsonParser p) { this(p, null); } @@ -193,8 +175,6 @@ public TokenBuffer(JsonParser p, DeserializationContext ctxt) * b.copyCurrentStructure(p); * return b; * - * - * @since 2.9 */ public static TokenBuffer asCopyOfValue(JsonParser p) throws IOException { TokenBuffer b = new TokenBuffer(p); @@ -207,17 +187,12 @@ public static TokenBuffer asCopyOfValue(JsonParser p) throws IOException { * with contents of this buffer. Usually context is assigned at construction, * based on given parser; but it is not always available, and may not contain * intended context. - * - * @since 2.9 */ public TokenBuffer overrideParentContext(JsonStreamContext ctxt) { _parentContext = ctxt; return this; } - /** - * @since 2.7 - */ public TokenBuffer forceUseOfBigDecimal(boolean b) { _forceBigDecimal = b; return this; @@ -249,8 +224,6 @@ public JsonParser asParser() { * p.nextToken(); * return p; * - * - * @since 2.9 */ public JsonParser asParserOnFirstToken() throws IOException { JsonParser p = asParser(_objectCodec); @@ -472,8 +445,6 @@ public void serialize(JsonGenerator gen) throws IOException /** * Helper method used by standard deserializer. - * - * @since 2.3 */ public TokenBuffer deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { @@ -689,7 +660,7 @@ public final void writeStartObject() throws IOException _writeContext = _writeContext.createChildObjectContext(); } - @Override // since 2.8 + @Override public void writeStartObject(Object forValue) throws IOException { _writeContext.writeValue(); @@ -983,7 +954,7 @@ public void writeObjectId(Object id) { _hasNativeId = true; } - @Override // since 2.8 + @Override public void writeEmbeddedObject(Object object) throws IOException { _appendValue(JsonToken.VALUE_EMBEDDED_OBJECT, object); } @@ -1158,8 +1129,6 @@ protected final void _append(JsonToken type, Object value) /** * Similar to {@link #_append(JsonToken)} but also updates context with * knowledge that a scalar value was written - * - * @since 2.6.4 */ protected final void _appendValue(JsonToken type) { @@ -1178,8 +1147,6 @@ protected final void _appendValue(JsonToken type) /** * Similar to {@link #_append(JsonToken,Object)} but also updates context with * knowledge that a scalar value was written - * - * @since 2.6.4 */ protected final void _appendValue(JsonToken type, Object value) { @@ -1195,22 +1162,6 @@ protected final void _appendValue(JsonToken type, Object value) } } - // 21-Oct-2016, tatu: Does not seem to be used or needed - /* - protected final void _appendRaw(int rawType, Object value) - { - Segment next = _hasNativeId - ? _last.appendRaw(_appendAt, rawType, value, _objectId, _typeId) - : _last.appendRaw(_appendAt, rawType, value); - if (next == null) { - ++_appendAt; - } else { - _last = next; - _appendAt = 1; - } - } - */ - @Override protected void _reportUnsupportedOperation() { throw new UnsupportedOperationException("Called operation not supported for TokenBuffer"); @@ -1233,14 +1184,8 @@ protected final static class Parser protected ObjectCodec _codec; - /** - * @since 2.3 - */ protected final boolean _hasNativeTypeIds; - /** - * @since 2.3 - */ protected final boolean _hasNativeObjectIds; protected final boolean _hasNativeIds; @@ -1279,13 +1224,6 @@ protected final static class Parser /********************************************************** */ - @Deprecated // since 2.9 - public Parser(Segment firstSeg, ObjectCodec codec, - boolean hasNativeTypeIds, boolean hasNativeObjectIds) - { - this(firstSeg, codec, hasNativeTypeIds, hasNativeObjectIds, null); - } - public Parser(Segment firstSeg, ObjectCodec codec, boolean hasNativeTypeIds, boolean hasNativeObjectIds, JsonStreamContext parentContext) @@ -1960,16 +1898,10 @@ private final void assignNativeIds(int index, Object objectId, Object typeId) } } - /** - * @since 2.3 - */ private Object findObjectId(int index) { return (_nativeIds == null) ? null : _nativeIds.get(_objectIdIndex(index)); } - - /** - * @since 2.3 - */ + private Object findTypeId(int index) { return (_nativeIds == null) ? null : _nativeIds.get(_typeIdIndex(index)); } diff --git a/src/test/java/com/fasterxml/jackson/databind/util/BeanUtilTest.java b/src/test/java/com/fasterxml/jackson/databind/util/BeanUtilTest.java index afd1732926..83ba5fbfac 100644 --- a/src/test/java/com/fasterxml/jackson/databind/util/BeanUtilTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/util/BeanUtilTest.java @@ -86,9 +86,9 @@ public void testOkNameForGetter() throws Exception public void testOkNameForSetter() throws Exception { - _testOkNameForSetter("setFoo", "foo"); - _testOkNameForSetter("notSetter", null); - _testOkNameForSetter("set", null); + _testOkNameForMutator("setFoo", "foo"); + _testOkNameForMutator("notSetter", null); + _testOkNameForMutator("set", null); } /* @@ -126,21 +126,20 @@ private void _testOkNameForGetter(String name, String expName, boolean useStd) t } } - private void _testOkNameForSetter(String name, String expName) throws Exception { - _testOkNameForSetter(name, expName, true); - _testOkNameForSetter(name, expName, false); + private void _testOkNameForMutator(String name, String expName) throws Exception { + _testOkNameForMutator(name, expName, true); + _testOkNameForMutator(name, expName, false); } - @SuppressWarnings("deprecation") - private void _testOkNameForSetter(String name, String expName, boolean useStd) throws Exception { + private void _testOkNameForMutator(String name, String expName, boolean useStd) throws Exception { AnnotatedMethod m = _method(Setters.class, name); if (expName == null) { - assertNull(BeanUtil.okNameForSetter(m, useStd)); + assertNull(BeanUtil.okNameForMutator(m, "set", useStd)); } else { - assertEquals(expName, BeanUtil.okNameForSetter(m, useStd)); + assertEquals(expName, BeanUtil.okNameForMutator(m, "set", useStd)); } } - + private AnnotatedMethod _method(Class cls, String name, Class...parameterTypes) throws Exception { return new AnnotatedMethod(null, cls.getMethod(name, parameterTypes), null, null); }