Skip to content

Commit 335c78f

Browse files
committed
DATAMONGO-1269 - Polishing.
Original pull request: #314.
1 parent b103e4e commit 335c78f

File tree

1 file changed

+9
-7
lines changed
  • spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,14 @@ static class PositionParameterRetainingPropertyKeyConverter implements Converter
889889

890890
private final KeyMapper keyMapper;
891891

892-
PositionParameterRetainingPropertyKeyConverter(String rawKey) {
892+
public PositionParameterRetainingPropertyKeyConverter(String rawKey) {
893893
this.keyMapper = new KeyMapper(rawKey);
894894
}
895895

896+
/*
897+
* (non-Javadoc)
898+
* @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
899+
*/
896900
@Override
897901
public String convert(MongoPersistentProperty source) {
898902
return keyMapper.mapPropertyName(source);
@@ -926,7 +930,7 @@ public TypeInformation<?> getTypeHint() {
926930
*/
927931
static class KeyMapper {
928932

929-
Iterator<String> iterator;
933+
private final Iterator<String> iterator;
930934

931935
public KeyMapper(String key) {
932936

@@ -943,14 +947,13 @@ public KeyMapper(String key) {
943947
protected String mapPropertyName(MongoPersistentProperty property) {
944948

945949
String mappedName = PropertyToFieldNameConverter.INSTANCE.convert(property);
946-
947950
boolean inspect = iterator.hasNext();
951+
948952
while (inspect) {
949953

950954
String partial = iterator.next();
955+
boolean isPositional = (isPositionalParameter(partial) && (property.isMap() || property.isCollectionLike()));
951956

952-
boolean isPositional = (isPositionalParameter(partial) && (property.isMap() || property.isCollectionLike() || property
953-
.isArray()));
954957
if (isPositional) {
955958
mappedName += "." + partial;
956959
}
@@ -961,7 +964,7 @@ protected String mapPropertyName(MongoPersistentProperty property) {
961964
return mappedName;
962965
}
963966

964-
boolean isPositionalParameter(String partial) {
967+
private static boolean isPositionalParameter(String partial) {
965968

966969
if (partial.equals("$")) {
967970
return true;
@@ -975,7 +978,6 @@ boolean isPositionalParameter(String partial) {
975978
}
976979
}
977980
}
978-
979981
}
980982

981983
/**

0 commit comments

Comments
 (0)