Skip to content

Commit

Permalink
Merge pull request #259 from FasterXML/tatu/3.0-db-3043-serializer-pr…
Browse files Browse the repository at this point in the history
…ovider-to-serialization-context

Changes wrt databind/3043 (`SerializerProvider` -> `SerializationContext`)
  • Loading branch information
cowtowncoder authored Nov 29, 2024
2 parents 08bf9be + ef0ecc0 commit 6c26edf
Show file tree
Hide file tree
Showing 31 changed files with 226 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tools.jackson.core.JsonGenerator;
import tools.jackson.databind.ValueSerializer;
import tools.jackson.databind.PropertyName;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.ser.BeanPropertyWriter;

public final class BooleanFieldPropertyWriter
Expand Down Expand Up @@ -56,18 +56,18 @@ public BooleanFieldPropertyWriter withAccessor(BeanPropertyAccessor acc) {
*/

@Override
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsProperty(bean, g, prov);
fallbackWriter.serializeAsProperty(bean, g, ctxt);
return;
}
boolean value;
try {
value = _propertyAccessor.booleanField(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, false);
_handleProblem(bean, g, ctxt, t, false);
return;
}
if (!_suppressableSet || _suppressableBoolean != value) {
Expand All @@ -77,24 +77,24 @@ public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerPr
}

@Override
public final void serializeAsElement(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsElement(bean, g, prov);
fallbackWriter.serializeAsElement(bean, g, ctxt);
return;
}
boolean value;
try {
value = _propertyAccessor.booleanField(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, true);
_handleProblem(bean, g, ctxt, t, true);
return;
}
if (!_suppressableSet || _suppressableBoolean != value) {
g.writeBoolean(value);
} else { // important: MUST output a placeholder
serializeAsOmittedElement(bean, g, prov);
serializeAsOmittedElement(bean, g, ctxt);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tools.jackson.core.JsonGenerator;
import tools.jackson.databind.ValueSerializer;
import tools.jackson.databind.PropertyName;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.ser.BeanPropertyWriter;

public final class BooleanMethodPropertyWriter
Expand Down Expand Up @@ -56,18 +56,18 @@ public BooleanMethodPropertyWriter withAccessor(BeanPropertyAccessor acc) {
*/

@Override
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsProperty(bean, g, prov);
fallbackWriter.serializeAsProperty(bean, g, ctxt);
return;
}
boolean value;
try {
value = _propertyAccessor.booleanGetter(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, false);
_handleProblem(bean, g, ctxt, t, false);
return;
}
if (!_suppressableSet || _suppressableBoolean != value) {
Expand All @@ -77,24 +77,24 @@ public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerPr
}

@Override
public final void serializeAsElement(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsElement(bean, g, prov);
fallbackWriter.serializeAsElement(bean, g, ctxt);
return;
}
boolean value;
try {
value = _propertyAccessor.booleanGetter(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, true);
_handleProblem(bean, g, ctxt, t, true);
return;
}
if (!_suppressableSet || _suppressableBoolean != value) {
g.writeBoolean(value);
} else { // important: MUST output a placeholder
serializeAsOmittedElement(bean, g, prov);
serializeAsOmittedElement(bean, g, ctxt);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tools.jackson.core.JsonGenerator;
import tools.jackson.databind.ValueSerializer;
import tools.jackson.databind.PropertyName;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.ser.BeanPropertyWriter;

public final class IntFieldPropertyWriter
Expand Down Expand Up @@ -56,18 +56,18 @@ public IntFieldPropertyWriter withAccessor(BeanPropertyAccessor acc) {
*/

@Override
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsProperty(bean, g, prov);
fallbackWriter.serializeAsProperty(bean, g, ctxt);
return;
}
int value;
try {
value = _propertyAccessor.intField(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, false);
_handleProblem(bean, g, ctxt, t, false);
return;
}
if (!_suppressableSet || _suppressableInt != value) {
Expand All @@ -77,24 +77,24 @@ public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerPr
}

@Override
public final void serializeAsElement(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsElement(bean, g, prov);
fallbackWriter.serializeAsElement(bean, g, ctxt);
return;
}
int value;
try {
value = _propertyAccessor.intField(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, true);
_handleProblem(bean, g, ctxt, t, true);
return;
}
if (!_suppressableSet || (_suppressableInt != value)) {
g.writeNumber(value);
} else { // important: MUST output a placeholder
serializeAsOmittedElement(bean, g, prov);
serializeAsOmittedElement(bean, g, ctxt);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tools.jackson.core.JsonGenerator;
import tools.jackson.databind.ValueSerializer;
import tools.jackson.databind.PropertyName;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.ser.BeanPropertyWriter;

public final class IntMethodPropertyWriter
Expand Down Expand Up @@ -56,17 +56,17 @@ public IntMethodPropertyWriter withAccessor(BeanPropertyAccessor acc) {
*/

@Override
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerProvider prov) throws Exception
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt) throws Exception
{
if (broken) {
fallbackWriter.serializeAsProperty(bean, g, prov);
fallbackWriter.serializeAsProperty(bean, g, ctxt);
return;
}
int value;
try {
value = _propertyAccessor.intGetter(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, false);
_handleProblem(bean, g, ctxt, t, false);
return;
}
if (!_suppressableIntSet || _suppressableInt != value) {
Expand All @@ -76,23 +76,23 @@ public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerPr
}

@Override
public final void serializeAsElement(Object bean, JsonGenerator g, SerializerProvider prov) throws Exception
public final void serializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt) throws Exception
{
if (broken) {
fallbackWriter.serializeAsElement(bean, g, prov);
fallbackWriter.serializeAsElement(bean, g, ctxt);
return;
}
int value;
try {
value = _propertyAccessor.intGetter(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, true);
_handleProblem(bean, g, ctxt, t, true);
return;
}
if (!_suppressableIntSet || _suppressableInt != value) {
g.writeNumber(value);
} else { // important: MUST output a placeholder
serializeAsOmittedElement(bean, g, prov);
serializeAsOmittedElement(bean, g, ctxt);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tools.jackson.core.JsonGenerator;
import tools.jackson.databind.ValueSerializer;
import tools.jackson.databind.PropertyName;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.ser.BeanPropertyWriter;

public final class LongFieldPropertyWriter
Expand Down Expand Up @@ -56,18 +56,18 @@ public LongFieldPropertyWriter withAccessor(BeanPropertyAccessor acc) {
*/

@Override
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsProperty(bean, g, prov);
fallbackWriter.serializeAsProperty(bean, g, ctxt);
return;
}
long value;
try {
value = _propertyAccessor.longField(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, false);
_handleProblem(bean, g, ctxt, t, false);
return;
}
if (!_suppressableSet || _suppressableLong != value) {
Expand All @@ -77,24 +77,24 @@ public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerPr
}

@Override
public final void serializeAsElement(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsElement(bean, g, prov);
fallbackWriter.serializeAsElement(bean, g, ctxt);
return;
}
long value;
try {
value = _propertyAccessor.longField(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, false);
_handleProblem(bean, g, ctxt, t, false);
return;
}
if (!_suppressableSet || _suppressableLong != value) {
g.writeNumber(value);
} else { // important: MUST output a placeholder
serializeAsOmittedElement(bean, g, prov);
serializeAsOmittedElement(bean, g, ctxt);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tools.jackson.core.JsonGenerator;
import tools.jackson.databind.ValueSerializer;
import tools.jackson.databind.PropertyName;
import tools.jackson.databind.SerializerProvider;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.ser.BeanPropertyWriter;

public final class LongMethodPropertyWriter
Expand Down Expand Up @@ -56,18 +56,18 @@ public LongMethodPropertyWriter withAccessor(BeanPropertyAccessor acc) {
*/

@Override
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsProperty(bean, g, prov);
fallbackWriter.serializeAsProperty(bean, g, ctxt);
return;
}
long value;
try {
value = _propertyAccessor.longGetter(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, false);
_handleProblem(bean, g, ctxt, t, false);
return;
}
if (!_suppressableSet || _suppressableLong != value) {
Expand All @@ -77,24 +77,24 @@ public final void serializeAsProperty(Object bean, JsonGenerator g, SerializerPr
}

@Override
public final void serializeAsElement(Object bean, JsonGenerator g, SerializerProvider prov)
public final void serializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt)
throws Exception
{
if (broken) {
fallbackWriter.serializeAsElement(bean, g, prov);
fallbackWriter.serializeAsElement(bean, g, ctxt);
return;
}
long value;
try {
value = _propertyAccessor.longGetter(bean, _propertyIndex);
} catch (Throwable t) {
_handleProblem(bean, g, prov, t, true);
_handleProblem(bean, g, ctxt, t, true);
return;
}
if (!_suppressableSet || _suppressableLong != value) {
g.writeNumber(value);
} else { // important: MUST output a placeholder
serializeAsOmittedElement(bean, g, prov);
serializeAsOmittedElement(bean, g, ctxt);
}
}
}
Loading

0 comments on commit 6c26edf

Please sign in to comment.