Class WrappedTableSchema<T,​R extends TableSchema<T>>

    • Constructor Detail

      • WrappedTableSchema

        protected WrappedTableSchema​(R delegateTableSchema)
        Standard constructor.
        Parameters:
        delegateTableSchema - An instance of TableSchema to be wrapped and proxied by this class.
    • Method Detail

      • delegateTableSchema

        protected R delegateTableSchema()
        The delegate table schema that is wrapped and proxied by this class.
      • mapToItem

        public T mapToItem​(Map<String,​AttributeValue> attributeMap)
        Description copied from interface: TableSchema
        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 TableSchema.mapToItem(Map, boolean) instead if you need to preserve empty object.

        API Implementors Note:

        TableSchema.mapToItem(Map, boolean) must be implemented if preserveEmptyObject behavior is desired.

        Specified by:
        mapToItem in interface TableSchema<T>
        Parameters:
        attributeMap - A map of String to AttributeValue that contains all the raw attributes to map.
        Returns:
        A new instance of a Java object with all the attributes mapped onto it.
        See Also:
        TableSchema.mapToItem(Map, boolean)
      • mapToItem

        public T mapToItem​(Map<String,​AttributeValue> attributeMap,
                           boolean preserveEmptyObject)
        Description copied from interface: TableSchema
        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 preserveEmptyObject is true. If it's false, an empty object will be returned.

        Note that preserveEmptyObject only applies to the top level Java object, if it has nested "empty" objects, they will be mapped as null. You can use DynamoDbPreserveEmptyObject to configure this behavior for nested objects.

        API Implementors Note:

        This method must be implemented if preserveEmptyObject behavior is to be supported

        Specified by:
        mapToItem in interface TableSchema<T>
        Parameters:
        attributeMap - A map of String to AttributeValue that 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.
        See Also:
        TableSchema.mapToItem(Map)
      • itemToMap

        public Map<String,​AttributeValue> itemToMap​(T item,
                                                          boolean ignoreNulls)
        Description copied from interface: TableSchema
        Takes a modelled object and converts it into a raw map of AttributeValue that the DynamoDb low-level SDK can work with.
        Specified by:
        itemToMap in interface TableSchema<T>
        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 AttributeValue of type 'nul' to the output map.
        Returns:
        A map of String to AttributeValue representing all the modelled attributes in the model object.
      • itemToMap

        public Map<String,​AttributeValue> itemToMap​(T item,
                                                          Collection<String> attributes)
        Description copied from interface: TableSchema
        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. This method is typically used to extract just the key attributes of a modelled item and will not ignore nulls on the modelled object.
        Specified by:
        itemToMap in interface TableSchema<T>
        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 AttributeValue representing the requested modelled attributes in the model object.
      • attributeValue

        public AttributeValue attributeValue​(T item,
                                             String attributeName)
        Description copied from interface: TableSchema
        Returns a single attribute value from the modelled object.
        Specified by:
        attributeValue in interface TableSchema<T>
        Parameters:
        item - The modelled Java object to extract the attribute from.
        attributeName - The attribute name describing which attribute to extract.
        Returns:
        A single 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

        public TableMetadata tableMetadata()
        Description copied from interface: TableSchema
        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.
        Specified by:
        tableMetadata in interface TableSchema<T>
        Returns:
        A TableMetadata object that contains structural information about the table being modelled.
      • isAbstract

        public boolean isAbstract()
        Description copied from interface: TableSchema
        A boolean value that represents whether this TableSchema is 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.
        Specified by:
        isAbstract in interface TableSchema<T>
        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.