-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FMWK-443 Add configuration flag writeSortedMaps #745
Conversation
@@ -157,7 +159,12 @@ private void convertToAerospikeWriteData(Object source, AerospikeWriteData data) | |||
|
|||
private Map<String, Object> convertProperties(TypeInformation<?> type, AerospikePersistentEntity<?> entity, | |||
ConvertingPropertyAccessor<?> accessor, boolean isCustomType) { | |||
Map<String, Object> target = new TreeMap<>(); | |||
Map<String, Object> target; | |||
if (!settings.isWriteTreeMaps()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simpler to check isWriteTreeMaps
and set target as TreeMap, otherwise use HashMap (follow the condition, no need for !
@@ -234,7 +241,14 @@ protected Map<Object, Object> convertMap(final Map<Object, Object> source, final | |||
Assert.notNull(source, "Given map must not be null!"); | |||
Assert.notNull(type, "Given type must not be null!"); | |||
|
|||
return source.entrySet().stream().collect(TreeMap::new, (m, e) -> { | |||
Supplier<Map<Object, Object>> mapSupplier; | |||
if (!settings.isWriteTreeMaps()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
simpler to check isWriteTreeMaps and set target as TreeMap, otherwise use HashMap (follow the condition, no need for !
@@ -37,4 +37,6 @@ public class AerospikeDataSettings { | |||
// Define how @Id fields (primary keys) and Map keys are stored: false - always as String, | |||
// true - preserve original type if supported | |||
boolean keepOriginalKeyTypes = false; | |||
// Define how Maps are written: true - as TreeMaps (default), false - as HashMaps | |||
boolean writeTreeMaps = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming to useSortedMap
.
Map<String, Object> target; | ||
if (settings.isWriteTreeMaps()) { | ||
target = new TreeMap<>(); | ||
} else { | ||
target = new HashMap<>(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using the ternary operator.
Supplier<Map<Object, Object>> mapSupplier; | ||
if (settings.isWriteTreeMaps()) { | ||
mapSupplier = TreeMap::new; | ||
} else { | ||
mapSupplier = HashMap::new; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using the ternary operator.
No description provided.