DATAMONGO-1118 - Simplified potentiallyConvertMapKey in MappingMongoConverter.

Fixed typos in CustomConversions.

Original pull request: #260.
This commit is contained in:
Thomas Darimont
2014-12-23 09:48:47 +01:00
committed by Oliver Gierke
parent c353e02b3e
commit 4a7a485e62
2 changed files with 11 additions and 12 deletions

View File

@@ -247,9 +247,9 @@ public class CustomConversions {
}
/**
* Returns the target type we can write an onject of the given source type to. The returned type might be a subclass
* oth the given expected type though. If {@code expectedTargetType} is {@literal null} we will simply return the
* first target type matching or {@literal null} if no conversion can be found.
* Returns the target type we can write an inject of the given source type to. The returned type might be a subclass
* of the given expected type though. If {@code expectedTargetType} is {@literal null} we will simply return the first
* target type matching or {@literal null} if no conversion can be found.
*
* @param sourceType must not be {@literal null}
* @param requestedTargetType

View File

@@ -647,7 +647,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
Object val = entry.getValue();
if (conversions.isSimpleType(key.getClass())) {
String simpleKey = potentiallyConvertMapKey(key);
String simpleKey = potentiallyEscapeMapKey(potentiallyConvertMapKey(key));
if (val == null || conversions.isSimpleType(val.getClass())) {
writeSimpleInternal(val, dbo, simpleKey);
} else if (val instanceof Collection || val.getClass().isArray()) {
@@ -670,16 +670,15 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
private String potentiallyConvertMapKey(Object key) {
String stringKey = null;
if (key instanceof String
|| !(conversions.hasCustomWriteTarget(key.getClass()) && conversions.getCustomWriteTarget(key.getClass())
.equals(String.class))) {
stringKey = key.toString();
} else {
stringKey = (String) getPotentiallyConvertedSimpleWrite(key);
if (key instanceof String) {
return (String) key;
}
return potentiallyEscapeMapKey(stringKey);
if (conversions.hasCustomWriteTarget(key.getClass(), String.class)) {
return (String) getPotentiallyConvertedSimpleWrite(key);
}
return key.toString();
}
/**