All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean Maven / Gradle / Ivy

/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

package software.amazon.awssdk.enhanced.dynamodb.mapper.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.enhanced.dynamodb.AttributeConverter;
import software.amazon.awssdk.enhanced.dynamodb.AttributeConverterProvider;
import software.amazon.awssdk.enhanced.dynamodb.DefaultAttributeConverterProvider;
import software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema;

/**
 * Class level annotation that identifies this class as being a DynamoDb mappable entity. Any class used to initialize
 * a {@link BeanTableSchema} must have this annotation. If a class is used as an attribute type within another
 * annotated DynamoDb class, either as a document or flattened with the {@link DynamoDbFlatten} annotation, it will also
 * require this annotation to work automatically without an explicit {@link AttributeConverter}.
 * 

* Attribute Converter Providers
* Using {@link AttributeConverterProvider}s is optional and, if used, the supplied provider supersedes the default * converter provided by the table schema. *

* Note: *

    *
  • The converter(s) must provide {@link AttributeConverter}s for all types used in the schema.
  • *
  • The table schema DefaultAttributeConverterProvider provides standard converters for most primitive * and common Java types. Use custom AttributeConverterProviders when you have specific needs for type conversion * that the defaults do not cover.
  • *
  • If you provide a list of attribute converter providers, you can add DefaultAttributeConverterProvider * to the end of the list to fall back on the defaults.
  • *
  • Providing an empty list {} will cause no providers to get loaded.
  • *
* * Example using attribute converter providers with one custom provider and the default provider: *
 * {@code
 * (converterProviders = {CustomAttributeConverter.class, DefaultAttributeConverterProvider.class});
 * }
 * 
*

* Example using {@link DynamoDbBean}: *

 * {@code
 * @DynamoDbBean
 * public class Customer {
 *     private String id;
 *     private Instant createdOn;
 *
 *     @DynamoDbPartitionKey
 *     public String getId() {
 *          return this.id;
 *     }
 *
 *     public void setId(String id) {
 *          this.id = id;
 *     }
 *
 *     public Instant getCreatedOn() {
 *          return this.createdOn;
 *     }
 *     public void setCreatedOn(Instant createdOn) {
 *          this.createdOn = createdOn;
 *      }
 * }
 * }
 * 
*/ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @SdkPublicApi public @interface DynamoDbBean { Class[] converterProviders() default { DefaultAttributeConverterProvider.class }; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy