SimpleItemConverter

class SimpleItemConverter<T, B>(builderFactory: () -> B, build: B.() -> T, descriptors: AttributeDescriptor<*, T, B>, unknownValueHandling: UnknownValueHandling<B> = UnknownValueHandling.Ignore) : Converter<T, Item>

An item converter which uses attribute descriptors to convert objects to items and vice versa. This converter distinguishes between the object type used for conversion into an item (treated as immutable) and a mutable builder type used for conversion from an item. Note that these do not have to be different types if the object type is already mutable.

Parameters

builderFactory

A function which returns a new, default-valued builder object. This is invoked once for every item which must be converted to an object.

build

A method which builds a builder object of type B into its final representation of type T. If B and T are the same type, this may be an identity function.

descriptors

A collection of AttributeDescriptor which describe how to construct and parse attributes

unknownValueHandling

Identifies how to handle attributes whose keys do not appear in the descriptors list. The default value is UnknownValueHandling.Ignore, which will silently ignore unknown attributes.

Type Parameters

T

The type of objects which will be converted to items. This converter treats type T as immutable.

B

The type of builders which will be used when converting from items.

Constructors

Link copied to clipboard
constructor(builderFactory: () -> B, build: B.() -> T, vararg descriptors: AttributeDescriptor<*, T, B>, unknownValueHandling: UnknownValueHandling<B> = UnknownValueHandling.Ignore)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun convertLeft(from: Item): T
Link copied to clipboard
open override fun convertRight(from: T): Item

Inherited functions

Link copied to clipboard
fun <V : Any> ValueConverter<V>.asNullable(nullValueConverter: ValueConverter<Nothing?> = NullValueConverter): ValueConverter<V?>
Link copied to clipboard
fun <T, PK : KeyType> ItemConverter<T>.withKeySpec(partitionKey: KeySpec<PK>, attributes: Attributes = emptyAttributes()): ItemSchema.PartitionKey<T, PK>

Associate this ItemConverter with a KeySpec for a partition key to form a complete ItemSchema

fun <T, PK : KeyType, SK : KeyType> ItemConverter<T>.withKeySpec(partitionKey: KeySpec<PK>, sortKey: KeySpec<SK>, attributes: Attributes = emptyAttributes()): ItemSchema.CompositeKey<T, PK, SK>

Associate this ItemConverter with KeySpec instances for a composite key to form a complete ItemSchema