Class StaticTableMetadata
- java.lang.Object
-
- software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableMetadata
-
- All Implemented Interfaces:
TableMetadata
@ThreadSafe public final class StaticTableMetadata extends Object implements TableMetadata
Implementation ofTableMetadata
that can be constructed directly using literal values for metadata objects. This implementation is used byStaticTableSchema
and associated interfaces such asStaticAttributeTag
andStaticTableTag
which permit manipulation of the table metadata.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StaticTableMetadata.Builder
Builder forStaticTableMetadata
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<String>
allKeys()
Returns all the names of attributes associated with any index (primary or secondary) known for this table.static StaticTableMetadata.Builder
builder()
Create a new builder for this classMap<String,Object>
customMetadata()
Returns all custom metadata for this table.<T> Optional<T>
customMetadataObject(String key, Class<? extends T> objectClass)
Returns a custom metadata object.boolean
equals(Object o)
int
hashCode()
Collection<String>
indexKeys(String indexName)
Returns all the names of attributes associated with the keys of a specified index.String
indexPartitionKey(String indexName)
Returns the attribute name of the partition key for an index.Optional<String>
indexSortKey(String indexName)
Returns the attribute name of the sort key for an index.Collection<IndexMetadata>
indices()
Returns metadata about all the known indices for this table.Collection<KeyAttributeMetadata>
keyAttributes()
Returns metadata about all the known 'key' attributes for this table, such as primary and secondary index keys, or any other attribute that forms part of the structure of the table.Optional<ScalarAttributeType>
scalarAttributeType(String keyAttribute)
Returns the DynamoDb scalar attribute type associated with a key attribute if one is applicable.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface software.amazon.awssdk.enhanced.dynamodb.TableMetadata
primaryKeys, primaryPartitionKey, primarySortKey
-
-
-
-
Method Detail
-
builder
public static StaticTableMetadata.Builder builder()
Create a new builder for this class- Returns:
- A newly initialized
StaticTableMetadata.Builder
for building aStaticTableMetadata
object.
-
customMetadataObject
public <T> Optional<T> customMetadataObject(String key, Class<? extends T> objectClass)
Description copied from interface:TableMetadata
Returns a custom metadata object. These objects are used by extensions to the library, therefore the type of object stored is flexible and does not need to be known by the interface.- Specified by:
customMetadataObject
in interfaceTableMetadata
- Type Parameters:
T
- The flexible type for the object being returned. The compiler will typically infer this.- Parameters:
key
- A unique key for the metadata object. This namespace is shared by all extensions, so it is recommended best practice to qualify it with the name of your extension.objectClass
- The java class that the object will be cast to before returning. An exception will be thrown if the stored object cannot be cast to this class.- Returns:
- An optional containing custom metadata object or empty if the object was not found.
-
indexPartitionKey
public String indexPartitionKey(String indexName)
Description copied from interface:TableMetadata
Returns the attribute name of the partition key for an index.- Specified by:
indexPartitionKey
in interfaceTableMetadata
- Parameters:
indexName
- The name of the index.- Returns:
- The attribute name representing the partition key for this index.
-
indexSortKey
public Optional<String> indexSortKey(String indexName)
Description copied from interface:TableMetadata
Returns the attribute name of the sort key for an index.- Specified by:
indexSortKey
in interfaceTableMetadata
- Parameters:
indexName
- The name of the index.- Returns:
- Optional of the attribute name representing the sort key for this index; empty if the index does not have a sort key.
-
indexKeys
public Collection<String> indexKeys(String indexName)
Description copied from interface:TableMetadata
Returns all the names of attributes associated with the keys of a specified index.- Specified by:
indexKeys
in interfaceTableMetadata
- Parameters:
indexName
- The name of the index.- Returns:
- A collection of all key attribute names for that index.
-
allKeys
public Collection<String> allKeys()
Description copied from interface:TableMetadata
Returns all the names of attributes associated with any index (primary or secondary) known for this table. Additionally any additional attributes that are deemed to be 'key-like' in how they should be treated will also be returned. An example of a 'key-like' attribute that is not actually a key is one tagged as a 'version' attribute when using the versioned record extension.- Specified by:
allKeys
in interfaceTableMetadata
- Returns:
- A collection of all key attribute names for the table.
-
indices
public Collection<IndexMetadata> indices()
Description copied from interface:TableMetadata
Returns metadata about all the known indices for this table.- Specified by:
indices
in interfaceTableMetadata
- Returns:
- A collection of
IndexMetadata
containing information about the indices.
-
customMetadata
public Map<String,Object> customMetadata()
Description copied from interface:TableMetadata
Returns all custom metadata for this table. These entries are used by extensions to the library, therefore the value type of each metadata object stored in the map is not known and is provided asObject
.This method should not be used to inspect individual custom metadata objects, instead use
TableMetadata.customMetadataObject(String, Class)
()} as that will perform a type-safety check on the retrieved object.- Specified by:
customMetadata
in interfaceTableMetadata
- Returns:
- A map of all the custom metadata for this table.
-
keyAttributes
public Collection<KeyAttributeMetadata> keyAttributes()
Description copied from interface:TableMetadata
Returns metadata about all the known 'key' attributes for this table, such as primary and secondary index keys, or any other attribute that forms part of the structure of the table.- Specified by:
keyAttributes
in interfaceTableMetadata
- Returns:
- A collection of
KeyAttributeMetadata
containing information about the keys.
-
scalarAttributeType
public Optional<ScalarAttributeType> scalarAttributeType(String keyAttribute)
Description copied from interface:TableMetadata
Returns the DynamoDb scalar attribute type associated with a key attribute if one is applicable.- Specified by:
scalarAttributeType
in interfaceTableMetadata
- Parameters:
keyAttribute
- The key attribute name to return the scalar attribute type of.- Returns:
- Optional
ScalarAttributeType
of the attribute, or empty if attribute is a non-scalar type.
-
-