Browse Source

Polishing.

Add nullability annotation. Return early on null value conversion.

See #3633
Original pull request: #3643.
3.1.x
Mark Paluch 5 years ago
parent
commit
5cf801ff8e
No known key found for this signature in database
GPG Key ID: 4406B84C1661DCD1
  1. 7
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java

7
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java

@ -378,6 +378,10 @@ public class QueryMapper {
} }
} }
if (value == null) {
return null;
}
if (isNestedKeyword(value)) { if (isNestedKeyword(value)) {
return getMappedKeyword(new Keyword((Bson) value), documentField.getPropertyEntity()); return getMappedKeyword(new Keyword((Bson) value), documentField.getPropertyEntity());
} }
@ -635,7 +639,7 @@ public class QueryMapper {
* @param candidate * @param candidate
* @return * @return
*/ */
protected boolean isNestedKeyword(Object candidate) { protected boolean isNestedKeyword(@Nullable Object candidate) {
if (!(candidate instanceof Document)) { if (!(candidate instanceof Document)) {
return false; return false;
@ -683,6 +687,7 @@ public class QueryMapper {
* @param value the actual value. Can be {@literal null}. * @param value the actual value. Can be {@literal null}.
* @return the potentially converted target value. * @return the potentially converted target value.
*/ */
@Nullable
private Object applyFieldTargetTypeHintToValue(Field documentField, @Nullable Object value) { private Object applyFieldTargetTypeHintToValue(Field documentField, @Nullable Object value) {
if (value == null || documentField.getProperty() == null || !documentField.getProperty().hasExplicitWriteTarget()) { if (value == null || documentField.getProperty() == null || !documentField.getProperty().hasExplicitWriteTarget()) {

Loading…
Cancel
Save