T
- The type of model object that is being mapped to records in the DynamoDb table.public interface TableSchema<T>
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.Modifier and Type | Method and Description |
---|---|
AttributeValue |
attributeValue(T item,
String key)
Returns a single attribute value from the modelled object.
|
static <T> StaticTableSchema.Builder<T> |
builder(Class<T> itemClass)
Returns a builder for the
StaticTableSchema implementation of this interface which allows all attributes,
tags and table structure to be directly declared in the builder. |
static <T> BeanTableSchema<T> |
fromBean(Class<T> beanClass)
Scans a bean class that has been annotated with DynamoDb bean annotations and then returns a
BeanTableSchema implementation of this interface that can map records to and from items of that bean
class. |
Map<String,AttributeValue> |
itemToMap(T item,
boolean ignoreNulls)
Takes a modelled object and converts it into a raw map of
AttributeValue that 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 of
AttributeValue that the DynamoDb low-level SDK can work with. |
EnhancedType<T> |
itemType()
Returns the
EnhancedType that represents the 'Type' of the Java object this table schema object maps to
and from. |
T |
mapToItem(Map<String,AttributeValue> attributeMap)
Takes a raw DynamoDb SDK representation of a record in a table and maps it to a Java object.
|
TableMetadata |
tableMetadata()
Returns the object that describes the structure of the table being modelled by the mapper.
|
static <T> StaticTableSchema.Builder<T> builder(Class<T> itemClass)
StaticTableSchema
implementation of this interface which allows all attributes,
tags and table structure to be directly declared in the builder.T
- The type of the item this TableSchema
will map records to.itemClass
- The class of the item this TableSchema
will map records to.StaticTableSchema.Builder
.static <T> BeanTableSchema<T> fromBean(Class<T> beanClass)
BeanTableSchema
implementation of this interface that can map records to and from items of that bean
class.T
- The type of the item this TableSchema
will map records to.beanClass
- The bean class this TableSchema
will map records to.BeanTableSchema
.T mapToItem(Map<String,AttributeValue> attributeMap)
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.
attributeMap
- A map of String to AttributeValue
that contains all the raw attributes to map.IllegalArgumentException
- if any attributes in the map could not be mapped onto the new model object.Map<String,AttributeValue> itemToMap(T item, boolean ignoreNulls)
AttributeValue
that the DynamoDb low-level
SDK can work with.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 AttributeValue
of
type 'nul' to the output map.AttributeValue
representing all the modelled attributes in the model object.Map<String,AttributeValue> itemToMap(T item, Collection<String> attributes)
AttributeValue
that 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.item
- The modelled Java object to extract the map of attributes from.attributes
- A collection of attribute names to extract into the output map.AttributeValue
representing the requested modelled attributes in the model
object.AttributeValue attributeValue(T item, String key)
item
- The modelled Java object to extract the attribute from.key
- The attribute name describing which attribute to extract.AttributeValue
representing the requested modelled attribute in the model object or
null if the attribute has not been set with a value in the modelled object.TableMetadata tableMetadata()
TableMetadata
object that contains structural information about the table being modelled.EnhancedType<T> itemType()
EnhancedType
that represents the 'Type' of the Java object this table schema object maps to
and from.EnhancedType
of the modelled item this TableSchema maps to.Copyright © 2020. All rights reserved.