1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 package software.amazon.awssdk.enhanced.dynamodb;
17 
18 import software.amazon.awssdk.annotations.SdkPublicApi;
19 import software.amazon.awssdk.annotations.ThreadSafe;
20 
21 /**
22  * Interface for a resource object that is part of either a {@link DynamoDbTable} or {@link DynamoDbAsyncTable}. This
23  * part of the interface is common between both of those higher order interfaces and has methods to access the
24  * metadata associated with the mapped entity, such as the schema and the table name, but knows nothing about how to
25  * actually execute operations against it.
26  *
27  * @param <T> The type of the modelled object.
28  */
29 @SdkPublicApi
30 @ThreadSafe
31 public interface MappedTableResource<T> {
32     /**
33      * Gets the {@link DynamoDbEnhancedClientExtension} associated with this mapped resource.
34      * @return The {@link DynamoDbEnhancedClientExtension} associated with this mapped resource.
35      */
mapperExtension()36     DynamoDbEnhancedClientExtension mapperExtension();
37 
38     /**
39      * Gets the {@link TableSchema} object that this mapped table was built with.
40      * @return The {@link TableSchema} object for this mapped table.
41      */
tableSchema()42     TableSchema<T> tableSchema();
43 
44     /**
45      * Gets the physical table name that operations performed by this object will be executed against.
46      * @return The physical table name.
47      */
tableName()48     String tableName();
49 
50     /**
51      * Creates a {@link Key} object from a modelled item. This key can be used in query conditionals and get
52      * operations to locate a specific record.
53      * @param item The item to extract the key fields from.
54      * @return A key that has been initialized with the index values extracted from the modelled object.
55      */
keyFrom(T item)56     Key keyFrom(T item);
57 }
58