com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGenerated Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of aws-java-sdk-dynamodb Show documentation
                Show all versions of aws-java-sdk-dynamodb Show documentation
The AWS Java SDK for Amazon DynamoDB module holds the client classes that are used for communicating with Amazon DynamoDB Service
                
            /*
 * Copyright 2011-2016 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.
 * You may obtain a copy of the License at:
 *
 *    http://aws.amazon.com/apache2.0
 *
 * 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 com.amazonaws.services.dynamodbv2.datamodeling;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
 * Annotation to mark a property as using a custom auto-generator.
 *
 * May be annotated on a user-defined annotation to pass additional
 * properties to the {@link DynamoDBAutoGenerator}.
 *
 * 
 * @DynamoDBHashKey
 * @CustomGeneratedKey(prefix="test-") //<- user-defined annotation
 * public String getKey()
 * 
 *
 * Where,
 * 
 * @DynamoDBAutoGenerated(generator=CustomGeneratedKey.Generator.class)
 * @Retention(RetentionPolicy.RUNTIME)
 * @Target({ElementType.METHOD})
 * public @interface CustomGeneratedKey {
 *     String prefix() default "";
 *
 *     public static class Generator implements DynamoDBAutoGenerator<String> {
 *         private final String prefix;
 *         public Generator(final Class<String> targetType, final CustomGeneratedKey annotation) {
 *             this.prefix = annotation.prefix();
 *         }
 *         public Generator() { //<- required if annotating directly
 *             this.prefix = "";
 *         }
 *         @Override
 *         public DynamoDBAutoGenerateStrategy getGenerateStrategy() {
 *             return DynamoDBAutoGenerateStrategy.CREATE;
 *         }
 *         @Override
 *         public final String generate(final String currentValue) {
 *             return prefix + UUID.randomUUID.toString();
 *         }
 *     }
 * }
 * 
 *
 * Alternately, the property/field may be annotated directly (which requires
 * the generator to provide a default constructor),
 * 
 * @DynamoDBAutoGenerated(generator=CustomGeneratedKey.Generator.class)
 * public String getKey()
 * 
 *
 * May be used as a meta-annotation.
 */
@DynamoDB
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
public @interface DynamoDBAutoGenerated {
    /**
     * The auto-generator class for this property.
     */
    @SuppressWarnings("rawtypes")
    Class extends DynamoDBAutoGenerator> generator();
}
    © 2015 - 2025 Weber Informatics LLC | Privacy Policy