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

Correction of minor warning(for databind.ser package) #4098

Merged
merged 4 commits into from
Aug 31, 2023
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 @@ -900,9 +900,7 @@ protected MapSerializer _checkMapContentInclusion(SerializerProvider prov,
break;
case CUSTOM: // new with 2.9
valueToSuppress = prov.includeFilterInstance(null, inclV.getContentFilter());
if (valueToSuppress == null) { // is this legal?
suppressNulls = true;
} else {
if (valueToSuppress != null) { // is this legal?
suppressNulls = prov.includeFilterSuppressNulls(valueToSuppress);
}
break;
Expand Down Expand Up @@ -967,9 +965,7 @@ protected JsonSerializer<?> buildMapEntrySerializer(SerializerProvider prov,
break;
case CUSTOM:
valueToSuppress = prov.includeFilterInstance(null, inclV.getContentFilter());
if (valueToSuppress == null) { // is this legal?
suppressNulls = true;
} else {
if (valueToSuppress != null) { // is this legal?
suppressNulls = prov.includeFilterSuppressNulls(valueToSuppress);
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ protected void removeIgnorableTypes(SerializationConfig config, BeanDescription
ignores.put(type, result);
}
// lotsa work, and yes, it is ignorable type, so:
if (result.booleanValue()) {
if (result) {
it.remove();
}
}
Expand All @@ -802,15 +802,9 @@ protected void removeIgnorableTypes(SerializationConfig config, BeanDescription
protected void removeSetterlessGetters(SerializationConfig config, BeanDescription beanDesc,
List<BeanPropertyDefinition> properties)
{
Iterator<BeanPropertyDefinition> it = properties.iterator();
while (it.hasNext()) {
BeanPropertyDefinition property = it.next();
// one caveat: only remove implicit properties;
// explicitly annotated ones should remain
if (!property.couldDeserialize() && !property.isExplicitlyIncluded()) {
it.remove();
}
}
// one caveat: only remove implicit properties;
// explicitly annotated ones should remain
properties.removeIf(property -> !property.couldDeserialize() && !property.isExplicitlyIncluded());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,6 @@ protected Impl(SerializerProvider src, SerializationConfig config,
@Override
public DefaultSerializerProvider copy()
{
if (getClass() != Impl.class) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually necessary -- will revert this change; super impl will throw exception and the intent is to fail if sub-classing provider impl but not overriding copy() method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhh. I see; Impl is final so it can never occur. Never mind. :)

return super.copy();
}
return new Impl(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,8 @@ public JsonSerializer<?> createContextual(SerializerProvider provider,
}
}

MapEntrySerializer mser = withResolved(property, keySer, ser,
valueToSuppress, suppressNulls);
// but note: no (full) filtering or sorting (unlike Maps)
return mser;
return withResolved(property, keySer, ser, valueToSuppress, suppressNulls);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,6 @@ protected final boolean _shouldUnwrapSingle(SerializerProvider provider) {
if (_unwrapSingle == null) {
return provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED);
}
return _unwrapSingle.booleanValue();
return _unwrapSingle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,9 @@ public JsonSerializer<?> createContextual(SerializerProvider provider,
}
// Or change Filter Id in use?
Object filterId = intr.findFilterId(accessor);
if (filterId != null) {
// but only consider case of adding a new filter id (no removal via annotation)
if (_propertyFilterId == null || !filterId.equals(_propertyFilterId)) {
newFilterId = filterId;
}
// but only consider case of adding a new filter id (no removal via annotation)
if (filterId != null && !filterId.equals(_propertyFilterId)) {
newFilterId = filterId;
}
}
// either way, need to resolve serializer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public abstract void serialize(T value, JsonGenerator gen, SerializerProvider se
protected boolean _asTimestamp(SerializerProvider serializers)
{
if (_useTimestamp != null) {
return _useTimestamp.booleanValue();
return _useTimestamp;
}
if (_customFormat == null) {
if (serializers != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t
protected final boolean _serializeAsIndex(SerializerProvider serializers)
{
if (_serializeAsIndex != null) {
return _serializeAsIndex.booleanValue();
return _serializeAsIndex;
}
return serializers.isEnabled(SerializationFeature.WRITE_ENUMS_USING_INDEX);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ public boolean hasSingleElement(Iterable<?> value) {
Iterator<?> it = value.iterator();
if (it.hasNext()) {
it.next();
if (!it.hasNext()) {
return true;
}
return !it.hasNext();
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public JsonSerializer<?> createContextual(SerializerProvider provider,
if (format != null) {
Boolean B = format.getFeature(JsonFormat.Feature.WRITE_SORTED_MAP_ENTRIES);
if (B != null) {
sortKeys = B.booleanValue();
sortKeys = B;
}
}
MapSerializer mser = withResolved(property, keySer, ser, ignored, included, sortKeys);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public ShortSerializer() {
@Override
public void serialize(Object value, JsonGenerator gen,
SerializerProvider provider) throws IOException {
gen.writeNumber(((Short) value).shortValue());
gen.writeNumber((Short) value);
}
}

Expand All @@ -154,7 +154,7 @@ public IntegerSerializer(Class<?> type) {
@Override
public void serialize(Object value, JsonGenerator gen,
SerializerProvider provider) throws IOException {
gen.writeNumber(((Integer) value).intValue());
gen.writeNumber((Integer) value);
}

// IMPORTANT: copied from `NonTypedScalarSerializerBase`
Expand Down Expand Up @@ -196,7 +196,7 @@ public LongSerializer(Class<?> cls) {
@Override
public void serialize(Object value, JsonGenerator gen,
SerializerProvider provider) throws IOException {
gen.writeNumber(((Long) value).longValue());
gen.writeNumber((Long) value);
}
}

Expand All @@ -211,7 +211,7 @@ public FloatSerializer() {
@Override
public void serialize(Object value, JsonGenerator gen,
SerializerProvider provider) throws IOException {
gen.writeNumber(((Float) value).floatValue());
gen.writeNumber((Float) value);
}
}

Expand All @@ -232,7 +232,7 @@ public DoubleSerializer(Class<?> cls) {
public void serialize(Object value, JsonGenerator gen,
SerializerProvider provider) throws IOException
{
gen.writeNumber(((Double) value).doubleValue());
gen.writeNumber((Double) value);
}

// IMPORTANT: copied from `NonTypedScalarSerializerBase`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public JsonNode getSchema(SerializerProvider provider, Type typeHint, boolean is
{
ObjectNode schema = (ObjectNode) getSchema(provider, typeHint);
if (!isOptional) {
schema.put("required", !isOptional);
schema.put("required", true);
}
return schema;
}
Expand All @@ -166,7 +166,7 @@ protected ObjectNode createSchemaNode(String type, boolean isOptional)
{
ObjectNode schema = createSchemaNode(type);
if (!isOptional) {
schema.put("required", !isOptional);
schema.put("required", true);
}
return schema;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ protected UUIDSerializer(Boolean asBinary) {
public boolean isEmpty(SerializerProvider prov, UUID value)
{
// Null UUID is empty, so...
if (value.getLeastSignificantBits() == 0L
&& value.getMostSignificantBits() == 0L) {
return true;
}
return false;
return value.getLeastSignificantBits() == 0L
&& value.getMostSignificantBits() == 0L;
}

@Override
Expand Down