Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes wrt databind/3043 (SerializerProvider -> SerializationContext) #259

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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