Skip to content

Commit cf48303

Browse files
committed
Polishing.
Use ObjectUtils.isEmpty for emptiness check. See #1737 Original pull request: #1812
1 parent 0a1bb2b commit cf48303

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/MappingRelationalConverter.java

+15-27
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,16 @@
4444
import org.springframework.data.mapping.PersistentPropertyAccessor;
4545
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
4646
import org.springframework.data.mapping.context.MappingContext;
47-
import org.springframework.data.mapping.model.*;
47+
import org.springframework.data.mapping.model.CachingValueExpressionEvaluatorFactory;
48+
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
49+
import org.springframework.data.mapping.model.EntityInstantiator;
50+
import org.springframework.data.mapping.model.ParameterValueProvider;
51+
import org.springframework.data.mapping.model.PersistentEntityParameterValueProvider;
52+
import org.springframework.data.mapping.model.PropertyValueProvider;
53+
import org.springframework.data.mapping.model.SimpleTypeHolder;
54+
import org.springframework.data.mapping.model.SpELContext;
55+
import org.springframework.data.mapping.model.ValueExpressionEvaluator;
56+
import org.springframework.data.mapping.model.ValueExpressionParameterValueProvider;
4857
import org.springframework.data.projection.EntityProjection;
4958
import org.springframework.data.projection.EntityProjectionIntrospector;
5059
import org.springframework.data.projection.EntityProjectionIntrospector.ProjectionPredicate;
@@ -66,6 +75,7 @@
6675
import org.springframework.lang.Nullable;
6776
import org.springframework.util.Assert;
6877
import org.springframework.util.ClassUtils;
78+
import org.springframework.util.ObjectUtils;
6979

7080
/**
7181
* {@link org.springframework.data.relational.core.conversion.RelationalConverter} that uses a
@@ -1164,37 +1174,15 @@ public boolean hasValue(AggregatePath path) {
11641174
if (value == null) {
11651175
return false;
11661176
}
1177+
11671178
if (!path.isCollectionLike()) {
11681179
return true;
11691180
}
11701181

1171-
if (value instanceof char[] ar) {
1172-
return ar.length != 0;
1173-
}
1174-
if (value instanceof byte[] ar) {
1175-
return ar.length != 0;
1176-
}
1177-
if (value instanceof short[] ar) {
1178-
return ar.length != 0;
1179-
}
1180-
if (value instanceof int[] ar) {
1181-
return ar.length != 0;
1182-
}
1183-
if (value instanceof long[] ar) {
1184-
return ar.length != 0;
1185-
}
1186-
if (value instanceof float[] ar) {
1187-
return ar.length != 0;
1188-
}
1189-
if (value instanceof double[] ar) {
1190-
return ar.length != 0;
1191-
}
1192-
if (value instanceof Object[] ar) {
1193-
return ar.length != 0;
1194-
}
1195-
if (value instanceof Collection<?> col) {
1196-
return !col.isEmpty();
1182+
if (value instanceof Collection<?> || value.getClass().isArray()) {
1183+
return !ObjectUtils.isEmpty(value);
11971184
}
1185+
11981186
return true;
11991187
}
12001188

0 commit comments

Comments
 (0)