Skip to content

Commit

Permalink
Changes wrt databind/#3043 (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored Nov 29, 2024
1 parent 6852120 commit 9d75e3d
Show file tree
Hide file tree
Showing 30 changed files with 95 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import tools.jackson.databind.AnnotationIntrospector;
import tools.jackson.databind.JacksonModule;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.module.SimpleDeserializers;
import tools.jackson.databind.module.SimpleSerializers;
import tools.jackson.databind.ser.std.StdSerializer;
Expand Down Expand Up @@ -120,7 +120,7 @@ public SchemaSerializer() {
}

@Override
public void serialize(Schema value, JsonGenerator gen, SerializerProvider prov)
public void serialize(Schema value, JsonGenerator gen, SerializationContext prov)
throws JacksonException
{
// Let's simply write as String, for now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tools.jackson.databind.DatabindContext;
import tools.jackson.databind.DeserializationContext;
import tools.jackson.databind.JavaType;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.jsontype.NamedType;
import tools.jackson.databind.jsontype.PolymorphicTypeValidator;
import tools.jackson.databind.jsontype.TypeDeserializer;
Expand Down Expand Up @@ -38,7 +38,7 @@ public static AvroTypeResolverBuilder construct(JsonTypeInfo.Value config) {
}

@Override
public TypeSerializer buildTypeSerializer(SerializerProvider ctxt, JavaType baseType,
public TypeSerializer buildTypeSerializer(SerializationContext ctxt, JavaType baseType,
Collection<NamedType> subtypes) {
// All type information is encoded in the schema, never in the data.
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import tools.jackson.core.JsonParser;

import tools.jackson.databind.JavaType;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import tools.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor;
import tools.jackson.databind.ser.std.StdScalarSerializer;
Expand Down Expand Up @@ -54,7 +54,7 @@ protected AvroInstantSerializer(Class<T> t, Function<T, Instant> getInstant) {
}

@Override
public void serialize(T value, JsonGenerator gen, SerializerProvider provider) throws JacksonException {
public void serialize(T value, JsonGenerator gen, SerializationContext provider) throws JacksonException {
/**
* Number of milliseconds, independent of a particular time zone or calendar,
* from 1 January 1970 00:00:00.000 UTC.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tools.jackson.core.JsonParser;

import tools.jackson.databind.JavaType;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import tools.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor;
import tools.jackson.databind.ser.std.StdScalarSerializer;
Expand Down Expand Up @@ -36,7 +36,7 @@ protected AvroLocalDateSerializer() {
}

@Override
public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider provider) throws JacksonException {
public void serialize(LocalDate value, JsonGenerator gen, SerializationContext provider) throws JacksonException {
/**
* Number of days from the unix epoch, 1 January 1970.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import tools.jackson.core.JsonParser;

import tools.jackson.databind.JavaType;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import tools.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor;
import tools.jackson.databind.ser.std.StdScalarSerializer;
Expand Down Expand Up @@ -38,7 +38,7 @@ protected AvroLocalDateTimeSerializer() {
}

@Override
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider provider)
public void serialize(LocalDateTime value, JsonGenerator gen, SerializationContext provider)
throws JacksonException
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tools.jackson.core.JsonParser;

import tools.jackson.databind.JavaType;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import tools.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor;
import tools.jackson.databind.ser.std.StdScalarSerializer;
Expand Down Expand Up @@ -36,7 +36,7 @@ protected AvroLocalTimeSerializer() {
}

@Override
public void serialize(LocalTime value, JsonGenerator gen, SerializerProvider provider) throws JacksonException {
public void serialize(LocalTime value, JsonGenerator gen, SerializationContext provider) throws JacksonException {
/**
* Number of milliseconds, with no reference to a particular calendar, time zone or date, after
* midnight, 00:00:00.000.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.apache.avro.Schema.Type;

import tools.jackson.databind.JavaType;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatTypes;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitable;
Expand All @@ -23,7 +23,7 @@ public class ArrayVisitor

protected Schema _elementSchema;

public ArrayVisitor(SerializerProvider p, JavaType type, VisitorFormatWrapperImpl visitorWrapper)
public ArrayVisitor(SerializationContext p, JavaType type, VisitorFormatWrapperImpl visitorWrapper)
{
super(p);
_type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.apache.avro.Schema;

import tools.jackson.databind.JavaType;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;

/**
* Simple container for Schemas that have already been generated during
Expand All @@ -15,7 +15,7 @@ public class DefinedSchemas
{
protected final Map<JavaType, Schema> _schemas = new LinkedHashMap<>();

protected SerializerProvider _provider;
protected SerializationContext _serializationContext;

/*
/**********************************************************************
Expand All @@ -25,12 +25,12 @@ public class DefinedSchemas

public DefinedSchemas() { }

public void setProvider(SerializerProvider provider) {
_provider = provider;
public void setContext(SerializationContext ctxt) {
_serializationContext = ctxt;
}

public SerializerProvider getProvider() {
return _provider;
public SerializationContext getContext() {
return _serializationContext;
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
public class EnumVisitor extends JsonStringFormatVisitor.Base
implements SchemaBuilder
{
protected final SerializerProvider _provider;
protected final SerializationContext _provider;
protected final JavaType _type;
protected final DefinedSchemas _schemas;

protected Set<String> _enums;

public EnumVisitor(SerializerProvider provider, DefinedSchemas schemas, JavaType t) {
public EnumVisitor(SerializationContext provider, DefinedSchemas schemas, JavaType t) {
_schemas = schemas;
_type = t;
_provider = provider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.apache.avro.Schema;

import tools.jackson.databind.JavaType;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.introspect.AnnotatedClass;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitable;
import tools.jackson.databind.jsonFormatVisitors.JsonMapFormatVisitor;
Expand All @@ -19,7 +19,7 @@ public class MapVisitor extends JsonMapFormatVisitor.Base

protected JavaType _keyType;

public MapVisitor(SerializerProvider p, JavaType type, VisitorFormatWrapperImpl visitorWrapper)
public MapVisitor(SerializationContext p, JavaType type, VisitorFormatWrapperImpl visitorWrapper)
{
super(p);
_type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class RecordVisitor

protected List<Schema.Field> _fields = new ArrayList<>();

public RecordVisitor(SerializerProvider p, JavaType type, VisitorFormatWrapperImpl visitorWrapper)
public RecordVisitor(SerializationContext p, JavaType type, VisitorFormatWrapperImpl visitorWrapper)
{
super(p);
_type = type;
Expand All @@ -66,9 +66,9 @@ public RecordVisitor(SerializerProvider p, JavaType type, VisitorFormatWrapperIm
} else if (subTypes != null && !subTypes.isEmpty()) {
List<Schema> unionSchemas = new ArrayList<>();
for (NamedType subType : subTypes) {
ValueSerializer<?> ser = getProvider().findValueSerializer(subType.getType());
ValueSerializer<?> ser = getContext().findValueSerializer(subType.getType());
VisitorFormatWrapperImpl visitor = _visitorWrapper.createChildWrapper();
ser.acceptJsonFormatVisitor(visitor, getProvider().getTypeFactory().constructType(subType.getType()));
ser.acceptJsonFormatVisitor(visitor, getContext().getTypeFactory().constructType(subType.getType()));
unionSchemas.add(visitor.getAvroSchema());
}
_avroSchema = Schema.createUnion(unionSchemas);
Expand Down Expand Up @@ -173,10 +173,10 @@ protected Schema.Field schemaFieldForWriter(BeanProperty prop, boolean optional)
// 2-Mar-2017, bryan: AvroEncode annotation expects to have the schema used directly
optional = optional && !(ser instanceof CustomEncodingSerializer); // Don't modify schema
}
final SerializerProvider prov = getProvider();
final SerializationContext prov = getContext();
if (ser == null) {
if (prov == null) {
throw DatabindException.from(prov, "SerializerProvider missing for RecordVisitor");
throw DatabindException.from(prov, "SerializationContext missing for RecordVisitor");
}
ser = prov.findPrimaryPropertySerializer(prop.getType(), prop);
}
Expand Down Expand Up @@ -210,7 +210,7 @@ protected Schema.Field schemaFieldForWriter(BeanProperty prop, boolean optional)
if (meta != null) {
field.addProp(meta.key(), meta.value());
}
List<PropertyName> aliases = prop.findAliases(getProvider().getConfig());
List<PropertyName> aliases = prop.findAliases(getContext().getConfig());
if (!aliases.isEmpty()) {
for (PropertyName pn : aliases) {
field.addAlias(pn.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
import tools.jackson.core.JsonParser.NumberType;

import tools.jackson.databind.JavaType;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.introspect.AnnotatedClass;
import tools.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor;
import tools.jackson.databind.jsonFormatVisitors.JsonValueFormat;

public class StringVisitor extends JsonStringFormatVisitor.Base
implements SchemaBuilder
{
protected final SerializerProvider _provider;
protected final SerializationContext _provider;
protected final JavaType _type;

public StringVisitor(SerializerProvider provider, JavaType type) {
public StringVisitor(SerializationContext provider, JavaType type) {
_type = type;
_provider = provider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

import org.apache.avro.Schema;

import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWithSerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWithSerializationContext;

public abstract class VisitorBase
implements JsonFormatVisitorWithSerializerProvider,
implements JsonFormatVisitorWithSerializationContext,
SchemaBuilder
{
protected SerializerProvider _provider;
protected SerializationContext _provider;

@Override
public abstract Schema builtAvroSchema();

@Override
public SerializerProvider getProvider() {
public SerializationContext getContext() {
return _provider;
}

@Override
public void setProvider(SerializerProvider provider) {
public void setContext(SerializationContext provider) {
_provider = provider;
}
}
Loading

0 comments on commit 9d75e3d

Please sign in to comment.