Class AbstractGetItemBuilder<T, S extends AbstractGetItemBuilder<T,S>>

java.lang.Object
dev.hogwai.dynamodb.simplified.builder.base.AbstractGetItemBuilder<T,S>
Type Parameters:
T - the item type
S - the concrete builder type (for fluent chaining)
Direct Known Subclasses:
AsyncGetItemBuilder, GetItemBuilder

public abstract class AbstractGetItemBuilder<T, S extends AbstractGetItemBuilder<T,S>> extends Object
Abstract base for sync and async get-item builders.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Whether to use strongly consistent reads (false by default).
    protected static final org.slf4j.Logger
    Logger for this builder class.
    protected final Object
    The partition key value.
    Optional projection expression to restrict returned attributes.
    protected final @Nullable Object
    The sort key value, or null if the table has no sort key.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractGetItemBuilder(@NonNull Object partitionKey, @Nullable Object sortKey)
    Constructs a new AbstractGetItemBuilder with the given key values.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected @NonNull software.amazon.awssdk.enhanced.dynamodb.model.GetItemEnhancedRequest
    Builds a high-level GetItemEnhancedRequest from the current key and settings.
    protected @NonNull Map<String, software.amazon.awssdk.services.dynamodb.model.AttributeValue>
    buildKeyMap(@NonNull String pkName, @Nullable String skName)
    Builds a key map for low-level requests using the given key attribute names.
    protected @NonNull software.amazon.awssdk.services.dynamodb.model.GetItemRequest
    buildLowLevelRequest(@NonNull Map<String, software.amazon.awssdk.services.dynamodb.model.AttributeValue> keyMap)
    Builds a low-level GetItemRequest from the given key map.
    @NonNull S
    consistentRead(boolean consistentRead)
    Enables or disables strongly consistent reads.
    @NonNull S
    project(@NonNull String... attributes)
    Restricts the returned attributes to the specified ones.
    @NonNull S
    project(@NonNull Consumer<ProjectionExpression> projectionBuilder)
    Restricts the returned attributes by configuring a ProjectionExpression via a consumer.
    protected abstract S
    Returns this typed as S for fluent chaining.
    protected abstract @NonNull String
    Returns the DynamoDB table name.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG

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

      protected final Object partitionKey
      The partition key value.
    • sortKey

      protected final @Nullable Object sortKey
      The sort key value, or null if the table has no sort key.
    • projectionExpression

      protected ProjectionExpression projectionExpression
      Optional projection expression to restrict returned attributes.
    • consistentRead

      protected boolean consistentRead
      Whether to use strongly consistent reads (false by default).
  • Constructor Details

    • AbstractGetItemBuilder

      protected AbstractGetItemBuilder(@NonNull Object partitionKey, @Nullable Object sortKey)
      Constructs a new AbstractGetItemBuilder with the given key values.
      Parameters:
      partitionKey - the partition key value
      sortKey - the sort key value, or null if the table has no sort key
  • Method Details

    • self

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

      public @NonNull S project(@NonNull String... attributes)
      Restricts the returned attributes to the specified ones.
      Parameters:
      attributes - the attribute names to include in the result
      Returns:
      this builder for chaining
    • project

      public @NonNull S project(@NonNull Consumer<ProjectionExpression> projectionBuilder)
      Restricts the returned attributes by configuring a ProjectionExpression via a consumer.
      Parameters:
      projectionBuilder - a consumer that configures the ProjectionExpression
      Returns:
      this builder for chaining
    • consistentRead

      public @NonNull S consistentRead(boolean consistentRead)
      Enables or disables strongly consistent reads.
      Parameters:
      consistentRead - true for a strongly consistent read, false (the default) for an eventually consistent read
      Returns:
      this builder for chaining
    • buildEnhancedRequest

      protected @NonNull software.amazon.awssdk.enhanced.dynamodb.model.GetItemEnhancedRequest buildEnhancedRequest()
      Builds a high-level GetItemEnhancedRequest from the current key and settings.
      Returns:
      the built enhanced request
    • buildLowLevelRequest

      protected @NonNull software.amazon.awssdk.services.dynamodb.model.GetItemRequest buildLowLevelRequest(@NonNull Map<String, software.amazon.awssdk.services.dynamodb.model.AttributeValue> keyMap)
      Builds a low-level GetItemRequest from the given key map. Requires a non-null projectionExpression.
      Parameters:
      keyMap - the key attribute map
      Returns:
      the built low-level request
    • buildKeyMap

      protected @NonNull Map<String, software.amazon.awssdk.services.dynamodb.model.AttributeValue> buildKeyMap(@NonNull String pkName, @Nullable String skName)
      Builds a key map for low-level requests using the given key attribute names.
      Parameters:
      pkName - the partition key attribute name
      skName - the sort key attribute name, or null if none
      Returns:
      the built key map
    • tableName

      protected abstract @NonNull String tableName()
      Returns the DynamoDB table name.
      Returns:
      the DynamoDB table name