Class ImmutableAttribute<T,B,R>
- java.lang.Object
-
- software.amazon.awssdk.enhanced.dynamodb.mapper.ImmutableAttribute<T,B,R>
-
- Type Parameters:
T- the class of the immutable item this attribute maps into.B- the class of the builder for the immutable item this attribute maps into.R- the class that the value of this attribute converts to.
@ThreadSafe public final class ImmutableAttribute<T,B,R> extends Object
A class that represents an attribute on an mapped immutable item. AStaticImmutableTableSchemacomposes multiple attributes that map to a common immutable item class.The recommended way to use this class is by calling
TableSchema.builder(Class, Class). Example:TableSchema.builder(Customer.class, Customer.Builder.class) .addAttribute(String.class, a -> a.name("customer_name").getter(Customer::name).setter(Customer.Builder::name)) // ... .build();It's also possible to construct this class on its own using the static builder. Example:
ImmutableAttribute<Customer, Customer.Builder, ?> customerNameAttribute = ImmutableAttribute.builder(Customer.class, Customer.Builder.class, String.class) .name("customer_name") .getter(Customer::name) .setter(Customer.Builder::name) .build();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableAttribute.Builder<T,B,R>A typed builder forImmutableAttribute.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeConverter<R>attributeConverter()A customAttributeConverterthat will be used to convert this attribute.static <T,B,R>
ImmutableAttribute.Builder<T,B,R>builder(Class<T> itemClass, Class<B> builderClass, Class<R> attributeClass)Constructs a new builder for this class using supplied types.static <T,B,R>
ImmutableAttribute.Builder<T,B,R>builder(Class<T> itemClass, Class<B> builderClass, EnhancedType<R> attributeType)Constructs a new builder for this class using supplied types.static <T,B,R>
ImmutableAttribute.Builder<T,B,R>builder(EnhancedType<T> itemType, EnhancedType<B> builderType, 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 immutable item it composes.Stringname()The name of this attributeBiConsumer<B,R>setter()A function that can set the value of this attribute on a builder for the immutable modelled item it composes.Collection<StaticAttributeTag>tags()A collection ofStaticAttributeTagassociated with this attribute.ImmutableAttribute.Builder<T,B,R>toBuilder()Converts an instance of this class to aImmutableAttribute.Builderthat can be used to modify and reconstruct it.EnhancedType<R>type()AEnhancedTypethat represents the type of the value this attribute stores.
-
-
-
Method Detail
-
builder
public static <T,B,R> ImmutableAttribute.Builder<T,B,R> builder(Class<T> itemClass, Class<B> builderClass, EnhancedType<R> attributeType)
Constructs a new builder for this class using supplied types.- Parameters:
itemClass- The class of the immutable item that this attribute composes.builderClass- The class of the builder for the immutable item that this attribute composes.attributeType- AEnhancedTypethat represents the type of the value this attribute stores.- Returns:
- A new typed builder for an attribute.
-
builder
public static <T,B,R> ImmutableAttribute.Builder<T,B,R> builder(EnhancedType<T> itemType, EnhancedType<B> builderType, EnhancedType<R> attributeType)
Constructs a new builder for this class using supplied types.- Parameters:
itemType- TheEnhancedTypeof the immutable item that this attribute composes.builderType- TheEnhancedTypeof the builder for the immutable item that this attribute composes.attributeType- AEnhancedTypethat represents the type of the value this attribute stores.- Returns:
- A new typed builder for an attribute.
-
builder
public static <T,B,R> ImmutableAttribute.Builder<T,B,R> builder(Class<T> itemClass, Class<B> builderClass, Class<R> attributeClass)
Constructs a new builder for this class using supplied types.- Parameters:
itemClass- The class of the item that this attribute composes.builderClass- The class of the builder for the immutable 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 immutable item it composes.
-
setter
public BiConsumer<B,R> setter()
A function that can set the value of this attribute on a builder for the immutable modelled item it composes.
-
tags
public Collection<StaticAttributeTag> tags()
A collection ofStaticAttributeTagassociated with this attribute.
-
type
public EnhancedType<R> type()
AEnhancedTypethat represents the type of the value this attribute stores.
-
attributeConverter
public AttributeConverter<R> attributeConverter()
A customAttributeConverterthat will be used to convert this attribute. If no custom converter was provided, the value will be null.- See Also:
ImmutableAttribute.Builder.attributeConverter
-
toBuilder
public ImmutableAttribute.Builder<T,B,R> toBuilder()
Converts an instance of this class to aImmutableAttribute.Builderthat can be used to modify and reconstruct it.
-
-