Class AsyncEntityTableBuilder<T>

java.lang.Object
dev.hogwai.dynamodb.simplified.entity.AsyncEntityTableBuilder<T>
Type Parameters:
T - the entity type

public final class AsyncEntityTableBuilder<T> extends Object
Builder for creating AsyncEntityTable instances for single-table design.

The entity class must be annotated with @Entity and may use @KeyComponent and @KeyPrefix annotations to define the entity schema.

Usage:

AsyncEntityTable<User> userTable = new AsyncEntityTableBuilder<>(User.class)
        .dynamoDbAsyncClient(asyncClient)
        .build();

Alternatively, use AsyncDynamoSimplifiedClient.entityTable(Class) for a simpler end-to-end flow.

  • Constructor Details

    • AsyncEntityTableBuilder

      public AsyncEntityTableBuilder(@NonNull Class<T> entityClass)
      Creates a new builder for the given entity class.
      Parameters:
      entityClass - the entity class annotated with @Entity
  • Method Details

    • dynamoDbAsyncClient

      public AsyncEntityTableBuilder<T> dynamoDbAsyncClient(@NonNull software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient client)
      Sets the low-level DynamoDbAsyncClient to use.
      Parameters:
      client - the DynamoDB async client
      Returns:
      this builder for chaining
    • enhancedAsyncClient

      public AsyncEntityTableBuilder<T> enhancedAsyncClient(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedAsyncClient client)
      Sets the DynamoDbEnhancedAsyncClient to use.

      If not set, one will be built from the provided dynamoDbAsyncClient(DynamoDbAsyncClient).

      Parameters:
      client - the enhanced async DynamoDB client
      Returns:
      this builder for chaining
    • build

      public @NonNull AsyncEntityTable<T> build()
      Builds the AsyncEntityTable instance.

      Reads the entity schema from annotations, creates the underlying DynamoDB table mapping, and wraps it in an AsyncDefaultEntityTable.

      Returns:
      a new AsyncEntityTable<T>
      Throws:
      IllegalArgumentException - if the entity class is not annotated with @Entity
      NullPointerException - if no DynamoDbAsyncClient is set