Class StaticAttribute<T,R>
java.lang.Object
software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttribute<T,R>
- Type Parameters:
T
- the class of the item this attribute maps into.R
- the class that the value of this attribute converts to.
A class that represents an attribute that can be read from and written to an mapped item. A
StaticTableSchema
composes multiple attributes that map to a common item class.
The recommended way to use this class is by calling StaticTableSchema.Builder.addAttribute(Class, Consumer)
.
Example:
StaticTableSchema.builder()
.addAttribute(String.class,
a -> a.name("customer_name").getter(Customer::getName).setter(Customer::setName))
// ...
.build();
It's also possible to construct this class on its own using the static builder. Example:
StaticAttribute<Customer, ?> customerNameAttribute =
StaticAttribute.builder(Customer.class, String.class)
.name("customer_name")
.getter(Customer::getName)
.setter(Customer::setName)
.build();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionA customAttributeConverter
that will be used to convert this attribute.static <T,
R> StaticAttribute.Builder <T, R> Constructs a new builder for this class using supplied types.static <T,
R> StaticAttribute.Builder <T, R> builder
(Class<T> itemClass, EnhancedType<R> attributeType) Constructs a new builder for this class using supplied types.static <T,
R> StaticAttribute.Builder <T, R> builder
(EnhancedType<T> itemType, EnhancedType<R> attributeType) Constructs a new builder for this class using supplied types.getter()
A function that can get the value of this attribute from a modelled item it composes.name()
The name of this attributeBiConsumer
<T, R> setter()
A function that can set the value of this attribute on a modelled item it composes.tags()
A collection ofStaticAttributeTag
associated with this attribute.Converts an instance of this class to aStaticAttribute.Builder
that can be used to modify and reconstruct it.type()
AEnhancedType
that represents the type of the value this attribute stores.
-
Method Details
-
builder
public static <T,R> StaticAttribute.Builder<T,R> builder(Class<T> itemClass, EnhancedType<R> attributeType) Constructs a new builder for this class using supplied types.- Parameters:
itemClass
- The class of the item that this attribute composes.attributeType
- AEnhancedType
that represents the type of the value this attribute stores.- Returns:
- A new typed builder for an attribute.
-
builder
public static <T,R> StaticAttribute.Builder<T,R> builder(EnhancedType<T> itemType, EnhancedType<R> attributeType) Constructs a new builder for this class using supplied types.- Parameters:
itemType
- TheEnhancedType
of the item that this attribute composes.attributeType
- AEnhancedType
that represents the type of the value this attribute stores.- Returns:
- A new typed builder for an attribute.
-
builder
public static <T,R> StaticAttribute.Builder<T,R> builder(Class<T> itemClass, Class<R> attributeClass) Constructs a new builder for this class using supplied types.- Parameters:
itemClass
- The class of the item that this attribute composes.attributeClass
- A class that represents the type of the value this attribute stores.- Returns:
- A new typed builder for an attribute.
-
name
The name of this attribute -
getter
A function that can get the value of this attribute from a modelled item it composes. -
setter
A function that can set the value of this attribute on a modelled item it composes. -
tags
A collection ofStaticAttributeTag
associated with this attribute. -
type
AEnhancedType
that represents the type of the value this attribute stores. -
attributeConverter
A customAttributeConverter
that will be used to convert this attribute. If no custom converter was provided, the value will be null.- See Also:
-
toBuilder
Converts an instance of this class to aStaticAttribute.Builder
that can be used to modify and reconstruct it.
-