Skip to content

Commit cd00fb7

Browse files
committed
feat: enhnace switch case at DynamoDB converter
Signed-off-by: Otavio Santana <[email protected]>
1 parent b800c7b commit cd00fb7

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

jnosql-dynamodb/src/main/java/org/eclipse/jnosql/databases/dynamodb/communication/DynamoDBConverter.java

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,20 @@ private DynamoDBConverter() {
4646

4747
private static Object convertValue(Object value) {
4848
if (value instanceof AttributeValue attributeValue) {
49-
switch (attributeValue.type()) {
50-
case S:
51-
return attributeValue.s();
52-
case N:
53-
return Double.valueOf(attributeValue.n());
54-
case B:
55-
return attributeValue.b().asByteArray();
56-
case SS:
57-
return attributeValue.ss();
58-
case NS:
59-
return attributeValue.ns().stream().map(Double::valueOf).toList();
60-
case BS:
61-
return attributeValue.bs().stream().map(SdkBytes::asByteArray).toList();
62-
case L:
63-
return attributeValue.l().stream().map(DynamoDBConverter::convertValue).toList();
64-
case M:
65-
return attributeValue.m().entrySet().stream().map(e -> Element.of(e.getKey(), convertValue(e.getValue()))).toList();
66-
case NUL:
67-
return null;
68-
case BOOL:
69-
return attributeValue.bool();
70-
case UNKNOWN_TO_SDK_VERSION:
71-
default:
72-
return null; // map type
73-
}
49+
return switch (attributeValue.type()) {
50+
case S -> attributeValue.s();
51+
case N -> Double.valueOf(attributeValue.n());
52+
case B -> attributeValue.b().asByteArray();
53+
case SS -> attributeValue.ss();
54+
case NS -> attributeValue.ns().stream().map(Double::valueOf).toList();
55+
case BS -> attributeValue.bs().stream().map(SdkBytes::asByteArray).toList();
56+
case L -> attributeValue.l().stream().map(DynamoDBConverter::convertValue).toList();
57+
case M ->
58+
attributeValue.m().entrySet().stream().map(e -> Element.of(e.getKey(), convertValue(e.getValue()))).toList();
59+
case NUL -> null;
60+
case BOOL -> attributeValue.bool();
61+
default -> null; // map type
62+
};
7463
}
7564
return value;
7665
}

0 commit comments

Comments
 (0)