Class 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.
StaticImmutableTableSchema composes
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 -
Method Summary
Modifier and TypeMethodDescriptionA customAttributeConverterthat will be used to convert this attribute.static <T,B, R> ImmutableAttribute.Builder <T, B, R> 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.getter()A function that can get the value of this attribute from a modelled immutable item it composes.name()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.tags()A collection ofStaticAttributeTagassociated with this attribute.Converts an instance of this class to aImmutableAttribute.Builderthat can be used to modify and reconstruct it.type()AEnhancedTypethat represents the type of the value this attribute stores.
-
Method Details
-
builder
public static <T,B, ImmutableAttribute.Builder<T,R> B, builderR> (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, ImmutableAttribute.Builder<T,R> B, builderR> (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, ImmutableAttribute.Builder<T,R> B, builderR> (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
The name of this attribute -
getter
-
setter
A function that can set the value of this attribute on a builder for the immutable modelled item it composes. -
tags
A collection ofStaticAttributeTagassociated with this attribute. -
type
AEnhancedTypethat represents the type of the value this attribute stores. -
attributeConverter
A customAttributeConverterthat 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 aImmutableAttribute.Builderthat can be used to modify and reconstruct it.
-