-
Notifications
You must be signed in to change notification settings - Fork 958
DynamodbEnhanced client add preserve empty bean support #2364
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
Conversation
...a/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbPreserveEmptyBean.java
Outdated
Show resolved
Hide resolved
| this.buildItemFunction = builder.buildItemFunction; | ||
| this.tableMetadata = tableMetadataBuilder.build(); | ||
| this.itemType = EnhancedType.of(builder.itemClass); | ||
| this.preserveEmtpyBean = builder.itemClass.getAnnotation(DynamoDbPreserveEmptyBean.class) != null; |
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.
Static*TableSchema must not perform any reflection. It must be statically configurable from its builder using properties and tags. We could achieve this by having a boolean builder property for example like
.preserveEmptyBean(true)
and then BeanTableSchema and ImmutableTableSchema would scan for the annotation and add that flag to the StaticImmutableTableSchema they were building.
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.
Yeah, I was not aware of this. I'll see if I can add a checkstyle for this.
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.
It's more of a design thing than a technical limitation. StaticTableSchema and StaticImmutableTableSchema are both public classes (APIs) that customers that specifically do not want to use reflection can opt to use to construct their TableSchema instances without any runtime class metadata being involved. We wouldn't want to break that contract/promise.
...c/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/testbeans/PreserveEmptyBean.java
Outdated
Show resolved
Hide resolved
2044b11 to
5593b48
Compare
...rc/main/java/software/amazon/awssdk/enhanced/dynamodb/DefaultAttributeConverterProvider.java
Outdated
Show resolved
Hide resolved
...m/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/EnhancedType.java
Outdated
Show resolved
Hide resolved
...m/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/EnhancedType.java
Outdated
Show resolved
Hide resolved
...om/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java
Show resolved
Hide resolved
...a/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbPreserveEmptyBean.java
Outdated
Show resolved
Hide resolved
...c/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/testbeans/AbstractImmutable.java
Outdated
Show resolved
Hide resolved
...src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/testbeans/NestedImmutable.java
Outdated
Show resolved
Hide resolved
...om/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java
Show resolved
Hide resolved
...om/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java
Outdated
Show resolved
Hide resolved
...rc/main/java/software/amazon/awssdk/enhanced/dynamodb/DefaultAttributeConverterProvider.java
Outdated
Show resolved
Hide resolved
...src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/testbeans/NestedImmutable.java
Outdated
Show resolved
Hide resolved
a77e3ef to
8ae5081
Compare
...rc/main/java/software/amazon/awssdk/enhanced/dynamodb/DefaultAttributeConverterProvider.java
Outdated
Show resolved
Hide resolved
...om/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java
Outdated
Show resolved
Hide resolved
...om/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java
Outdated
Show resolved
Hide resolved
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.
Nice with a comprehensive example!
…ass if all fields are null when mapping a DynamoDb record to a Java bean
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.
Beautiful!
cfbee38 to
f2a0a69
Compare
|
SonarCloud Quality Gate failed. |
Description
Added a new attribute-level annotation that initializes a class as empty class if all fields are null when mapping a DynamoDb record to a Java bean
Motivation and Context
#2280 #2334
Testing
Added unit tests
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsLicense