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
 
 @ThreadSafe public interface TableSchema<T> Interface for a mapper that is capable of mapping a modelled Java object into a map ofAttributeValuethat 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 aTableMetadataobject.
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description List<String>attributeNames()Returns a complete list of attribute names that are mapped by thisTableSchemaAttributeValueattributeValue(T item, String attributeName)Returns a single attribute value from the modelled object.static <T> StaticTableSchema.Builder<T>builder(Class<T> itemClass)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(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.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>converterForAttribute(Object key)AttributeConverterthat is applied to the given key.static DocumentTableSchema.BuilderdocumentSchemaBuilder()Provides interfaces to interact with DynamoDB tables asEnhancedDocumentwhere the complete Schema of the table is not required.static <T> BeanTableSchema<T>fromBean(Class<T> beanClass)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>fromClass(Class<T> annotatedClass)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.booleanisAbstract()A 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.Map<String,AttributeValue>itemToMap(T item, boolean ignoreNulls)Takes a modelled object and converts it into a raw map ofAttributeValuethat the DynamoDb low-level SDK can work with.Map<String,AttributeValue>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.EnhancedType<T>itemType()Returns theEnhancedTypethat represents the 'Type' of the Java object this table schema object maps to and from.TmapToItem(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.TableMetadatatableMetadata()Returns the object that describes the structure of the table being modelled by the mapper.
 
- 
- 
- 
Method Detail- 
builderstatic <T> StaticTableSchema.Builder<T> builder(Class<T> itemClass) 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 this- TableSchemawill map records to.
- Parameters:
- itemClass- The class of the item this- TableSchemawill map records to.
- Returns:
- A newly initialized StaticTableSchema.Builder.
 
 - 
builderstatic <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.- Type Parameters:
- T- The type of the item this- TableSchemawill map records to.
- Parameters:
- itemType- The- EnhancedTypeof the item this- TableSchemawill map records to.
- Returns:
- A newly initialized StaticTableSchema.Builder.
 
 - 
builderstatic <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 this- TableSchemawill map records to.
- B- The type of the builder used by this- TableSchemato construct immutable items with.
- Parameters:
- immutableItemClass- The class of the immutable item this- TableSchemawill map records to.
- immutableBuilderClass- The class that can be used to construct immutable items this- TableSchemamaps records to.
- Returns:
- A newly initialized StaticImmutableTableSchema.Builder
 
 - 
builderstatic <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 this- TableSchemawill map records to.
- B- The type of the builder used by this- TableSchemato construct immutable items with.
- Parameters:
- immutableItemType- The- EnhancedTypeof the immutable item this- TableSchemawill map records to.
- immutableBuilderType- The- EnhancedTypeof the class that can be used to construct immutable items this- TableSchemamaps records to.
- Returns:
- A newly initialized StaticImmutableTableSchema.Builder
 
 - 
fromBeanstatic <T> BeanTableSchema<T> fromBean(Class<T> beanClass) 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 this- TableSchemawill map records to.
- Parameters:
- beanClass- The bean class this- TableSchemawill map records to.
- Returns:
- An initialized BeanTableSchema.
 
 - 
fromBeanstatic <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.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 this- TableSchemawill map records to.
- Parameters:
- params- The parameters used to create the- BeanTableSchema.
- Returns:
- An initialized BeanTableSchema.
 
 - 
documentSchemaBuilderstatic DocumentTableSchema.Builder documentSchemaBuilder() Provides interfaces to interact with DynamoDB tables asEnhancedDocumentwhere the complete Schema of the table is not required.- Returns:
- A DocumentTableSchema.Builderfor instantiating DocumentTableSchema.
 
 - 
fromImmutableClassstatic <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.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 this- TableSchemawill map records to.
- Parameters:
- immutableClass- The immutable class this- TableSchemawill map records to.
- Returns:
- An initialized ImmutableTableSchema.
 
 - 
fromImmutableClassstatic <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.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 this- TableSchemawill map records to.
- Parameters:
- params- The parameters used to create the- ImmutableTableSchema.
- Returns:
- An initialized ImmutableTableSchema.
 
 - 
fromClassstatic <T> TableSchema<T> fromClass(Class<T> annotatedClass) 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 this- TableSchemawill map records to.
- Parameters:
- annotatedClass- A class that has been annotated with DynamoDb enhanced client annotations.
- Returns:
- An initialized TableSchema
 
 - 
mapToItemT mapToItem(Map<String,AttributeValue> attributeMap) 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- AttributeValuethat contains all the raw attributes to map.
- Returns:
- A new instance of a Java object with all the attributes mapped onto it.
- Throws:
- IllegalArgumentException- if any attributes in the map could not be mapped onto the new model object.
- See Also:
- mapToItem(Map, boolean)
 
 - 
mapToItemdefault T mapToItem(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. 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. In the scenario where all attribute values in the map are null, it will return null if preserveEmptyObjectis true. If it's false, an empty object will be returned.Note that preserveEmptyObjectonly applies to the top level Java object, if it has nested "empty" objects, they will be mapped as null. You can useDynamoDbPreserveEmptyObjectto configure this behavior for nested objects.API Implementors Note: This method must be implemented if preserveEmptyObjectbehavior is to be supported- Parameters:
- attributeMap- A map of String to- AttributeValuethat contains all the raw attributes to map.
- preserveEmptyObject- whether to initialize this Java object as empty class if all fields are null
- Returns:
- A new instance of a Java object with all the attributes mapped onto it.
- Throws:
- IllegalArgumentException- if any attributes in the map could not be mapped onto the new model object.
- UnsupportedOperationException- if- preserveEmptyObjectis not supported in the implementation
- See Also:
- mapToItem(Map)
 
 - 
itemToMapMap<String,AttributeValue> itemToMap(T item, boolean ignoreNulls) Takes a modelled object and converts it into a raw map ofAttributeValuethat the DynamoDb low-level SDK can work with.- Parameters:
- item- The modelled Java object to convert into a map of attributes.
- ignoreNulls- If set to true; any null values in the Java object will not be added to the output map. If set to false; null values in the Java object will be added as- AttributeValueof type 'nul' to the output map.
- Returns:
- A map of String to AttributeValuerepresenting all the modelled attributes in the model object.
 
 - 
itemToMapMap<String,AttributeValue> 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. This method is typically used to extract just the key attributes of a modelled item and will not ignore nulls on the modelled object.- Parameters:
- item- The modelled Java object to extract the map of attributes from.
- attributes- A collection of attribute names to extract into the output map.
- Returns:
- A map of String to AttributeValuerepresenting the requested modelled attributes in the model object.
 
 - 
attributeValueAttributeValue attributeValue(T item, String attributeName) Returns a single attribute value from the modelled object.- Parameters:
- item- The modelled Java object to extract the attribute from.
- attributeName- The attribute name describing which attribute to extract.
- Returns:
- A single AttributeValuerepresenting the requested modelled attribute in the model object or null if the attribute has not been set with a value in the modelled object.
 
 - 
tableMetadataTableMetadata tableMetadata() Returns the object that describes the structure of the table being modelled by the mapper. This includes information such as the table name, index keys and attribute tags.- Returns:
- A TableMetadataobject that contains structural information about the table being modelled.
 
 - 
itemTypeEnhancedType<T> itemType() Returns theEnhancedTypethat represents the 'Type' of the Java object this table schema object maps to and from.- Returns:
- The EnhancedTypeof the modelled item this TableSchema maps to.
 
 - 
attributeNamesList<String> attributeNames() Returns a complete list of attribute names that are mapped by thisTableSchema
 - 
isAbstractboolean isAbstract() A 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.- Returns:
- true if it is abstract, and therefore cannot be used directly to create records but can be referred to by other schemata, and false if it is concrete and may be used to map records directly.
 
 - 
converterForAttributedefault AttributeConverter<T> converterForAttribute(Object key) AttributeConverterthat is applied to the given key.- Parameters:
- key- Attribute of the modelled item.
- Returns:
- AttributeConverter defined for the given attribute key.
 
 
- 
 
-