Merged
Conversation
Contributor
tim-aero
commented
Jul 4, 2023
- Builder pattern used to build configuration
- Refactored the AeroMapper and ReactiveAeroMapper to extracts the builders into a common class whilse preserving the same interface
- Added setters onto several configuration classes
- Added unit tests for the configuration in code
- Minor other tweaks
- Builder pattern used to build configuration - Refactored the AeroMapper and ReactiveAeroMapper to extracts the builders into a common class whilse preserving the same interface - Added setters onto several configuration classes - Added unit tests for the configuration in code - Minor other tweaks
reugn
reviewed
Jul 4, 2023
Comment on lines
162
to
163
|
|
||
|
|
Comment on lines
33
to
34
|
|
||
|
|
| } | ||
|
|
||
| enum PolicyType { | ||
| public static enum PolicyType { |
Contributor
There was a problem hiding this comment.
No need for explicit static modifier
| * @return this object | ||
| */ | ||
| public AbstractBuilder<T> addConverter(Object converter) { | ||
| GenericTypeMapper mapper = new GenericTypeMapper(converter); |
Contributor
There was a problem hiding this comment.
Rename the local variable to not hide the class field
Comment on lines
177
to
179
| if (!ConfigurationUtils.validateFieldOnClass(this.clazz, fieldName)) { | ||
| throw new AerospikeException(String.format("Field %s does not exist on class %s or its superclasses", fieldName, this.clazz)); | ||
| } |
Contributor
There was a problem hiding this comment.
Can be extracted to a validation method and reused (used twice in the class)
| } | ||
|
|
||
| public AeroPolicyMapper<T> withReadPolicy(Policy policy) { | ||
| return new AeroPolicyMapper<T>(this, PolicyType.READ, policy); |
Contributor
There was a problem hiding this comment.
The diamond operator AeroPolicyMapper<>(...) can be used in return statements
|
|
||
| @Test | ||
| public void testWithConfiguration() { | ||
| AeroMapper mapper = new AeroMapper.Builder(client) |
Contributor
There was a problem hiding this comment.
The current builder architecture using intermediate states is complicated. Please consider something like:
ClassConfiguration classConfigB = ClassConfiguration.Builder(B.class)
.withFieldNamed("c")
.beingEmbeddedAs(AerospikeEmbed.EmbedType.MAP)
.build();
new AeroMapper.Builder(client)
.withClassConfiguration(classConfigB)
.build();| } | ||
|
|
||
| @Test | ||
| public void testWithInvalidConfiguarion() { |
Contributor
There was a problem hiding this comment.
Suggested change
| public void testWithInvalidConfiguarion() { | |
| public void testWithInvalidConfiguration() { |
| .withFieldNamed("c").beingEmbeddedAs(AerospikeEmbed.EmbedType.MAP) | ||
| .end() | ||
| .build(); | ||
| Assertions.fail("Excpected invalid configuration to throw an error"); |
Contributor
There was a problem hiding this comment.
Suggested change
| Assertions.fail("Excpected invalid configuration to throw an error"); | |
| Assertions.fail("Expected invalid configuration to throw an error"); |
Refactored the ClassConfig builder to be a separate builder for a cleaner experience
configuration-through-code
reugn
approved these changes
Jul 7, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.