Class StaticTableSchema<T>
- java.lang.Object
-
- software.amazon.awssdk.enhanced.dynamodb.mapper.WrappedTableSchema<T,StaticImmutableTableSchema<T,T>>
-
- software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema<T>
-
- All Implemented Interfaces:
TableSchema<T>
@ThreadSafe public final class StaticTableSchema<T> extends WrappedTableSchema<T,StaticImmutableTableSchema<T,T>>
Implementation ofTableSchemathat builds a schema based on directly declared attributes and methods to get and set those attributes. Just likeStaticImmutableTableSchemawhich is the equivalent implementation for immutable objects, this is the most direct, and thus fastest, implementation ofTableSchema.Example using a fictional 'Customer' data item class:-
static final TableSchema<Customer> CUSTOMER_TABLE_SCHEMA = StaticTableSchema.builder(Customer.class) .newItemSupplier(Customer::new) .addAttribute(String.class, a -> a.name("account_id") .getter(Customer::getAccountId) .setter(Customer::setAccountId) .tags(primaryPartitionKey())) .addAttribute(Integer.class, a -> a.name("sub_id") .getter(Customer::getSubId) .setter(Customer::setSubId) .tags(primarySortKey())) .addAttribute(String.class, a -> a.name("name") .getter(Customer::getName) .setter(Customer::setName) .tags(secondaryPartitionKey("customers_by_name"))) .addAttribute(Instant.class, a -> a.name("created_date") .getter(Customer::getCreatedDate) .setter(Customer::setCreatedDate) .tags(secondarySortKey("customers_by_date"), secondarySortKey("customers_by_name"))) .build();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStaticTableSchema.Builder<T>Builder for aStaticTableSchema
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeConverterProviderattributeConverterProvider()The table schemaAttributeConverterProvider.static <T> StaticTableSchema.Builder<T>builder(Class<T> itemClass)Creates a builder for aStaticTableSchematyped to specific data item class.static <T> StaticTableSchema.Builder<T>builder(EnhancedType<T> itemType)Creates a builder for aStaticTableSchematyped to specific data item class.-
Methods inherited from class software.amazon.awssdk.enhanced.dynamodb.mapper.WrappedTableSchema
attributeNames, attributeValue, converterForAttribute, delegateTableSchema, isAbstract, itemToMap, itemToMap, itemType, mapToItem, mapToItem, tableMetadata
-
-
-
-
Method Detail
-
builder
public static <T> StaticTableSchema.Builder<T> builder(Class<T> itemClass)
Creates a builder for aStaticTableSchematyped to specific data item class.- Type Parameters:
T- The type of the item thisTableSchemawill map records to.- Parameters:
itemClass- The data item class object that theStaticTableSchemais to map to.- Returns:
- A newly initialized builder
-
builder
public static <T> StaticTableSchema.Builder<T> builder(EnhancedType<T> itemType)
Creates a builder for aStaticTableSchematyped to specific data item class.- Type Parameters:
T- The type of the item thisTableSchemawill map records to.- Parameters:
itemType- TheEnhancedTypeof the data item class object that theStaticTableSchemais to map to.- Returns:
- A newly initialized builder
-
attributeConverterProvider
public AttributeConverterProvider attributeConverterProvider()
The table schemaAttributeConverterProvider.- See Also:
attributeConverterProvider()
-
-