Class MapAttributeConverter<T extends Map<?,?>>

java.lang.Object
software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.MapAttributeConverter<T>
All Implemented Interfaces:
AttributeConverter<T>

@ThreadSafe @Immutable public class MapAttributeConverter<T extends Map<?,?>> extends Object implements AttributeConverter<T>
A converter between a specific Map type and AttributeValue.

This stores values in DynamoDB as a map from string to attribute value. This uses a configured StringAttributeConverter to convert the map keys to a string, and a configured AttributeConverter to convert the map values to an attribute value.

This supports reading maps from DynamoDB. This uses a configured StringAttributeConverter to convert the map keys, and a configured AttributeConverter to convert the map values.

A builder is exposed to allow defining how the map, key and value types are created and converted:

AttributeConverter<Map<MonthDay, String>> mapConverter = MapAttributeConverter.builder(EnhancedType.mapOf(Integer.class, String.class)) .mapConstructor(HashMap::new) .keyConverter(MonthDayStringConverter.create()) .valueConverter(StringAttributeConverter.create()) .build();

For frequently-used types, static methods are exposed to reduce the amount of boilerplate involved in creation: AttributeConverter<Map<MonthDay, String>> mapConverter = MapAttributeConverter.mapConverter(MonthDayStringConverter.create(), StringAttributeConverter.create());

AttributeConverter<SortedMap<MonthDay, String>> sortedMapConverter = MapAttributeConverter.sortedMapConverter(MonthDayStringConverter.create(), StringAttributeConverter.create());

See Also: