Class AbstractCrossTableBatchGetBuilder<S extends AbstractCrossTableBatchGetBuilder<S>>

java.lang.Object
dev.hogwai.dynamodb.simplified.builder.base.AbstractCrossTableBatchGetBuilder<S>
Type Parameters:
S - the concrete builder type (for fluent chaining)
Direct Known Subclasses:
AsyncCrossTableBatchGetBuilder, CrossTableBatchGetBuilder

public abstract class AbstractCrossTableBatchGetBuilder<S extends AbstractCrossTableBatchGetBuilder<S>> extends Object
Abstract base for sync and async cross-table batch get builders.

Manages entries (key + table associations), consistent read, projection, and consumed capacity settings shared across sync and async variants.

  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
      Logger for this builder class.
    • entries

      The list of entries (table + key + projection) to retrieve.
    • consistentRead

      protected Boolean consistentRead
      Whether to use strongly consistent reads, or null to use the default.
    • returnConsumedCapacity

      protected software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity returnConsumedCapacity
      Optional consumed capacity reporting level.
  • Constructor Details

    • AbstractCrossTableBatchGetBuilder

      protected AbstractCrossTableBatchGetBuilder()
      Constructs a new AbstractCrossTableBatchGetBuilder.
  • Method Details

    • self

      protected abstract @NonNull S self()
      Returns this typed as S for fluent chaining.
      Returns:
      this builder
    • getTableName

      protected abstract @NonNull String getTableName(@NonNull AbstractCrossTableBatchGetBuilder.Entry entry)
      Extracts the DynamoDB table name from an entry's table reference.
      Parameters:
      entry - the entry whose table name to extract
      Returns:
      the DynamoDB table name
    • getTableSchema

      protected abstract @NonNull software.amazon.awssdk.enhanced.dynamodb.TableSchema<?> getTableSchema(@NonNull AbstractCrossTableBatchGetBuilder.Entry entry)
      Extracts the table schema from an entry's table reference.
      Parameters:
      entry - the entry whose table schema to extract
      Returns:
      the table schema
    • project

      public @NonNull S project(@NonNull String... attributes)
      Restricts the returned attributes for the most recently added entry to the specified attribute names.

      Projection is applied server-side, reducing data transfer and consumed capacity.

      Parameters:
      attributes - the attribute names to include
      Returns:
      this builder
      Throws:
      IllegalStateException - if no entries have been added yet
    • project

      public @NonNull S project(@NonNull Consumer<ProjectionExpression> consumer)
      Restricts the returned attributes for the most recently added entry using a ProjectionExpression builder consumer.
      Parameters:
      consumer - a consumer to configure the projection expression
      Returns:
      this builder
      Throws:
      IllegalStateException - if no entries have been added yet
    • returnConsumedCapacity

      public @NonNull S returnConsumedCapacity(@NonNull software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity returnConsumedCapacity)
      Configures whether to return consumed capacity information for the operation.
      Parameters:
      returnConsumedCapacity - the consumed capacity reporting level
      Returns:
      this builder for chaining
    • consistentRead

      public @NonNull S consistentRead(boolean consistentRead)
      Configures whether to use strongly consistent reads for this batch get operation.

      If not set, DynamoDB defaults to eventually consistent reads.

      Parameters:
      consistentRead - true for strongly consistent reads
      Returns:
      this builder for chaining
    • buildKey

      protected static @NonNull software.amazon.awssdk.enhanced.dynamodb.Key buildKey(@NonNull Object partitionKey, @Nullable Object sortKey)
      Builds a Key from partition and optional sort key values.
      Parameters:
      partitionKey - the partition key value
      sortKey - the sort key value, or null if the table has no sort key
      Returns:
      the constructed key
    • groupEntriesByTable

      protected Map<String, List<AbstractCrossTableBatchGetBuilder.Entry>> groupEntriesByTable()
      Groups entries by their DynamoDB table name.
      Returns:
      a map from table name to its entries
    • buildRequestItems

      protected Map<String, software.amazon.awssdk.services.dynamodb.model.KeysAndAttributes> buildRequestItems(Map<String, List<AbstractCrossTableBatchGetBuilder.Entry>> entriesByTable, Map<String, software.amazon.awssdk.enhanced.dynamodb.TableSchema<?>> tableSchemas)
      Builds the request items map from entries grouped by table.

      Also populates the tableSchemas map with the schema for each table, needed downstream for deserialization.

      Parameters:
      entriesByTable - entries grouped by table name
      tableSchemas - map to populate with table schemas (output)
      Returns:
      the request items for the batch get operation