public static void createLockTableInDynamoDB()

in src/main/java/com/amazonaws/services/dynamodbv2/AmazonDynamoDBLockClient.java [342:381]


    public static void createLockTableInDynamoDB(final CreateDynamoDBTableOptions createDynamoDBTableOptions) {
        Objects.requireNonNull(createDynamoDBTableOptions.getDynamoDBClient(), "DynamoDB client object cannot be null");
        Objects.requireNonNull(createDynamoDBTableOptions.getTableName(), "Table name cannot be null");
        Objects.requireNonNull(createDynamoDBTableOptions.getProvisionedThroughput(), "Provisioned throughput cannot be null");
        Objects.requireNonNull(createDynamoDBTableOptions.getPartitionKeyName(), "Hash Key Name cannot be null");
        Objects.requireNonNull(createDynamoDBTableOptions.getSortKeyName(), "Sort Key Name cannot be null");
        final KeySchemaElement partitionKeyElement = KeySchemaElement.builder()
                .attributeName(createDynamoDBTableOptions.getPartitionKeyName()).keyType(KeyType.HASH)
                .build();

        final List<KeySchemaElement> keySchema = new ArrayList<>();
        keySchema.add(partitionKeyElement);

        final Collection<AttributeDefinition> attributeDefinitions = new ArrayList<>();
        attributeDefinitions.add(AttributeDefinition.builder()
                .attributeName(createDynamoDBTableOptions.getPartitionKeyName())
                .attributeType(ScalarAttributeType.S)
                .build());

        if (createDynamoDBTableOptions.getSortKeyName().isPresent()) {
            final KeySchemaElement sortKeyElement = KeySchemaElement.builder()
                    .attributeName(createDynamoDBTableOptions.getSortKeyName().get())
                    .keyType(KeyType.RANGE)
                    .build();
            keySchema.add(sortKeyElement);
            attributeDefinitions.add(AttributeDefinition.builder()
                    .attributeName(createDynamoDBTableOptions.getSortKeyName().get())
                    .attributeType(ScalarAttributeType.S)
                    .build());
        }

        final CreateTableRequest createTableRequest = CreateTableRequest.builder()
                .tableName(createDynamoDBTableOptions.getTableName())
                .keySchema(keySchema)
                .provisionedThroughput(createDynamoDBTableOptions.getProvisionedThroughput())
                .attributeDefinitions(attributeDefinitions)
                .build();

        createDynamoDBTableOptions.getDynamoDBClient().createTable(createTableRequest);
    }