Class DynamoDbAttributeValueHelper
DynamoDB SDK versions expose attribute values through similar accessor methods but different
concrete classes. This helper calls those accessors through DynamoDbReflectionHelper so
the controller does not need a compile-time dependency on a particular AWS SDK. The resulting
representation uses maps, lists, sets, strings, numbers, booleans, and binary values that can be
inspected without SDK-specific logic.
The class also resolves DynamoDB attribute types and traverses the restricted document-path
syntax accepted by DynamoDbConditionExpression.g4 directly over the normalized maps and
lists. Direct traversal preserves the original Java values and distinguishes a missing path from
a path whose value is explicitly null.
-
Method Summary
Modifier and TypeMethodDescriptiondocumentPaths(Map<String, Object> item) Returns every resolvable document path in a normalized DynamoDB item.static DynamoDbValueLookuplookupByPath(Map<String, Object> item, String path) Resolves a DynamoDB document path against a normalized item without converting it to JSON.static DynamoDbAttributeTyperesolveAttributeType(Object value) Resolves the DynamoDB attribute type represented by a normalized Java runtime value.toPlainMap(Object source) Converts a map of DynamoDB attribute values into a deterministic map of plain Java values.static ObjecttoPlainValue(Object value) Converts one DynamoDB attribute value object into the corresponding plain Java value.
-
Method Details
-
toPlainMap
Converts a map of DynamoDB attribute values into a deterministic map of plain Java values.Keys are converted to strings and null keys are omitted because DynamoDB attribute names are strings. Values are recursively normalized with
toPlainValue(Object). ALinkedHashMapis used so source iteration order is retained for reproducible heuristic evaluation and tests.- Parameters:
source- input object expected to be a map- Returns:
- normalized map, or an empty map when
sourceis not a map
-
toPlainValue
Converts one DynamoDB attribute value object into the corresponding plain Java value.Already-plain maps and collections are recursively normalized first. Other objects are inspected through the accessor names shared by DynamoDB SDK attribute-value implementations. Scalar values are checked before document and set values to match the mutually exclusive DynamoDB attribute model. Unknown objects are returned unchanged so callers can still handle SDK variants or test values that this helper does not recognize.
- Parameters:
value- attribute value object- Returns:
- recursively normalized Java value, or the original object when no known DynamoDB attribute shape is available
-
resolveAttributeType
Resolves the DynamoDB attribute type represented by a normalized Java runtime value.The heuristic calculator uses this mapping to evaluate
attribute_type. Sets are classified by a representative element because Java generic element types are erased. Empty and unrecognized sets fall back toDynamoDbAttributeType.LIST, while unsupported scalar objects fall back toDynamoDbAttributeType.STRING; these defaults preserve the existing behavior for values without enough runtime type information.- Parameters:
value- runtime value- Returns:
- DynamoDB attribute type used by type predicates
-
documentPaths
Returns every resolvable document path in a normalized DynamoDB item.Map fields use dot notation and list elements use bracketed indexes, matching
lookupByPath(Map, String). Container paths are included alongside their descendants, while sets are treated as leaves because DynamoDB document paths cannot address set members. Paths retain the deterministic traversal order of the normalized maps and lists.Children are pushed onto a LIFO work stack in reverse order to preserve depth-first preorder.
- Parameters:
item- normalized DynamoDB item- Returns:
- snapshot of all resolvable document paths, or an empty set when
itemis null
-
lookupByPath
Resolves a DynamoDB document path against a normalized item without converting it to JSON.Supported paths contain dot-separated map fields and zero or more list indexes on each field, for example
profile.country,squads[0].captain, ortournaments[0][1]. Direct map/list traversal avoids an additional JSON dependency or tree conversion and preserves the runtime types consumed by the heuristic calculator.Lookup fails when the item or path is absent, a field does not exist, an intermediate value has the wrong container type, or a list index is outside the available range. A successfully resolved explicit null is returned as
DynamoDbValueLookup(true, null).- Parameters:
item- normalized DynamoDB itempath- document path produced by the DynamoDB expression parser- Returns:
- result containing both path-presence information and the resolved value
-