From 2369fd2904fc929f92f621f336ef761d5d667e2a Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 29 Nov 2024 21:16:32 +0100 Subject: [PATCH] SerializationContext --- .../module/scala/ser/EnumSerializerModule.scala | 4 ++-- .../jackson/module/scala/ser/EitherSerializer.scala | 12 ++++++------ .../scala/ser/EnumerationSerializerModule.scala | 6 +++--- .../module/scala/ser/IterableSerializerModule.scala | 6 +++--- .../module/scala/ser/IteratorSerializerModule.scala | 6 +++--- .../module/scala/ser/OptionSerializerModule.scala | 8 ++++---- .../module/scala/ser/ScalaIterableSerializer.scala | 8 ++++---- .../module/scala/ser/ScalaIteratorSerializer.scala | 8 ++++---- .../module/scala/ser/SymbolSerializerModule.scala | 2 +- .../module/scala/ser/TupleSerializerModule.scala | 2 +- .../jackson/module/scala/ser/SerializableMap.scala | 6 +++--- .../jackson/module/scala/ser/SerializableMap.scala | 6 +++--- .../jackson/module/scala/ser/SerializableMap.scala | 6 +++--- .../jackson/module/scala/ser/SerializableMap.scala | 6 +++--- .../introspect/ScalaAnnotationIntrospectorTest.scala | 10 +++++----- .../module/scala/ser/JacksonSerializableSpec.scala | 10 +++++----- .../jackson/module/scala/ser/MapSerializerTest.scala | 4 ++-- 17 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/main/scala-3/tools/jackson/module/scala/ser/EnumSerializerModule.scala b/src/main/scala-3/tools/jackson/module/scala/ser/EnumSerializerModule.scala index 31d32c171..21976d1d6 100644 --- a/src/main/scala-3/tools/jackson/module/scala/ser/EnumSerializerModule.scala +++ b/src/main/scala-3/tools/jackson/module/scala/ser/EnumSerializerModule.scala @@ -17,12 +17,12 @@ private object EnumSerializerShared { } private object EnumSerializer extends ValueSerializer[Enum] { - def serialize(value: Enum, jgen: JsonGenerator, provider: SerializerProvider): Unit = + def serialize(value: Enum, jgen: JsonGenerator, provider: SerializationContext): Unit = jgen.writeString(value.toString) } private object EnumKeySerializer extends ValueSerializer[Enum] { - def serialize(value: Enum, jgen: JsonGenerator, provider: SerializerProvider): Unit = + def serialize(value: Enum, jgen: JsonGenerator, provider: SerializationContext): Unit = jgen.writeName(value.toString) } diff --git a/src/main/scala/tools/jackson/module/scala/ser/EitherSerializer.scala b/src/main/scala/tools/jackson/module/scala/ser/EitherSerializer.scala index a84b47e8f..ecefa9859 100644 --- a/src/main/scala/tools/jackson/module/scala/ser/EitherSerializer.scala +++ b/src/main/scala/tools/jackson/module/scala/ser/EitherSerializer.scala @@ -46,7 +46,7 @@ private class EitherSerializer(left: EitherDetails, else new EitherSerializer(newLeft, newRight, prop, contentIncl, dynamicSerializers) } - protected[this] def createContextualDetails(prov: SerializerProvider, + protected[this] def createContextualDetails(prov: SerializationContext, prop: BeanProperty, details: EitherDetails): EitherDetails = { val vts = details.valueTypeSerializer.optMap(_.forProperty(prov, prop)) @@ -76,7 +76,7 @@ private class EitherSerializer(left: EitherDetails, details.copy(valueTypeSerializer = vts, valueSerializer = serializerOption) } - override def createContextual(prov: SerializerProvider, prop: BeanProperty): ValueSerializer[_] = { + override def createContextual(prov: SerializationContext, prop: BeanProperty): ValueSerializer[_] = { val propOpt = Option(prop) val newLeft = createContextualDetails(prov, prop, left) @@ -95,11 +95,11 @@ private class EitherSerializer(left: EitherDetails, withResolved(propOpt, newLeft, newRight, newIncl) } - override def serialize(value: Either[AnyRef, AnyRef], jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(value: Either[AnyRef, AnyRef], jgen: JsonGenerator, provider: SerializationContext): Unit = { serialize(value, jgen, provider, None) } - def serialize(value: Either[AnyRef, AnyRef], jgen: JsonGenerator, provider: SerializerProvider, vts: Option[TypeSerializer]): Unit = { + def serialize(value: Either[AnyRef, AnyRef], jgen: JsonGenerator, provider: SerializationContext, vts: Option[TypeSerializer]): Unit = { val (field, content, details) = value match { case Left(c) => ("l", c, left) case Right(c) => ("r", c, right) @@ -118,7 +118,7 @@ private class EitherSerializer(left: EitherDetails, jgen.writeEndObject() } - override def serializeWithType(value: Either[AnyRef, AnyRef], jgen: JsonGenerator, provider: SerializerProvider, typeSer: TypeSerializer): Unit = { + override def serializeWithType(value: Either[AnyRef, AnyRef], jgen: JsonGenerator, provider: SerializationContext, typeSer: TypeSerializer): Unit = { if (value == null) { provider.defaultSerializeNullValue(jgen) } else { @@ -129,7 +129,7 @@ private class EitherSerializer(left: EitherDetails, } } - protected[this] def findCachedSerializer(prov: SerializerProvider, typ: Class[_]): ValueSerializer[AnyRef] = { + protected[this] def findCachedSerializer(prov: SerializationContext, typ: Class[_]): ValueSerializer[AnyRef] = { var ser = dynamicSerializers.serializerFor(typ).asInstanceOf[ValueSerializer[AnyRef]] if (ser == null) { ser = findSerializer(prov, typ, property) diff --git a/src/main/scala/tools/jackson/module/scala/ser/EnumerationSerializerModule.scala b/src/main/scala/tools/jackson/module/scala/ser/EnumerationSerializerModule.scala index 661819ba9..18a8ff0ae 100644 --- a/src/main/scala/tools/jackson/module/scala/ser/EnumerationSerializerModule.scala +++ b/src/main/scala/tools/jackson/module/scala/ser/EnumerationSerializerModule.scala @@ -12,7 +12,7 @@ import tools.jackson.module.scala.{JacksonModule, JsonScalaEnumeration, ScalaMod trait ContextualEnumerationSerializer { self: ValueSerializer[_] => - override def createContextual(serializerProvider: SerializerProvider, beanProperty: BeanProperty): ValueSerializer[_] = + override def createContextual(SerializationContext: SerializationContext, beanProperty: BeanProperty): ValueSerializer[_] = Option(beanProperty) .optMap(_.getAnnotation(classOf[JsonScalaEnumeration])) .map(_ => new AnnotatedEnumerationSerializer) @@ -24,7 +24,7 @@ trait ContextualEnumerationSerializer { * http://jira.codehaus.org/browse/JACKSON-211 */ private class EnumerationSerializer extends ValueSerializer[scala.Enumeration#Value] with ContextualEnumerationSerializer { - override def serialize(value: scala.Enumeration#Value, jgen: JsonGenerator, provider: SerializerProvider) = { + override def serialize(value: scala.Enumeration#Value, jgen: JsonGenerator, provider: SerializationContext) = { val parentEnum = value.asInstanceOf[AnyRef].getClass.getSuperclass.getDeclaredFields.find( f => f.getName == "$outer" ) .getOrElse(throw new RuntimeException("failed to find $outer field on Enumeration class")) val enumClass = parentEnum.get(value).getClass.getName stripSuffix "$" @@ -36,7 +36,7 @@ private class EnumerationSerializer extends ValueSerializer[scala.Enumeration#Va } private class AnnotatedEnumerationSerializer extends ValueSerializer[scala.Enumeration#Value] with ContextualEnumerationSerializer { - override def serialize(value: scala.Enumeration#Value, jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(value: scala.Enumeration#Value, jgen: JsonGenerator, provider: SerializationContext): Unit = { provider.writeValue(jgen, value.toString) } } diff --git a/src/main/scala/tools/jackson/module/scala/ser/IterableSerializerModule.scala b/src/main/scala/tools/jackson/module/scala/ser/IterableSerializerModule.scala index 03ff74bdb..76b8b0557 100644 --- a/src/main/scala/tools/jackson/module/scala/ser/IterableSerializerModule.scala +++ b/src/main/scala/tools/jackson/module/scala/ser/IterableSerializerModule.scala @@ -23,7 +23,7 @@ private trait IterableSerializer override def hasSingleElement(value: collection.Iterable[Any]): Boolean = value.size == 1 - override def serialize(value: collection.Iterable[Any], gen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(value: collection.Iterable[Any], gen: JsonGenerator, provider: SerializationContext): Unit = { if (provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED) && hasSingleElement(value)) { collectionSerializer.serializeContents(value, gen, provider) } else { @@ -33,7 +33,7 @@ private trait IterableSerializer } } - override def serializeContents(value: collection.Iterable[Any], gen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serializeContents(value: collection.Iterable[Any], gen: JsonGenerator, provider: SerializationContext): Unit = { serialize(value, gen, provider) } @@ -43,7 +43,7 @@ private trait IterableSerializer unwrapSingle: jl.Boolean): ResolvedIterableSerializer = new ResolvedIterableSerializer(this, property, vts, elementSerializer, unwrapSingle) - override def isEmpty(provider: SerializerProvider, value: collection.Iterable[Any]): Boolean = value.isEmpty + override def isEmpty(provider: SerializationContext, value: collection.Iterable[Any]): Boolean = value.isEmpty } private class ResolvedIterableSerializer( src: IterableSerializer, diff --git a/src/main/scala/tools/jackson/module/scala/ser/IteratorSerializerModule.scala b/src/main/scala/tools/jackson/module/scala/ser/IteratorSerializerModule.scala index 232fdba73..c54c694f3 100644 --- a/src/main/scala/tools/jackson/module/scala/ser/IteratorSerializerModule.scala +++ b/src/main/scala/tools/jackson/module/scala/ser/IteratorSerializerModule.scala @@ -23,7 +23,7 @@ private trait IteratorSerializer override def hasSingleElement(p1: collection.Iterator[Any]): Boolean = p1.size == 1 - override def serialize(value: collection.Iterator[Any], jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(value: collection.Iterator[Any], jgen: JsonGenerator, provider: SerializationContext): Unit = { if (provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED) && hasSingleElement(value)) { iteratorSerializer.serializeContents(value, jgen, provider) } else { @@ -33,7 +33,7 @@ private trait IteratorSerializer } } - override def serializeContents(value: collection.Iterator[Any], gen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serializeContents(value: collection.Iterator[Any], gen: JsonGenerator, provider: SerializationContext): Unit = { serialize(value, gen, provider) } @@ -41,7 +41,7 @@ private trait IteratorSerializer new ResolvedIteratorSerializer(this, property, vts, elementSerializer, unwrapSingle) - override def isEmpty(provider: SerializerProvider, value: collection.Iterator[Any]): Boolean = value.hasNext + override def isEmpty(provider: SerializationContext, value: collection.Iterator[Any]): Boolean = value.hasNext } private class ResolvedIteratorSerializer( src: IteratorSerializer, diff --git a/src/main/scala/tools/jackson/module/scala/ser/OptionSerializerModule.scala b/src/main/scala/tools/jackson/module/scala/ser/OptionSerializerModule.scala index a7d9e5c8b..51d0fe1f9 100644 --- a/src/main/scala/tools/jackson/module/scala/ser/OptionSerializerModule.scala +++ b/src/main/scala/tools/jackson/module/scala/ser/OptionSerializerModule.scala @@ -21,7 +21,7 @@ import scala.util.control.Breaks.{break, breakable} // This is still here because it is used in other places like EitherSerializer, it is no // longer used for the Option serializer object OptionSerializer { - def useStatic(provider: SerializerProvider, property: Option[BeanProperty], referredType: Option[JavaType]): Boolean = { + def useStatic(provider: SerializationContext, property: Option[BeanProperty], referredType: Option[JavaType]): Boolean = { if (referredType.isEmpty) false // First: no serializer for `Object.class`, must be dynamic else if (referredType.get.isJavaLangObject) false @@ -57,17 +57,17 @@ object OptionSerializer { } } - def findSerializer(provider: SerializerProvider, typ: Class[_], prop: Option[BeanProperty]): ValueSerializer[AnyRef] = { + def findSerializer(provider: SerializationContext, typ: Class[_], prop: Option[BeanProperty]): ValueSerializer[AnyRef] = { // Important: ask for TYPED serializer, in case polymorphic handling is needed! provider.findTypedValueSerializer(typ, true).asInstanceOf[ValueSerializer[AnyRef]] } - def findSerializer(provider: SerializerProvider, typ: JavaType, prop: Option[BeanProperty]): ValueSerializer[AnyRef] = { + def findSerializer(provider: SerializationContext, typ: JavaType, prop: Option[BeanProperty]): ValueSerializer[AnyRef] = { // Important: ask for TYPED serializer, in case polymorphic handling is needed! provider.findTypedValueSerializer(typ, true).asInstanceOf[ValueSerializer[AnyRef]] } - def hasContentTypeAnnotation(provider: SerializerProvider, property: BeanProperty): Boolean = { + def hasContentTypeAnnotation(provider: SerializationContext, property: BeanProperty): Boolean = { val intr = provider.getAnnotationIntrospector if (property == null || intr == null) { false diff --git a/src/main/scala/tools/jackson/module/scala/ser/ScalaIterableSerializer.scala b/src/main/scala/tools/jackson/module/scala/ser/ScalaIterableSerializer.scala index 2484ac1fe..f05b25f36 100644 --- a/src/main/scala/tools/jackson/module/scala/ser/ScalaIterableSerializer.scala +++ b/src/main/scala/tools/jackson/module/scala/ser/ScalaIterableSerializer.scala @@ -21,11 +21,11 @@ private case class ScalaIterableSerializer(elemType: JavaType, staticTyping: Boo this(src.elemType, src.staticTyping, vts, property, valueSerializer.asInstanceOf[ValueSerializer[Object]], unwrapSingle) } - override def isEmpty(prov: SerializerProvider, value: Iterable[Any]): Boolean = value.isEmpty + override def isEmpty(prov: SerializationContext, value: Iterable[Any]): Boolean = value.isEmpty override def hasSingleElement(value: Iterable[Any]): Boolean = value.size == 1 - override def serialize(value: Iterable[Any], g: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(value: Iterable[Any], g: JsonGenerator, provider: SerializationContext): Unit = { if (((_unwrapSingle == null && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || _unwrapSingle) && hasSingleElement(value)) { serializeContents(value, g, provider) @@ -36,7 +36,7 @@ private case class ScalaIterableSerializer(elemType: JavaType, staticTyping: Boo } } - override def serializeContents(value: Iterable[Any], g: JsonGenerator, provider: SerializerProvider): Unit = { + override def serializeContents(value: Iterable[Any], g: JsonGenerator, provider: SerializationContext): Unit = { g.assignCurrentValue(value) if (_elementSerializer != null) { serializeContentsUsing(value, g, provider, _elementSerializer) @@ -79,7 +79,7 @@ private case class ScalaIterableSerializer(elemType: JavaType, staticTyping: Boo new ScalaIterableSerializer(this, _property, vts, _elementSerializer, _unwrapSingle) } - private def serializeContentsUsing(value: Iterable[Any], g: JsonGenerator, provider: SerializerProvider, ser: ValueSerializer[AnyRef]): Unit = { + private def serializeContentsUsing(value: Iterable[Any], g: JsonGenerator, provider: SerializationContext, ser: ValueSerializer[AnyRef]): Unit = { val it = value.iterator if (it.hasNext) { val typeSer = _valueTypeSerializer diff --git a/src/main/scala/tools/jackson/module/scala/ser/ScalaIteratorSerializer.scala b/src/main/scala/tools/jackson/module/scala/ser/ScalaIteratorSerializer.scala index 5f29e3440..a08fc7a81 100644 --- a/src/main/scala/tools/jackson/module/scala/ser/ScalaIteratorSerializer.scala +++ b/src/main/scala/tools/jackson/module/scala/ser/ScalaIteratorSerializer.scala @@ -25,11 +25,11 @@ private case class ScalaIteratorSerializer(elemType: JavaType, staticTyping: Boo this(src.elemType, src.staticTyping, vts, property, valueSerializer.asInstanceOf[ValueSerializer[Object]], unwrapSingle) } - override def isEmpty(prov: SerializerProvider, value: Iterator[Any]): Boolean = value.isEmpty + override def isEmpty(prov: SerializationContext, value: Iterator[Any]): Boolean = value.isEmpty override def hasSingleElement(value: Iterator[Any]): Boolean = value.size == 1 - override def serialize(value: Iterator[Any], g: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(value: Iterator[Any], g: JsonGenerator, provider: SerializationContext): Unit = { //writeSingleElement is unsupported - also unsupported in tools.jackson.databind.ser.impl.IteratorSerializer //calculating the length of iterators can be expensive g.writeStartArray(value) @@ -37,7 +37,7 @@ private case class ScalaIteratorSerializer(elemType: JavaType, staticTyping: Boo g.writeEndArray() } - override def serializeContents(it: Iterator[Any], g: JsonGenerator, provider: SerializerProvider): Unit = { + override def serializeContents(it: Iterator[Any], g: JsonGenerator, provider: SerializationContext): Unit = { g.assignCurrentValue(it) if (_elementSerializer != null) { serializeContentsUsing(it, g, provider, _elementSerializer) @@ -79,7 +79,7 @@ private case class ScalaIteratorSerializer(elemType: JavaType, staticTyping: Boo new ScalaIteratorSerializer(this, _property, vts, _elementSerializer, _unwrapSingle) } - private def serializeContentsUsing(it: Iterator[Any], g: JsonGenerator, provider: SerializerProvider, ser: ValueSerializer[AnyRef]): Unit = { + private def serializeContentsUsing(it: Iterator[Any], g: JsonGenerator, provider: SerializationContext, ser: ValueSerializer[AnyRef]): Unit = { if (it.hasNext) { val typeSer = _valueTypeSerializer var i = 0 diff --git a/src/main/scala/tools/jackson/module/scala/ser/SymbolSerializerModule.scala b/src/main/scala/tools/jackson/module/scala/ser/SymbolSerializerModule.scala index 9f973cbc7..835d4a175 100644 --- a/src/main/scala/tools/jackson/module/scala/ser/SymbolSerializerModule.scala +++ b/src/main/scala/tools/jackson/module/scala/ser/SymbolSerializerModule.scala @@ -11,7 +11,7 @@ import tools.jackson.module.scala.{JacksonModule, ScalaModule} import scala.languageFeature.postfixOps private object SymbolSerializer extends ValueSerializer[Symbol] { - def serialize(value: Symbol, jgen: JsonGenerator, provider: SerializerProvider): Unit = + def serialize(value: Symbol, jgen: JsonGenerator, provider: SerializationContext): Unit = jgen.writeString(value.name) } diff --git a/src/main/scala/tools/jackson/module/scala/ser/TupleSerializerModule.scala b/src/main/scala/tools/jackson/module/scala/ser/TupleSerializerModule.scala index 7bc9fe1b0..798848617 100644 --- a/src/main/scala/tools/jackson/module/scala/ser/TupleSerializerModule.scala +++ b/src/main/scala/tools/jackson/module/scala/ser/TupleSerializerModule.scala @@ -12,7 +12,7 @@ import scala.languageFeature.postfixOps private class TupleSerializer extends ValueSerializer[Product] { - def serialize(value: Product, jgen: JsonGenerator, provider: SerializerProvider): Unit = { + def serialize(value: Product, jgen: JsonGenerator, provider: SerializationContext): Unit = { jgen.writeStartArray() value.productIterator.foreach(provider.writeValue(jgen, _)) jgen.writeEndArray() diff --git a/src/test/scala-2.11/tools/jackson/module/scala/ser/SerializableMap.scala b/src/test/scala-2.11/tools/jackson/module/scala/ser/SerializableMap.scala index c538c4361..618b1e0fe 100644 --- a/src/test/scala-2.11/tools/jackson/module/scala/ser/SerializableMap.scala +++ b/src/test/scala-2.11/tools/jackson/module/scala/ser/SerializableMap.scala @@ -1,7 +1,7 @@ package tools.jackson.module.scala.ser import tools.jackson.core.JsonGenerator -import tools.jackson.databind.{JacksonSerializable, SerializerProvider} +import tools.jackson.databind.{JacksonSerializable, SerializationContext} import tools.jackson.databind.jsontype.TypeSerializer import scala.collection.immutable.AbstractMap @@ -14,10 +14,10 @@ class SerializableMap extends AbstractMap[String, String] with JacksonSerializab def get(key: String): Option[String] = None def iterator: Iterator[(String, String)] = throw new IllegalArgumentException("This shouldn't get called") - override def serialize(jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(jgen: JsonGenerator, provider: SerializationContext): Unit = { jgen.writeNumber(10) } - override def serializeWithType(jgen: JsonGenerator, provider: SerializerProvider, typeSer: TypeSerializer): Unit = { + override def serializeWithType(jgen: JsonGenerator, provider: SerializationContext, typeSer: TypeSerializer): Unit = { serialize(jgen, provider) } } diff --git a/src/test/scala-2.12/tools/jackson/module/scala/ser/SerializableMap.scala b/src/test/scala-2.12/tools/jackson/module/scala/ser/SerializableMap.scala index c538c4361..618b1e0fe 100644 --- a/src/test/scala-2.12/tools/jackson/module/scala/ser/SerializableMap.scala +++ b/src/test/scala-2.12/tools/jackson/module/scala/ser/SerializableMap.scala @@ -1,7 +1,7 @@ package tools.jackson.module.scala.ser import tools.jackson.core.JsonGenerator -import tools.jackson.databind.{JacksonSerializable, SerializerProvider} +import tools.jackson.databind.{JacksonSerializable, SerializationContext} import tools.jackson.databind.jsontype.TypeSerializer import scala.collection.immutable.AbstractMap @@ -14,10 +14,10 @@ class SerializableMap extends AbstractMap[String, String] with JacksonSerializab def get(key: String): Option[String] = None def iterator: Iterator[(String, String)] = throw new IllegalArgumentException("This shouldn't get called") - override def serialize(jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(jgen: JsonGenerator, provider: SerializationContext): Unit = { jgen.writeNumber(10) } - override def serializeWithType(jgen: JsonGenerator, provider: SerializerProvider, typeSer: TypeSerializer): Unit = { + override def serializeWithType(jgen: JsonGenerator, provider: SerializationContext, typeSer: TypeSerializer): Unit = { serialize(jgen, provider) } } diff --git a/src/test/scala-2.13/tools/jackson/module/scala/ser/SerializableMap.scala b/src/test/scala-2.13/tools/jackson/module/scala/ser/SerializableMap.scala index ac7e808cf..b0b67a85a 100644 --- a/src/test/scala-2.13/tools/jackson/module/scala/ser/SerializableMap.scala +++ b/src/test/scala-2.13/tools/jackson/module/scala/ser/SerializableMap.scala @@ -2,7 +2,7 @@ package tools.jackson.module.scala.ser import tools.jackson.core.JsonGenerator import tools.jackson.databind.jsontype.TypeSerializer -import tools.jackson.databind.{JacksonSerializable, SerializerProvider} +import tools.jackson.databind.{JacksonSerializable, SerializationContext} import scala.collection.immutable.AbstractMap @@ -12,10 +12,10 @@ class SerializableMap extends AbstractMap[String, String] with JacksonSerializab def get(key: String): Option[String] = None def iterator: Iterator[(String, String)] = throw new IllegalArgumentException("This shouldn't get called") - override def serialize(jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(jgen: JsonGenerator, provider: SerializationContext): Unit = { jgen.writeNumber(10) } - override def serializeWithType(jgen: JsonGenerator, provider: SerializerProvider, typeSer: TypeSerializer): Unit = { + override def serializeWithType(jgen: JsonGenerator, provider: SerializationContext, typeSer: TypeSerializer): Unit = { serialize(jgen, provider) } diff --git a/src/test/scala-3/tools/jackson/module/scala/ser/SerializableMap.scala b/src/test/scala-3/tools/jackson/module/scala/ser/SerializableMap.scala index ac7e808cf..b0b67a85a 100644 --- a/src/test/scala-3/tools/jackson/module/scala/ser/SerializableMap.scala +++ b/src/test/scala-3/tools/jackson/module/scala/ser/SerializableMap.scala @@ -2,7 +2,7 @@ package tools.jackson.module.scala.ser import tools.jackson.core.JsonGenerator import tools.jackson.databind.jsontype.TypeSerializer -import tools.jackson.databind.{JacksonSerializable, SerializerProvider} +import tools.jackson.databind.{JacksonSerializable, SerializationContext} import scala.collection.immutable.AbstractMap @@ -12,10 +12,10 @@ class SerializableMap extends AbstractMap[String, String] with JacksonSerializab def get(key: String): Option[String] = None def iterator: Iterator[(String, String)] = throw new IllegalArgumentException("This shouldn't get called") - override def serialize(jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(jgen: JsonGenerator, provider: SerializationContext): Unit = { jgen.writeNumber(10) } - override def serializeWithType(jgen: JsonGenerator, provider: SerializerProvider, typeSer: TypeSerializer): Unit = { + override def serializeWithType(jgen: JsonGenerator, provider: SerializationContext, typeSer: TypeSerializer): Unit = { serialize(jgen, provider) } diff --git a/src/test/scala/tools/jackson/module/scala/introspect/ScalaAnnotationIntrospectorTest.scala b/src/test/scala/tools/jackson/module/scala/introspect/ScalaAnnotationIntrospectorTest.scala index f5537d499..38807c3b3 100644 --- a/src/test/scala/tools/jackson/module/scala/introspect/ScalaAnnotationIntrospectorTest.scala +++ b/src/test/scala/tools/jackson/module/scala/introspect/ScalaAnnotationIntrospectorTest.scala @@ -11,7 +11,7 @@ import tools.jackson.databind import tools.jackson.databind.json.JsonMapper import tools.jackson.databind.module.SimpleModule import tools.jackson.databind.util.LookupCache -import tools.jackson.databind.{BeanDescription, MapperFeature, ObjectMapper, SerializerProvider, ValueSerializer} +import tools.jackson.databind.{BeanDescription, MapperFeature, ObjectMapper, SerializationContext, ValueSerializer} import tools.jackson.module.scala.deser.OptionWithNumberDeserializerTest.OptionLong import tools.jackson.module.scala.deser.ValueHolder import tools.jackson.module.scala.{DefaultLookupCacheFactory, DefaultScalaModule, LookupCacheFactory} @@ -102,9 +102,9 @@ class ScalaAnnotationIntrospectorTest extends FixtureAnyFlatSpec with Matchers { .addModule(new SimpleModule() { addSerializer(new ValueSerializer[Token] { override val handledType: Class[Token] = classOf[Token] - override def serialize(value: Token, gen: JsonGenerator, serializers: SerializerProvider): Unit = + override def serialize(value: Token, gen: JsonGenerator, serializers: SerializationContext): Unit = gen.writeString("") - override def createContextual(prov: SerializerProvider, property: databind.BeanProperty): ValueSerializer[_] = { + override def createContextual(prov: SerializationContext, property: databind.BeanProperty): ValueSerializer[_] = { property.getAnnotation(classOf[JsonScalaTestAnnotation]) shouldNot be (null) this } @@ -135,9 +135,9 @@ class ScalaAnnotationIntrospectorTest extends FixtureAnyFlatSpec with Matchers { val builder = new JsonMapper.Builder(new JsonFactory).addModule(new SimpleModule() { addSerializer(new ValueSerializer[Token] { override val handledType: Class[Token] = classOf[Token] - override def serialize(value: Token, gen: JsonGenerator, serializers: SerializerProvider): Unit = + override def serialize(value: Token, gen: JsonGenerator, serializers: SerializationContext): Unit = gen.writeString("") - override def createContextual(prov: SerializerProvider, property: databind.BeanProperty): ValueSerializer[_] = { + override def createContextual(prov: SerializationContext, property: databind.BeanProperty): ValueSerializer[_] = { property.getAnnotation(classOf[JsonScalaTestAnnotation]) shouldNot be (null) this } diff --git a/src/test/scala/tools/jackson/module/scala/ser/JacksonSerializableSpec.scala b/src/test/scala/tools/jackson/module/scala/ser/JacksonSerializableSpec.scala index d7198c8e9..66be035b0 100644 --- a/src/test/scala/tools/jackson/module/scala/ser/JacksonSerializableSpec.scala +++ b/src/test/scala/tools/jackson/module/scala/ser/JacksonSerializableSpec.scala @@ -1,6 +1,6 @@ package tools.jackson.module.scala.ser -import tools.jackson.databind.{JacksonSerializable, SerializerProvider} +import tools.jackson.databind.{JacksonSerializable, SerializationContext} import tools.jackson.databind.jsontype.TypeSerializer import tools.jackson.core.JsonGenerator import tools.jackson.module.scala.BaseFixture @@ -8,19 +8,19 @@ import tools.jackson.module.scala.BaseFixture object JacksonSerializableSpec { class SerializableIterable extends JacksonSerializable.Base with Iterable[String] { override def iterator: Iterator[String] = throw new IllegalArgumentException("This shouldn't get called") - override def serialize(jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(jgen: JsonGenerator, provider: SerializationContext): Unit = { jgen.writeNumber(10) } - override def serializeWithType(jgen: JsonGenerator, provider: SerializerProvider, typeSer: TypeSerializer): Unit = { + override def serializeWithType(jgen: JsonGenerator, provider: SerializationContext, typeSer: TypeSerializer): Unit = { serialize(jgen, provider) } } class SerializableIterator extends JacksonSerializable.Base with Iterator[String] { - override def serialize(jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(jgen: JsonGenerator, provider: SerializationContext): Unit = { jgen.writeNumber(10) } - override def serializeWithType(jgen: JsonGenerator, provider: SerializerProvider, typeSer: TypeSerializer): Unit = { + override def serializeWithType(jgen: JsonGenerator, provider: SerializationContext, typeSer: TypeSerializer): Unit = { serialize(jgen, provider) } diff --git a/src/test/scala/tools/jackson/module/scala/ser/MapSerializerTest.scala b/src/test/scala/tools/jackson/module/scala/ser/MapSerializerTest.scala index 77a92e412..16fff7c62 100644 --- a/src/test/scala/tools/jackson/module/scala/ser/MapSerializerTest.scala +++ b/src/test/scala/tools/jackson/module/scala/ser/MapSerializerTest.scala @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.{JsonInclude, JsonProperty, JsonSubTypes import tools.jackson.core.JsonGenerator import tools.jackson.databind.annotation.JsonSerialize import tools.jackson.databind.json.JsonMapper -import tools.jackson.databind.{SerializerProvider, ValueSerializer} +import tools.jackson.databind.{SerializationContext, ValueSerializer} import tools.jackson.module.scala.{DefaultScalaModule, JacksonModule} import scala.annotation.meta.getter @@ -28,7 +28,7 @@ class NonEmptyMaps { } class TupleKeySerializer extends ValueSerializer[Product] { - override def serialize(value: Product, jgen: JsonGenerator, provider: SerializerProvider): Unit = { + override def serialize(value: Product, jgen: JsonGenerator, provider: SerializationContext): Unit = { val objectMapper = JsonMapper.builder().addModule(DefaultScalaModule).build() jgen.writeName(objectMapper.writeValueAsString(value)) }