From c59045b352bd98ba038a95ddefa2d1a8cf14b3df Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 8 Feb 2021 10:31:09 -0800 Subject: [PATCH] Fix #3046 (JsonSerializable -> JacksonSerializable) --- release-notes/VERSION | 1 + ...alizable.java => JacksonSerializable.java} | 12 ++++++---- .../fasterxml/jackson/databind/JsonNode.java | 2 +- .../jackson/databind/node/ArrayNode.java | 4 ++-- .../jackson/databind/node/BaseJsonNode.java | 6 ++--- .../jackson/databind/node/ObjectNode.java | 4 ++-- .../jackson/databind/node/POJONode.java | 6 ++--- .../databind/ser/BasicSerializerFactory.java | 12 +++++----- .../databind/ser/BeanSerializerFactory.java | 4 ++-- ...ava => JacksonSerializableSerializer.java} | 24 ++++++++++--------- .../ser/jackson/TokenBufferSerializer.java | 2 +- .../jackson/databind/type/TypeBase.java | 4 ++-- .../jackson/databind/util/JSONPObject.java | 12 +++++----- .../databind/util/JSONWrappedObject.java | 4 ++-- .../jackson/databind/util/RawValue.java | 20 ++++++++-------- .../jackson/databind/util/TokenBuffer.java | 2 +- .../deser/jdk/ArrayDeserializationTest.java | 2 +- .../databind/node/TestConversions.java | 2 +- .../ser/jdk/EnumSerializationTest.java | 2 +- .../jackson/databind/util/RawValueTest.java | 4 ++-- 20 files changed, 67 insertions(+), 62 deletions(-) rename src/main/java/com/fasterxml/jackson/databind/{JsonSerializable.java => JacksonSerializable.java} (89%) rename src/main/java/com/fasterxml/jackson/databind/ser/jackson/{JsonSerializableSerializer.java => JacksonSerializableSerializer.java} (54%) diff --git a/release-notes/VERSION b/release-notes/VERSION index 6570e1da3b..5ce3674a82 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -45,5 +45,6 @@ Versions: 3.x (for earlier see VERSION-2.x) #3028: Change `UUIDSerializer` to use `StreamWriteCapability` check instead of `JsonGenerator.canWriteBinaryNatively()` #3037: Rename `Module` as `JacksonModule` in 3.0 (to avoid overlap with `java.lang.Module`) +#3046: Rename `JsonSerializable` as `JacksonSerializable` in 3.0 - Remove `MappingJsonFactory` - Add context parameter for `TypeSerializer` contextualization (`forProperty()`) diff --git a/src/main/java/com/fasterxml/jackson/databind/JsonSerializable.java b/src/main/java/com/fasterxml/jackson/databind/JacksonSerializable.java similarity index 89% rename from src/main/java/com/fasterxml/jackson/databind/JsonSerializable.java rename to src/main/java/com/fasterxml/jackson/databind/JacksonSerializable.java index d0988dcaa2..b772547934 100644 --- a/src/main/java/com/fasterxml/jackson/databind/JsonSerializable.java +++ b/src/main/java/com/fasterxml/jackson/databind/JacksonSerializable.java @@ -13,11 +13,13 @@ * so -- if class is a bean, it can be serialized without * implementing this interface. *

- * Note that while it is possible to just directly implement {@link JsonSerializable}, + * Note that while it is possible to just directly implement {@link JacksonSerializable}, * actual implementations are strongly recommended to instead extend - * {@link JsonSerializable.Base}. + * {@link JacksonSerializable.Base}. + *

+ * NOTE: in Jackson 2.x this type was named {@code JsonSerializable} */ -public interface JsonSerializable +public interface JacksonSerializable { /** * Serialization method called when no additional type information is @@ -47,9 +49,9 @@ public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, * Base class with minimal implementation, as well as couple of extension methods * that core Jackson databinding makes use of. * Use of this base class is strongly recommended over directly implementing - * {@link JsonSerializable}. + * {@link JacksonSerializable}. */ - public abstract static class Base implements JsonSerializable + public abstract static class Base implements JacksonSerializable { /** * Method that may be called on instance to determine if it is considered diff --git a/src/main/java/com/fasterxml/jackson/databind/JsonNode.java b/src/main/java/com/fasterxml/jackson/databind/JsonNode.java index 0182a7e0d6..17cabe1486 100644 --- a/src/main/java/com/fasterxml/jackson/databind/JsonNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/JsonNode.java @@ -36,7 +36,7 @@ * and {@link ObjectMapper#treeAsTokens(TreeNode)} */ public abstract class JsonNode - extends JsonSerializable.Base // i.e. implements JsonSerializable + extends JacksonSerializable.Base // i.e. implements JacksonSerializable implements TreeNode, Iterable { /* diff --git a/src/main/java/com/fasterxml/jackson/databind/node/ArrayNode.java b/src/main/java/com/fasterxml/jackson/databind/node/ArrayNode.java index 7df1e9fed8..07efe8b711 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/ArrayNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/ArrayNode.java @@ -63,7 +63,7 @@ public ArrayNode deepCopy() /* /********************************************************** - /* Overrides for JsonSerializable.Base + /* Overrides for JacksonSerializable.Base /********************************************************** */ @@ -169,7 +169,7 @@ public void serialize(JsonGenerator f, SerializerProvider provider) final int size = c.size(); f.writeStartArray(this, size); for (int i = 0; i < size; ++i) { // we'll typically have array list - // For now, assuming it's either BaseJsonNode, JsonSerializable + // For now, assuming it's either BaseJsonNode, JacksonSerializable JsonNode n = c.get(i); ((BaseJsonNode) n).serialize(f, provider); } diff --git a/src/main/java/com/fasterxml/jackson/databind/node/BaseJsonNode.java b/src/main/java/com/fasterxml/jackson/databind/node/BaseJsonNode.java index 5af28671bd..871a7b9034 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/BaseJsonNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/BaseJsonNode.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.JsonSerializable; +import com.fasterxml.jackson.databind.JacksonSerializable; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @@ -11,7 +11,7 @@ * Abstract base class common to all standard {@link JsonNode} * implementations. * The main addition here is that we declare that sub-classes must - * implement {@link JsonSerializable}. + * implement {@link JacksonSerializable}. * This simplifies object mapping aspects a bit, as no external serializers are needed. *

* Note that support for {@link java.io.Serializable} is added here and so all subtypes @@ -113,7 +113,7 @@ public JsonParser.NumberType numberType() { /* /********************************************************** - /* JsonSerializable + /* JacksonSerializable /********************************************************** */ diff --git a/src/main/java/com/fasterxml/jackson/databind/node/ObjectNode.java b/src/main/java/com/fasterxml/jackson/databind/node/ObjectNode.java index 205446c29b..9d6a3e331c 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/ObjectNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/ObjectNode.java @@ -57,7 +57,7 @@ public ObjectNode deepCopy() /* /********************************************************** - /* Overrides for JsonSerializable.Base + /* Overrides for JacksonSerializable.Base /********************************************************** */ @@ -307,7 +307,7 @@ public void serialize(JsonGenerator g, SerializerProvider provider) for (Map.Entry en : _children.entrySet()) { /* 17-Feb-2009, tatu: Can we trust that all nodes will always * extend BaseJsonNode? Or if not, at least implement - * JsonSerializable? Let's start with former, change if + * JacksonSerializable? Let's start with former, change if * we must. */ BaseJsonNode value = (BaseJsonNode) en.getValue(); diff --git a/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java b/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java index c9a4968ee4..1cd376c9fb 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.*; -import com.fasterxml.jackson.databind.JsonSerializable; +import com.fasterxml.jackson.databind.JacksonSerializable; import com.fasterxml.jackson.databind.SerializerProvider; /** @@ -109,8 +109,8 @@ public final void serialize(JsonGenerator gen, SerializerProvider ctxt) throws J { if (_value == null) { ctxt.defaultSerializeNullValue(gen); - } else if (_value instanceof JsonSerializable) { - ((JsonSerializable) _value).serialize(gen, ctxt); + } else if (_value instanceof JacksonSerializable) { + ((JacksonSerializable) _value).serialize(gen, ctxt); } else { // 25-May-2018, tatu: [databind#1991] do not call via generator but through context; // this to preserve contextual information diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/BasicSerializerFactory.java b/src/main/java/com/fasterxml/jackson/databind/ser/BasicSerializerFactory.java index 9b59a2bad8..ad7daf39f4 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/BasicSerializerFactory.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/BasicSerializerFactory.java @@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.introspect.*; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.jackson.JsonValueSerializer; -import com.fasterxml.jackson.databind.ser.jackson.JsonSerializableSerializer; +import com.fasterxml.jackson.databind.ser.jackson.JacksonSerializableSerializer; import com.fasterxml.jackson.databind.ser.jdk.*; import com.fasterxml.jackson.databind.ser.std.*; import com.fasterxml.jackson.databind.type.*; @@ -296,12 +296,12 @@ protected final JsonSerializer findSerializerByLookup(JavaType type, /** * Method called to see if one of primary per-class annotations - * (or related, like implementing of {@link JsonSerializable}) + * (or related, like implementing of {@link JacksonSerializable}) * determines the serializer to use. *

* Currently handles things like: *