Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Use ObjectUtils.isEmpty for emptiness check.

See #1737
Original pull request: #1812
  • Loading branch information
mp911de committed Jun 11, 2024
1 parent fd66677 commit 5f425bd
Showing 1 changed file with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.*;
import org.springframework.data.mapping.model.CachingValueExpressionEvaluatorFactory;
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
import org.springframework.data.mapping.model.EntityInstantiator;
import org.springframework.data.mapping.model.ParameterValueProvider;
import org.springframework.data.mapping.model.PersistentEntityParameterValueProvider;
import org.springframework.data.mapping.model.PropertyValueProvider;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.data.mapping.model.SpELContext;
import org.springframework.data.mapping.model.ValueExpressionEvaluator;
import org.springframework.data.mapping.model.ValueExpressionParameterValueProvider;
import org.springframework.data.projection.EntityProjection;
import org.springframework.data.projection.EntityProjectionIntrospector;
import org.springframework.data.projection.EntityProjectionIntrospector.ProjectionPredicate;
Expand All @@ -66,6 +75,7 @@
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;

/**
* {@link org.springframework.data.relational.core.conversion.RelationalConverter} that uses a
Expand Down Expand Up @@ -1164,37 +1174,15 @@ public boolean hasValue(AggregatePath path) {
if (value == null) {
return false;
}

if (!path.isCollectionLike()) {
return true;
}

if (value instanceof char[] ar) {
return ar.length != 0;
}
if (value instanceof byte[] ar) {
return ar.length != 0;
}
if (value instanceof short[] ar) {
return ar.length != 0;
}
if (value instanceof int[] ar) {
return ar.length != 0;
}
if (value instanceof long[] ar) {
return ar.length != 0;
}
if (value instanceof float[] ar) {
return ar.length != 0;
}
if (value instanceof double[] ar) {
return ar.length != 0;
}
if (value instanceof Object[] ar) {
return ar.length != 0;
}
if (value instanceof Collection<?> col) {
return !col.isEmpty();
if (value instanceof Collection<?> || value.getClass().isArray()) {
return !ObjectUtils.isEmpty(value);
}

return true;
}

Expand Down

0 comments on commit 5f425bd

Please sign in to comment.