Interface CommonOperation<ItemT,RequestT,ResponseT,ResultT>
-
- Type Parameters:
ItemT- The modelled object that this table maps records to.RequestT- The type of the request object for the DynamoDb call in the low levelDynamoDbClientorDynamoDbAsyncClient.ResponseT- The type of the response object for the DynamoDb call in the low levelDynamoDbClientorDynamoDbAsyncClient.ResultT- The type of the mapped result object that will be returned by the execution of this operation.
- All Known Subinterfaces:
IndexOperation<ItemT,RequestT,ResponseT,ResultT>,TableOperation<ItemT,RequestT,ResponseT,ResultT>
- All Known Implementing Classes:
CreateTableOperation,DeleteItemOperation,DeleteTableOperation,DescribeTableOperation,GetItemOperation,PutItemOperation,UpdateItemOperation
public interface CommonOperation<ItemT,RequestT,ResponseT,ResultT>Common interface for a single operation that can be executed in a synchronous or non-blocking asynchronous fashion against a mapped database table. These operations can be made against either the primary index of a table or a secondary index, although some implementations of this interface do not support secondary indices and will throw an exception when executed against one. Conceptually an operation maps 1:1 with an actual DynamoDb call.This interface is extended by
TableOperationandIndexOperationwhich contain implementations of the behavior to actually execute the operation in the context of a table or secondary index and are used byDynamoDbTableorDynamoDbAsyncTableandDynamoDbIndexorDynamoDbAsyncIndexrespectively. By sharing this common interface operations are able to re-use code regardless of whether they are executed in the context of a primary or secondary index or whether they are being executed in a synchronous or non-blocking asynchronous fashion.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Function<RequestT,CompletableFuture<ResponseT>>asyncServiceCall(DynamoDbAsyncClient dynamoDbAsyncClient)Provides a function for making the low level non-blocking asynchronous SDK call to DynamoDb.default ResultTexecute(TableSchema<ItemT> tableSchema, OperationContext context, DynamoDbEnhancedClientExtension extension, DynamoDbClient dynamoDbClient)Default implementation of a complete synchronous execution of this operation against either the primary or a secondary index.default CompletableFuture<ResultT>executeAsync(TableSchema<ItemT> tableSchema, OperationContext context, DynamoDbEnhancedClientExtension extension, DynamoDbAsyncClient dynamoDbAsyncClient)Default implementation of a complete non-blocking asynchronous execution of this operation against either the primary or a secondary index.RequestTgenerateRequest(TableSchema<ItemT> tableSchema, OperationContext context, DynamoDbEnhancedClientExtension extension)This method generates the request that needs to be sent to a low levelDynamoDbClient.OperationNameoperationName()The type, or name, of the operation.Function<RequestT,ResponseT>serviceCall(DynamoDbClient dynamoDbClient)Provides a function for making the low level synchronous SDK call to DynamoDb.ResultTtransformResponse(ResponseT response, TableSchema<ItemT> tableSchema, OperationContext context, DynamoDbEnhancedClientExtension extension)Takes the response object returned by the actual DynamoDb call and maps it into a higher level abstracted result object.
-
-
-
Method Detail
-
generateRequest
RequestT generateRequest(TableSchema<ItemT> tableSchema, OperationContext context, DynamoDbEnhancedClientExtension extension)
This method generates the request that needs to be sent to a low levelDynamoDbClient.- Parameters:
tableSchema- ATableSchemathat maps the table to a modelled object.context- An object containing the context, or target, of the command execution.extension- ADynamoDbEnhancedClientExtensionthat may modify the request of this operation. A null value here will result in no modifications.- Returns:
- A request that can be used as an argument to a
DynamoDbClientcall to perform the operation.
-
serviceCall
Function<RequestT,ResponseT> serviceCall(DynamoDbClient dynamoDbClient)
Provides a function for making the low level synchronous SDK call to DynamoDb.- Parameters:
dynamoDbClient- A low levelDynamoDbClientto make the call against.- Returns:
- A function that calls DynamoDb with a provided request object and returns the response object.
-
asyncServiceCall
Function<RequestT,CompletableFuture<ResponseT>> asyncServiceCall(DynamoDbAsyncClient dynamoDbAsyncClient)
Provides a function for making the low level non-blocking asynchronous SDK call to DynamoDb.- Parameters:
dynamoDbAsyncClient- A low levelDynamoDbAsyncClientto make the call against.- Returns:
- A function that calls DynamoDb with a provided request object and returns the response object.
-
transformResponse
ResultT transformResponse(ResponseT response, TableSchema<ItemT> tableSchema, OperationContext context, DynamoDbEnhancedClientExtension extension)
Takes the response object returned by the actual DynamoDb call and maps it into a higher level abstracted result object.- Parameters:
response- The response object returned by the DynamoDb call for this operation.tableSchema- ATableSchemathat maps the table to a modelled object.context- An object containing the context, or target, of the command execution.extension- ADynamoDbEnhancedClientExtensionthat may modify the result of this operation. A null value here will result in no modifications.- Returns:
- A high level result object as specified by the implementation of this operation.
-
execute
default ResultT execute(TableSchema<ItemT> tableSchema, OperationContext context, DynamoDbEnhancedClientExtension extension, DynamoDbClient dynamoDbClient)
Default implementation of a complete synchronous execution of this operation against either the primary or a secondary index. It performs three steps: 1) Call generateRequest() to get the request object. 2) Call getServiceCall() and call it using the request object generated in the previous step. 3) Call transformResponse() to convert the response object returned in the previous step to a high level result.- Parameters:
tableSchema- ATableSchemathat maps the table to a modelled object.context- An object containing the context, or target, of the command execution.dynamoDbClient- ADynamoDbClientto make the call against.extension- ADynamoDbEnhancedClientExtensionthat may modify the request or result of this operation. A null value here will result in no modifications.- Returns:
- A high level result object as specified by the implementation of this operation.
-
executeAsync
default CompletableFuture<ResultT> executeAsync(TableSchema<ItemT> tableSchema, OperationContext context, DynamoDbEnhancedClientExtension extension, DynamoDbAsyncClient dynamoDbAsyncClient)
Default implementation of a complete non-blocking asynchronous execution of this operation against either the primary or a secondary index. It performs three steps: 1) Call generateRequest() to get the request object. 2) Call getServiceCall() and call it using the request object generated in the previous step. 3) Wraps theCompletableFuturereturned by the SDK in a new one that calls transformResponse() to convert the response object returned in the previous step to a high level result.- Parameters:
tableSchema- ATableSchemathat maps the table to a modelled object.context- An object containing the context, or target, of the command execution.dynamoDbAsyncClient- ADynamoDbAsyncClientto make the call against.extension- ADynamoDbEnhancedClientExtensionthat may modify the request or result of this operation. A null value here will result in no modifications.- Returns:
- A
CompletableFutureof the high level result object as specified by the implementation of this operation.
-
operationName
OperationName operationName()
The type, or name, of the operation.
-
-