From 580e6529b93baf9ef8a24637e97f18eca4afccc1 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 19 Apr 2016 19:22:04 -0700 Subject: minor cleanup --- .../fasterxml/jackson/databind/JsonSerializer.java | 6 ++---- .../jackson/databind/deser/DeserializerCache.java | 2 +- .../jackson/databind/introspect/Annotated.java | 4 ++-- .../databind/introspect/AnnotatedWithParams.java | 2 +- .../jackson/databind/jsontype/TypeIdResolver.java | 13 +++---------- .../databind/jsontype/impl/ClassNameIdResolver.java | 16 +++++----------- .../databind/jsontype/impl/TypeIdResolverBase.java | 19 ------------------- .../databind/jsontype/impl/TypeNameIdResolver.java | 21 +++++---------------- .../jackson/databind/ser/BeanPropertyWriter.java | 12 ++---------- 9 files changed, 21 insertions(+), 74 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/databind/JsonSerializer.java b/src/main/java/com/fasterxml/jackson/databind/JsonSerializer.java index 88e5f5032..c0041748e 100644 --- a/src/main/java/com/fasterxml/jackson/databind/JsonSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/JsonSerializer.java @@ -187,10 +187,8 @@ public abstract class JsonSerializer *

* Default implementation will consider only null values to be empty. * - * @since 2.0 - * * @deprecated Since 2.5 Use {@link #isEmpty(SerializerProvider, Object)} instead; - * will be removed from 2.8 + * will be removed from 2.9 */ @Deprecated public boolean isEmpty(T value) { @@ -204,7 +202,7 @@ public abstract class JsonSerializer *

* Default implementation will consider only null values to be empty. *

- * NOTE: replaces {@link #isEmpty(Object)}, deprecated in 2.5 + * NOTE: replaces {@link #isEmpty(Object)}, which was deprecated in 2.5 * * @since 2.5 */ 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 a4ab8d770..ec72a9608 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/DeserializerCache.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/DeserializerCache.java @@ -353,7 +353,7 @@ public final class DeserializerCache } // otherwise need to do bit of introspection JavaType delegateType = conv.getInputType(ctxt.getTypeFactory()); - // One more twist, as per [Issue#288]; probably need to get new BeanDesc + // One more twist, as per [databind#288]; probably need to get new BeanDesc if (!delegateType.hasRawClass(type.getRawClass())) { beanDesc = config.introspect(delegateType); } diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/Annotated.java b/src/main/java/com/fasterxml/jackson/databind/introspect/Annotated.java index 08eff1c39..ab6daa716 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/Annotated.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/Annotated.java @@ -63,7 +63,7 @@ public abstract class Annotated public abstract JavaType getType(); /** - * @deprecated Since 2.7 Use {@link #getType()} instead. To be removed from 2.8. + * @deprecated Since 2.7 Use {@link #getType()} instead. To be removed from 2.9 */ @Deprecated public final JavaType getType(TypeBindings bogus) { @@ -74,7 +74,7 @@ public abstract class Annotated * Full generic type of the annotated element; definition * of what exactly this means depends on sub-class. * - * @deprecated Since 2.7 should instead use {@link #getType()}. To be removed from 2.8 + * @deprecated Since 2.7 should instead use {@link #getType()}. To be removed from 2.9 */ @Deprecated public Type getGenericType() { diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedWithParams.java b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedWithParams.java index 8ab5141a7..4dfa440bc 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedWithParams.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedWithParams.java @@ -116,7 +116,7 @@ public abstract class AnnotatedWithParams public abstract JavaType getParameterType(int index); /** - * @deprecated Since 2.7, remove in 2.8 + * @deprecated Since 2.7, remove in 2.9 */ @Deprecated public final Type getGenericParameterType(int index) { diff --git a/src/main/java/com/fasterxml/jackson/databind/jsontype/TypeIdResolver.java b/src/main/java/com/fasterxml/jackson/databind/jsontype/TypeIdResolver.java index 5ea8386ac..e9d4c02d1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/jsontype/TypeIdResolver.java +++ b/src/main/java/com/fasterxml/jackson/databind/jsontype/TypeIdResolver.java @@ -42,7 +42,7 @@ public interface TypeIdResolver /* Conversions between types and type ids /********************************************************** */ - + /** * Method called to serialize type of the type of given value * as a String to include in serialized JSON content. @@ -65,17 +65,10 @@ public interface TypeIdResolver */ public String idFromBaseType(); - // !!! TODO: remove from 2.8 - /** - * @deprecated since 2.5; call {@link #typeFromId(DatabindContext, String)} instead - */ - @Deprecated // since 2.5 - public JavaType typeFromId(String id); - /** * Method called to resolve type from given type identifier. * - * @since 2.5 -- but since 2.3 has existed in {@link com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase} + * @since 2.5 */ public JavaType typeFromId(DatabindContext context, String id); @@ -85,7 +78,7 @@ public interface TypeIdResolver * @since 2.7 -- but since 2.5 has existed in {@link com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase} */ public String getDescForKnownTypeIds(); - + /* /********************************************************** /* Accessors for metadata diff --git a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/ClassNameIdResolver.java b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/ClassNameIdResolver.java index 94ff96332..536c6aa6c 100644 --- a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/ClassNameIdResolver.java +++ b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/ClassNameIdResolver.java @@ -29,18 +29,12 @@ public class ClassNameIdResolver @Override public String idFromValue(Object value) { - return _idFrom(value, value.getClass()); + return _idFrom(value, value.getClass(), _typeFactory); } @Override public String idFromValueAndType(Object value, Class type) { - return _idFrom(value, type); - } - - @Deprecated // since 2.3 - @Override - public JavaType typeFromId(String id) { - return _typeFromId(id, _typeFactory); + return _idFrom(value, type, _typeFactory); } @Override @@ -74,7 +68,7 @@ public class ClassNameIdResolver /********************************************************** */ - protected final String _idFrom(Object value, Class cls) + protected final String _idFrom(Object value, Class cls, TypeFactory typeFactory) { // Need to ensure that "enum subtypes" work too if (Enum.class.isAssignableFrom(cls)) { @@ -93,12 +87,12 @@ public class ClassNameIdResolver if (value instanceof EnumSet) { // Regular- and JumboEnumSet... Class enumClass = ClassUtil.findEnumType((EnumSet) value); // not optimal: but EnumSet is not a customizable type so this is sort of ok - str = _typeFactory.constructCollectionType(EnumSet.class, enumClass).toCanonical(); + str = typeFactory.constructCollectionType(EnumSet.class, enumClass).toCanonical(); } else if (value instanceof EnumMap) { Class enumClass = ClassUtil.findEnumType((EnumMap) value); Class valueClass = Object.class; // not optimal: but EnumMap is not a customizable type so this is sort of ok - str = _typeFactory.constructMapType(EnumMap.class, enumClass, valueClass).toCanonical(); + str = typeFactory.constructMapType(EnumMap.class, enumClass, valueClass).toCanonical(); } else { String end = str.substring(9); if ((end.startsWith(".Arrays$") || end.startsWith(".Collections$")) diff --git a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/TypeIdResolverBase.java b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/TypeIdResolverBase.java index 8532543dc..273b01366 100644 --- a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/TypeIdResolverBase.java +++ b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/TypeIdResolverBase.java @@ -51,25 +51,6 @@ public abstract class TypeIdResolverBase return idFromValueAndType(null, _baseType.getRawClass()); } - /** - * @deprecated Since 2.3, override {@link #typeFromId(DatabindContext, String)} instead - * to get access to contextual information - */ - @Deprecated - @Override - public JavaType typeFromId(String id) { - return typeFromId(null, id); - } - - /** - * New method, replacement for {@link #typeFromId(String)}, which is given - * context for accessing information, including configuration and - * {@link TypeFactory}. - * - * @return Type for given id - * - * @since 2.3 - */ @Override public JavaType typeFromId(DatabindContext context, String id) { // 22-Dec-2015, tatu: Must be overridden by sub-classes, so let's throw diff --git a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/TypeNameIdResolver.java b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/TypeNameIdResolver.java index 9025daff9..d607fbf07 100644 --- a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/TypeNameIdResolver.java +++ b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/TypeNameIdResolver.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.jsontype.NamedType; public class TypeNameIdResolver extends TypeIdResolverBase { protected final MapperConfig _config; - + /** * Mappings from class name to type id, used for serialization */ @@ -22,7 +22,7 @@ public class TypeNameIdResolver extends TypeIdResolverBase * Mappings from type id to JavaType, used for deserialization */ protected final Map _idToType; - + protected TypeNameIdResolver(MapperConfig config, JavaType baseType, Map typeToId, Map idToType) { @@ -79,8 +79,7 @@ public class TypeNameIdResolver extends TypeIdResolverBase public JsonTypeInfo.Id getMechanism() { return JsonTypeInfo.Id.NAME; } @Override - public String idFromValue(Object value) - { + public String idFromValue(Object value) { return idFromClass(value.getClass()); } @@ -123,12 +122,6 @@ public class TypeNameIdResolver extends TypeIdResolverBase return idFromValue(value); } - @Deprecated - @Override - public JavaType typeFromId(String id) { - return _typeFromId(id); - } - @Override public JavaType typeFromId(DatabindContext context, String id) { return _typeFromId(id); @@ -150,13 +143,9 @@ public class TypeNameIdResolver extends TypeIdResolverBase @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append('[').append(getClass().getName()); - sb.append("; id-to-type=").append(_idToType); - sb.append(']'); - return sb.toString(); + return String.format("[%s; id-to-type=%s]", getClass().getName(), _idToType); } - + /* /********************************************************* /* Helper methods diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java b/src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java index 3e28c4845..ac90b3112 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java @@ -599,15 +599,8 @@ public class BeanPropertyWriter extends PropertyWriter // which extends .getRawClass(); } - /* - * public JavaType getFullPropertyType() { if (_accessorMethod != null) { - * return _accessorMethod.getType() } if (_field != null) { return - * _field.getType(); } return null; } - */ - /** - * @deprecated Since 2.7, to be removed from 2.8, use {@link #getType()} - * instead. + * @deprecated Since 2.7, to be removed from 2.9, use {@link #getType()} instead. */ @Deprecated public Class getPropertyType() { @@ -625,8 +618,7 @@ public class BeanPropertyWriter extends PropertyWriter // which extends * * @return The property type, or null if not found. * - * @deprecated Since 2.7, to be removed from 2.8, use {@link #getType()} - * instead. + * @deprecated Since 2.7, to be removed from 2.9, use {@link #getType()} instead. */ @Deprecated public Type getGenericPropertyType() { -- cgit v1.2.3