T
- The type of object that this TableSchema
maps to.public final class ImmutableTableSchema<T> extends WrappedTableSchema<T,StaticImmutableTableSchema<T,?>>
TableSchema
that builds a table schema based on properties and annotations of an immutable
class with an associated builder class. Example:
@DynamoDbImmutable(builder = Customer.Builder.class)
public class Customer {
@DynamoDbPartitionKey
public String accountId() { ... }
@DynamoDbSortKey
public int subId() { ... }
// Defines a GSI (customers_by_name) with a partition key of 'name'
@DynamoDbSecondaryPartitionKey(indexNames = "customers_by_name")
public String name() { ... }
// Defines an LSI (customers_by_date) with a sort key of 'createdDate' and also declares the
// same attribute as a sort key for the GSI named 'customers_by_name'
@DynamoDbSecondarySortKey(indexNames = {"customers_by_date", "customers_by_name"})
public Instant createdDate() { ... }
// Not required to be an inner-class, but builders often are
public static final class Builder {
public Builder accountId(String accountId) { ... };
public Builder subId(int subId) { ... };
public Builder name(String name) { ... };
public Builder createdDate(Instant createdDate) { ... };
public Customer build() { ... };
}
}
Creating an ImmutableTableSchema
is a moderately expensive operation, and should be performed sparingly. This is
usually done once at application startup.Modifier and Type | Method and Description |
---|---|
static <T> ImmutableTableSchema<T> |
create(Class<T> immutableClass)
Scans an immutable class and builds an
ImmutableTableSchema from it that can be used with the
DynamoDbEnhancedClient . |
attributeNames, attributeValue, delegateTableSchema, isAbstract, itemToMap, itemToMap, itemType, mapToItem, tableMetadata
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
builder, builder, fromBean, fromClass, fromImmutableClass
public static <T> ImmutableTableSchema<T> create(Class<T> immutableClass)
ImmutableTableSchema
from it that can be used with the
DynamoDbEnhancedClient
.
Creating an ImmutableTableSchema
is a moderately expensive operation, and should be performed sparingly. This is
usually done once at application startup.T
- The immutable class type.immutableClass
- The annotated immutable class to build the table schema from.ImmutableTableSchema
Copyright © 2021. All rights reserved.