• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.mapper;
17 
18 import software.amazon.awssdk.annotations.SdkPublicApi;
19 import software.amazon.awssdk.annotations.ThreadSafe;
20 
21 /**
22  * Update behaviors that can be applied to individual attributes. This behavior will only apply to 'update' operations
23  * such as UpdateItem, and not 'put' operations such as PutItem.
24  * <p>
25  * If an update behavior is not specified for an attribute, the default behavior of {@link #WRITE_ALWAYS} will be
26  * applied.
27  */
28 @SdkPublicApi
29 @ThreadSafe
30 public enum UpdateBehavior {
31     /**
32      * Always overwrite with the new value if one is provided, or remove any existing value if a null value is
33      * provided and 'ignoreNulls' is set to false.
34      * <p>
35      * This is the default behavior applied to all attributes unless otherwise specified.
36      */
37     WRITE_ALWAYS,
38 
39     /**
40      * Write the new value if there is no existing value in the persisted record or a new record is being written,
41      * otherwise leave the existing value.
42      * <p>
43      * IMPORTANT: If a null value is provided and 'ignoreNulls' is set to false, the attribute
44      * will always be removed from the persisted record as DynamoDb does not support conditional removal with this
45      * method.
46      */
47     WRITE_IF_NOT_EXISTS
48 }
49