protected abstract class DynamoDBMapper.SaveObjectHandler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.Class<?> |
clazz |
private ItemConverter |
converter |
private java.util.List<DynamoDBMapper.ValueUpdate> |
inMemoryUpdates |
private java.util.Map<java.lang.String,ExpectedAttributeValue> |
internalExpectedValueAssertions
Any expected value conditions specified by the implementation of
DynamoDBMapper, e.g.
|
protected java.lang.Object |
object |
private java.util.Map<java.lang.String,AttributeValue> |
primaryKeys |
private DynamoDBMapperConfig |
saveConfig |
private java.lang.String |
tableName |
private java.util.Map<java.lang.String,AttributeValueUpdate> |
updateValues |
protected java.lang.String |
userProvidedConditionOperator
Condition operator on the additional expected value conditions
specified by the user.
|
protected java.util.Map<java.lang.String,ExpectedAttributeValue> |
userProvidedExpectedValueConditions
Additional expected value conditions specified by the user.
|
Constructor and Description |
---|
SaveObjectHandler(java.lang.Class<?> clazz,
java.lang.Object object,
java.lang.String tableName,
DynamoDBMapperConfig saveConfig,
ItemConverter converter,
DynamoDBSaveExpression saveExpression)
Constructs a handler for saving the specified model object.
|
Modifier and Type | Method and Description |
---|---|
protected PutItemResult |
doPutItem()
Save the item using a PutItem request.
|
protected UpdateItemResult |
doUpdateItem()
Save the item using a UpdateItem request.
|
void |
execute()
The general workflow of a save operation.
|
protected abstract void |
executeLowLevelRequest()
Implement this method to send the low-level request that is necessary
to complete the save operation.
|
protected java.util.Map<java.lang.String,AttributeValueUpdate> |
getAttributeValueUpdates()
Get the map of AttributeValueUpdate on each modeled attribute.
|
protected java.util.List<DynamoDBMapper.ValueUpdate> |
getInMemoryUpdates()
Get the list of all the necessary in-memory update on the object.
|
protected DynamoDBMapperConfig.SaveBehavior |
getLocalSaveBehavior()
Get the SaveBehavior used locally for this save operation.
|
protected java.util.Map<java.lang.String,AttributeValue> |
getPrimaryKeyAttributeValues()
Get the map of all the specified primamry keys of the saved object.
|
protected java.lang.String |
getTableName()
Get the table name
|
protected java.util.Map<java.lang.String,ExpectedAttributeValue> |
mergeExpectedAttributeValueConditions()
Merge and return all the expected value conditions (either
user-specified or imposed by the internal implementation of
DynamoDBMapper) for this save operation.
|
private void |
onAutoGenerate(DynamoDBMappingsRegistry.Mapping mapping,
java.lang.Object getterResult)
Auto-generates the attribute value.
|
private void |
onAutoGenerateAssignableKey(DynamoDBMappingsRegistry.Mapping mapping,
java.lang.Object getterResult)
Auto-generates the key.
|
protected void |
onNonKeyAttribute(java.lang.String attributeName,
AttributeValue currentValue)
Implement this method for necessary operations when a non-key
attribute is set a non-null value in the object.
|
protected abstract void |
onNullNonKeyAttribute(java.lang.String attributeName)
Implement this method for necessary operations when a non-key
attribute is set null in the object.
|
protected abstract void |
onPrimaryKeyAttributeValue(java.lang.String attributeName,
AttributeValue keyAttributeValue)
Implement this method to do the necessary operations when a primary key
attribute is set with some value.
|
private void |
onVersionAttribute(DynamoDBMappingsRegistry.Mapping mapping,
java.lang.Object getterResult)
Auto-generates the version.
|
protected final java.lang.Object object
protected final java.lang.Class<?> clazz
private final java.lang.String tableName
private final DynamoDBMapperConfig saveConfig
private final ItemConverter converter
private final java.util.Map<java.lang.String,AttributeValue> primaryKeys
private final java.util.Map<java.lang.String,AttributeValueUpdate> updateValues
private final java.util.Map<java.lang.String,ExpectedAttributeValue> internalExpectedValueAssertions
protected final java.util.Map<java.lang.String,ExpectedAttributeValue> userProvidedExpectedValueConditions
protected final java.lang.String userProvidedConditionOperator
private final java.util.List<DynamoDBMapper.ValueUpdate> inMemoryUpdates
public SaveObjectHandler(java.lang.Class<?> clazz, java.lang.Object object, java.lang.String tableName, DynamoDBMapperConfig saveConfig, ItemConverter converter, DynamoDBSaveExpression saveExpression)
object
- The model object to be saved.clazz
- The domain class of the object.tableName
- The table name.saveConifg
- The mapper configuration used for this save.saveExpression
- The save expression, including the user-provided conditions and an optional logic operator.public void execute()
protected abstract void onPrimaryKeyAttributeValue(java.lang.String attributeName, AttributeValue keyAttributeValue)
attributeName
- The name of the primary key attribute.keyAttributeValue
- The AttributeValue of the primary key attribute as specified in
the object.protected void onNonKeyAttribute(java.lang.String attributeName, AttributeValue currentValue)
attributeName
- The name of the non-key attribute.currentValue
- The updated value of the given attribute.protected abstract void onNullNonKeyAttribute(java.lang.String attributeName)
attributeName
- The name of the non-key attribute.protected abstract void executeLowLevelRequest()
protected DynamoDBMapperConfig.SaveBehavior getLocalSaveBehavior()
protected java.lang.String getTableName()
protected java.util.Map<java.lang.String,AttributeValue> getPrimaryKeyAttributeValues()
protected java.util.Map<java.lang.String,AttributeValueUpdate> getAttributeValueUpdates()
protected java.util.Map<java.lang.String,ExpectedAttributeValue> mergeExpectedAttributeValueConditions()
protected java.util.List<DynamoDBMapper.ValueUpdate> getInMemoryUpdates()
protected UpdateItemResult doUpdateItem()
The ReturnedValues parameter for the UpdateItem request is set as ALL_NEW, which means the service should return all of the attributes of the new version of the item after the update. The handler will use the returned attributes to detect silent failure on the server-side.
protected PutItemResult doPutItem()
private void onAutoGenerate(DynamoDBMappingsRegistry.Mapping mapping, java.lang.Object getterResult)
mapping
- The mapping details.getterResult
- The current attribute value.private void onAutoGenerateAssignableKey(DynamoDBMappingsRegistry.Mapping mapping, java.lang.Object getterResult)
mapping
- The mapping details.getterResult
- The current attribute value.private void onVersionAttribute(DynamoDBMappingsRegistry.Mapping mapping, java.lang.Object getterResult)
mapping
- The mapping details.getterResult
- The current attribute value.