Class NestedAttributeName

java.lang.Object
software.amazon.awssdk.enhanced.dynamodb.NestedAttributeName

@ThreadSafe public final class NestedAttributeName extends Object
A high-level representation of a DynamoDB nested attribute name that can be used in various situations where the API requires or accepts a nested attribute name. The nested attributes are represented by a list of strings where each element corresponds to a nesting level. A simple (top-level) attribute name can be represented by creating an instance with a single string element.

NestedAttributeName is used directly in QueryEnhancedRequest.nestedAttributesToProject() and ScanEnhancedRequest.nestedAttributesToProject(), and indirectly by QueryEnhancedRequest.attributesToProject() and ScanEnhancedRequest.attributesToProject().

Examples of creating NestedAttributeNames:

  • Simple attribute Level0 can be created as NestedAttributeName.create("Level0")
  • Nested attribute Level0.Level1 can be created as NestedAttributeName.create("Level0", "Level1")
  • Nested attribute Level0.Level-2 can be created as NestedAttributeName.create("Level0", "Level-2")
  • List item 0 of ListAttribute can be created as NestedAttributeName.create("ListAttribute[0]")
  • Method Details

    • create

      public static NestedAttributeName create(String element)
      Creates a NestedAttributeName with a single element, which is effectively just a simple attribute name without nesting.

      Example:create("foo") will create NestedAttributeName corresponding to Attribute foo.

      Parameters:
      element - Attribute Name. Single String represents just a simple attribute name without nesting.
      Returns:
      NestedAttributeName with attribute name as specified element.
    • create

      public static NestedAttributeName create(String... elements)
      Creates a NestedAttributeName from a list of elements that compose the full path of the nested attribute.

      Example:create("foo", "bar") will create NestedAttributeName which represents foo.bar nested attribute.

      Parameters:
      elements - Nested Attribute Names. Each of strings in varargs represent the nested attribute name at subsequent levels.
      Returns:
      NestedAttributeName with Nested attribute name set as specified in elements var args.
    • create

      public static NestedAttributeName create(List<String> elements)
      Creates a NestedAttributeName from a list of elements that compose the full path of the nested attribute.

      Example:create(Arrays.asList("foo", "bar")) will create NestedAttributeName which represents foo.bar nested attribute.

      Parameters:
      elements - List of Nested Attribute Names. Each of strings in List represent the nested attribute name at subsequent levels.
      Returns:
      NestedAttributeName with Nested attribute name set as specified in elements Collections.
    • builder

      public static NestedAttributeName.Builder builder()
      Create a builder that can be used to create a NestedAttributeName.
    • elements

      public List<String> elements()
      Gets elements of NestedAttributeName in the form of List. Each element in the list corresponds to the subsequent Nested Attribute name.
      Returns:
      List of nested attributes, each entry in the list represent one level of nesting. Example, A Two level Attribute name foo.bar will be represented as ["foo", "bar"]
    • toBuilder

      public NestedAttributeName.Builder toBuilder()
      Returns a builder initialized with all existing values on the request object.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object