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.
@ThreadSafe public final class StaticAttribute<T,R> extends Object
A class that represents an attribute that can be read from and written to an mapped item. AStaticTableSchema
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 Modifier and Type Class Description static class
StaticAttribute.Builder<T,R>
A typed builder forStaticAttribute
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeConverter<R>
attributeConverter()
A customAttributeConverter
that will be used to convert this attribute.static <T,R>
StaticAttribute.Builder<T,R>builder(Class<T> itemClass, Class<R> attributeClass)
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.Function<T,R>
getter()
A function that can get the value of this attribute from a modelled item it composes.String
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.Collection<StaticAttributeTag>
tags()
A collection ofStaticAttributeTag
associated with this attribute.StaticAttribute.Builder<T,R>
toBuilder()
Converts an instance of this class to aStaticAttribute.Builder
that can be used to modify and reconstruct it.EnhancedType<R>
type()
AEnhancedType
that represents the type of the value this attribute stores.
-
-
-
Method Detail
-
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
public String name()
The name of this attribute
-
getter
public Function<T,R> getter()
A function that can get the value of this attribute from a modelled item it composes.
-
setter
public BiConsumer<T,R> setter()
A function that can set the value of this attribute on a modelled item it composes.
-
tags
public Collection<StaticAttributeTag> tags()
A collection ofStaticAttributeTag
associated with this attribute.
-
type
public EnhancedType<R> type()
AEnhancedType
that represents the type of the value this attribute stores.
-
attributeConverter
public AttributeConverter<R> attributeConverter()
A customAttributeConverter
that will be used to convert this attribute. If no custom converter was provided, the value will be null.
-
toBuilder
public StaticAttribute.Builder<T,R> toBuilder()
Converts an instance of this class to aStaticAttribute.Builder
that can be used to modify and reconstruct it.
-
-