Interface TableSchema<T>
- Type Parameters:
T- The type of model object that is being mapped to records in the DynamoDb table.
- All Known Implementing Classes:
BeanTableSchema,DocumentTableSchema,ImmutableTableSchema,MetaTableSchema,StaticImmutableTableSchema,StaticTableSchema,WrappedTableSchema
AttributeValue that is
understood by the DynamoDb low-level SDK and back again. This object is also expected to know about the
structure of the table it is modelling, which is stored in a TableMetadata object.-
Method Summary
Modifier and TypeMethodDescriptionReturns a complete list of attribute names that are mapped by thisTableSchemaattributeValue(T item, String attributeName) Returns a single attribute value from the modelled object.static <T> StaticTableSchema.Builder<T> Returns a builder for theStaticTableSchemaimplementation of this interface which allows all attributes, tags and table structure to be directly declared in the builder.static <T,B> StaticImmutableTableSchema.Builder <T, B> Returns a builder for theStaticImmutableTableSchemaimplementation of this interface which allows all attributes, tags and table structure to be directly declared in the builder.static <T> StaticTableSchema.Builder<T> builder(EnhancedType<T> itemType) Returns a builder for theStaticTableSchemaimplementation of this interface which allows all attributes, tags and table structure to be directly declared in the builder.static <T,B> StaticImmutableTableSchema.Builder <T, B> builder(EnhancedType<T> immutableItemType, EnhancedType<B> immutableBuilderType) Returns a builder for theStaticImmutableTableSchemaimplementation of this interface which allows all attributes, tags and table structure to be directly declared in the builder.default AttributeConverter<T> AttributeConverterthat is applied to the given key.static DocumentTableSchema.BuilderProvides interfaces to interact with DynamoDB tables asEnhancedDocumentwhere the complete Schema of the table is not required.static <T> BeanTableSchema<T> Scans a bean class that has been annotated with DynamoDb bean annotations and then returns aBeanTableSchemaimplementation of this interface that can map records to and from items of that bean class.static <T> BeanTableSchema<T> fromBean(BeanTableSchemaParams<T> params) Scans a bean class that has been annotated with DynamoDb bean annotations and then returns aBeanTableSchemaimplementation of this interface that can map records to and from items of that bean class.static <T> TableSchema<T> Scans a class that has been annotated with DynamoDb enhanced client annotations and then returns an appropriateTableSchemaimplementation that can map records to and from items of that class.static <T> ImmutableTableSchema<T> fromImmutableClass(Class<T> immutableClass) Scans an immutable class that has been annotated with DynamoDb immutable annotations and then returns aImmutableTableSchemaimplementation of this interface that can map records to and from items of that immutable class.static <T> ImmutableTableSchema<T> fromImmutableClass(ImmutableTableSchemaParams<T> params) Scans an immutable class that has been annotated with DynamoDb immutable annotations and then returns aImmutableTableSchemaimplementation of this interface that can map records to and from items of that immutable class.booleanA boolean value that represents whether thisTableSchemais abstract which means that it cannot be used to directly create records as it is lacking required structural elements to map to a table, such as a primary key, but can be referred to and embedded by other schemata.Takes a modelled object and converts it into a raw map ofAttributeValuethat the DynamoDb low-level SDK can work with.itemToMap(T item, Collection<String> attributes) Takes a modelled object and extracts a specific set of attributes which are then returned as a map ofAttributeValuethat the DynamoDb low-level SDK can work with.itemType()Returns theEnhancedTypethat represents the 'Type' of the Java object this table schema object maps to and from.mapToItem(Map<String, AttributeValue> attributeMap) Takes a raw DynamoDb SDK representation of a record in a table and maps it to a Java object.default TmapToItem(Map<String, AttributeValue> attributeMap, boolean preserveEmptyObject) Takes a raw DynamoDb SDK representation of a record in a table and maps it to a Java object.Returns the object that describes the structure of the table being modelled by the mapper.
-
Method Details
-
builder
Returns a builder for theStaticTableSchemaimplementation of this interface which allows all attributes, tags and table structure to be directly declared in the builder.- Type Parameters:
T- The type of the item thisTableSchemawill map records to.- Parameters:
itemClass- The class of the item thisTableSchemawill map records to.- Returns:
- A newly initialized
StaticTableSchema.Builder.
-
builder
Returns a builder for theStaticTableSchemaimplementation of this interface which allows all attributes, tags and table structure to be directly declared in the builder.- Type Parameters:
T- The type of the item thisTableSchemawill map records to.- Parameters:
itemType- TheEnhancedTypeof the item thisTableSchemawill map records to.- Returns:
- A newly initialized
StaticTableSchema.Builder.
-
builder
static <T,B> StaticImmutableTableSchema.Builder<T,B> builder(Class<T> immutableItemClass, Class<B> immutableBuilderClass) Returns a builder for theStaticImmutableTableSchemaimplementation of this interface which allows all attributes, tags and table structure to be directly declared in the builder.- Type Parameters:
T- The type of the immutable item thisTableSchemawill map records to.B- The type of the builder used by thisTableSchemato construct immutable items with.- Parameters:
immutableItemClass- The class of the immutable item thisTableSchemawill map records to.immutableBuilderClass- The class that can be used to construct immutable items thisTableSchemamaps records to.- Returns:
- A newly initialized
StaticImmutableTableSchema.Builder
-
builder
static <T,B> StaticImmutableTableSchema.Builder<T,B> builder(EnhancedType<T> immutableItemType, EnhancedType<B> immutableBuilderType) Returns a builder for theStaticImmutableTableSchemaimplementation of this interface which allows all attributes, tags and table structure to be directly declared in the builder.- Type Parameters:
T- The type of the immutable item thisTableSchemawill map records to.B- The type of the builder used by thisTableSchemato construct immutable items with.- Parameters:
immutableItemType- TheEnhancedTypeof the immutable item thisTableSchemawill map records to.immutableBuilderType- TheEnhancedTypeof the class that can be used to construct immutable items thisTableSchemamaps records to.- Returns:
- A newly initialized
StaticImmutableTableSchema.Builder
-
fromBean
Scans a bean class that has been annotated with DynamoDb bean annotations and then returns aBeanTableSchemaimplementation of this interface that can map records to and from items of that bean class.It's recommended to only create a
BeanTableSchemaonce for a single bean class, usually at application start up, because it's a moderately expensive operation.- Type Parameters:
T- The type of the item thisTableSchemawill map records to.- Parameters:
beanClass- The bean class thisTableSchemawill map records to.- Returns:
- An initialized
BeanTableSchema.
-
fromBean
Scans a bean class that has been annotated with DynamoDb bean annotations and then returns aBeanTableSchemaimplementation of this interface that can map records to and from items of that bean class.It's recommended to only create a
BeanTableSchemaonce for a single bean class, usually at application start up, because it's a moderately expensive operation.Generally, this method should be preferred over
fromBean(Class)because it allows you to use a customMethodHandles.Lookupinstance, which is necessary when your application runs in an environment where your application code and dependencies like the AWS SDK for Java are loaded by different classloaders.- Type Parameters:
T- The type of the item thisTableSchemawill map records to.- Parameters:
params- The parameters used to create theBeanTableSchema.- Returns:
- An initialized
BeanTableSchema.
-
documentSchemaBuilder
Provides interfaces to interact with DynamoDB tables asEnhancedDocumentwhere the complete Schema of the table is not required.- Returns:
- A
DocumentTableSchema.Builderfor instantiating DocumentTableSchema.
-
fromImmutableClass
Scans an immutable class that has been annotated with DynamoDb immutable annotations and then returns aImmutableTableSchemaimplementation of this interface that can map records to and from items of that immutable class.It's recommended to only create an
ImmutableTableSchemaonce for a single immutable class, usually at application start up, because it's a moderately expensive operation.- Type Parameters:
T- The type of the item thisTableSchemawill map records to.- Parameters:
immutableClass- The immutable class thisTableSchemawill map records to.- Returns:
- An initialized
ImmutableTableSchema.
-
fromImmutableClass
Scans an immutable class that has been annotated with DynamoDb immutable annotations and then returns aImmutableTableSchemaimplementation of this interface that can map records to and from items of that immutable class.It's recommended to only create an
ImmutableTableSchemaonce for a single immutable class, usually at application start up, because it's a moderately expensive operation.- Type Parameters:
T- The type of the item thisTableSchemawill map records to.- Parameters:
params- The parameters used to create theImmutableTableSchema.- Returns:
- An initialized
ImmutableTableSchema.
-
fromClass
Scans a class that has been annotated with DynamoDb enhanced client annotations and then returns an appropriateTableSchemaimplementation that can map records to and from items of that class. Currently supported top level annotations (see documentation on those classes for more information on how to use them):DynamoDbBean,DynamoDbImmutable.It's recommended to only invoke this operation once for a single class, usually at application start up, because it's a moderately expensive operation.
If this table schema is not behaving as you expect, enable debug logging for
software.amazon.awssdk.enhanced.dynamodb.beans.- Type Parameters:
T- The type of the item thisTableSchemawill map records to.- Parameters:
annotatedClass- A class that has been annotated with DynamoDb enhanced client annotations.- Returns:
- An initialized
TableSchema
-
mapToItem
Takes a raw DynamoDb SDK representation of a record in a table and maps it to a Java object. A new object is created to fulfil this operation.If attributes are missing from the map, that will not cause an error, however if attributes are found in the map which the mapper does not know how to map, an exception will be thrown.
If all attribute values in the attributeMap are null, null will be returned. Use
mapToItem(Map, boolean)instead if you need to preserve empty object.API Implementors Note:
mapToItem(Map, boolean)must be implemented ifpreserveEmptyObjectbehavior is desired.- Parameters:
attributeMap- A map of String to
-