Skip to content

Commit 0c074c0

Browse files
authored
Handled surface api comments of removing Generic access as Objects (#3811)
* TableSchema API to create table and functional tests * Surface API Review * Surface API Review - compilation issues * Surface API Review - Review comments * Surface API Review comments from Matt * Compilation issue and toStringMethod for JsonNode * Updated after handling Matt's comments * Functional Test added * Update in test cases * Removed functional tests , will create new PR for this * Review comments handled * Explicutly adding the dependency in th pom.xml * Removed @code from @snippet line in javadoc
1 parent 5c683e5 commit 0c074c0

22 files changed

+2131
-1675
lines changed

docs/design/services/dynamodb/high-level-library/DocumentAPI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ providers.
4444

4545
// New API in TableSchema to create a DocumentTableSchema
4646
DocumentTableSchema documentTableSchema =
47-
TableSchema.fromDocumentSchemaBuilder()
47+
TableSchema.documentSchemaBuilder()
4848
.addIndexPartitionKey(primaryIndexName(), "sample_hash_name", AttributeValueType.S)
4949
.addIndexSortKey("gsi_index", "sample_sort_name", AttributeValueType.N)
5050
.addAttributeConverterProviders(cutomAttributeConverters)
@@ -78,7 +78,7 @@ EnhancedDocument documentTableItem = documentTable.getItem(
7878
Number sampleSortvalue = documentTableItem.get("sample_sort_name", EnhancedType.of(Number.class));
7979

8080
// Accessing an attribute from document using specific getters.
81-
sampleSortvalue = documentTableItem.getSdkNumber("sample_sort_name");
81+
sampleSortvalue = documentTableItem.getNumber("sample_sort_name");
8282

8383
// Accessing an attribute of custom class using custom converters.
8484
CustomClass customClass = documentTableItem.get("custom_nested_map", new CustomAttributeConverter()));

services-custom/dynamodb-enhanced/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@
106106
<artifactId>aws-core</artifactId>
107107
<version>${awsjavasdk.version}</version>
108108
</dependency>
109+
<dependency>
110+
<groupId>software.amazon.awssdk</groupId>
111+
<artifactId>json-utils</artifactId>
112+
<version>${awsjavasdk.version}</version>
113+
</dependency>
109114
<dependency>
110115
<groupId>software.amazon.awssdk</groupId>
111116
<artifactId>http-client-spi</artifactId>

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/DefaultAttributeConverterProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.OptionalLongAttributeConverter;
6262
import software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.PeriodAttributeConverter;
6363
import software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.SdkBytesAttributeConverter;
64+
import software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.SdkNumberAttributeConverter;
6465
import software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.SetAttributeConverter;
6566
import software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.ShortAttributeConverter;
6667
import software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.StringAttributeConverter;
@@ -88,7 +89,7 @@
8889
@ThreadSafe
8990
@Immutable
9091
public final class DefaultAttributeConverterProvider implements AttributeConverterProvider {
91-
private static DefaultAttributeConverterProvider INSTANCE = getDefaultBuilder().build();
92+
private static final DefaultAttributeConverterProvider INSTANCE = getDefaultBuilder().build();
9293

9394
private static final Logger log = Logger.loggerFor(DefaultAttributeConverterProvider.class);
9495

@@ -247,7 +248,8 @@ private static Builder getDefaultBuilder() {
247248
.addConverter(UuidAttributeConverter.create())
248249
.addConverter(ZonedDateTimeAsStringAttributeConverter.create())
249250
.addConverter(ZoneIdAttributeConverter.create())
250-
.addConverter(ZoneOffsetAttributeConverter.create());
251+
.addConverter(ZoneOffsetAttributeConverter.create())
252+
.addConverter(SdkNumberAttributeConverter.create());
251253
}
252254

253255
/**

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
import java.util.Map;
2121
import software.amazon.awssdk.annotations.SdkPublicApi;
2222
import software.amazon.awssdk.annotations.ThreadSafe;
23+
import software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocument;
2324
import software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema;
25+
import software.amazon.awssdk.enhanced.dynamodb.mapper.DocumentTableSchema;
2426
import software.amazon.awssdk.enhanced.dynamodb.mapper.ImmutableTableSchema;
2527
import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema;
2628
import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema;
@@ -84,6 +86,16 @@ static <T> BeanTableSchema<T> fromBean(Class<T> beanClass) {
8486
return BeanTableSchema.create(beanClass);
8587
}
8688

89+
/**
90+
* Provides interfaces to interact with DynamoDB tables as {@link EnhancedDocument} where the complete Schema of the table is
91+
* not required.
92+
*
93+
* @return A {@link DocumentTableSchema.Builder} for instantiating DocumentTableSchema.
94+
*/
95+
static DocumentTableSchema.Builder documentSchemaBuilder() {
96+
return DocumentTableSchema.builder();
97+
}
98+
8799
/**
88100
* Scans an immutable class that has been annotated with DynamoDb immutable annotations and then returns a
89101
* {@link ImmutableTableSchema} implementation of this interface that can map records to and from items of that

0 commit comments

Comments
 (0)