From 20a8621f095ef387322ecebcfc37b0daf4f877d6 Mon Sep 17 00:00:00 2001 From: WinterYukky <49480575+WinterYukky@users.noreply.github.com> Date: Tue, 31 Oct 2023 07:11:37 +0000 Subject: [PATCH] style: use Document.ListBuilder --- .../cloudformation/proxy/aws/SdkPojoDeserializer.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/software/amazon/cloudformation/proxy/aws/SdkPojoDeserializer.java b/src/main/java/software/amazon/cloudformation/proxy/aws/SdkPojoDeserializer.java index abf0e91a..30d1d9e6 100644 --- a/src/main/java/software/amazon/cloudformation/proxy/aws/SdkPojoDeserializer.java +++ b/src/main/java/software/amazon/cloudformation/proxy/aws/SdkPojoDeserializer.java @@ -36,6 +36,7 @@ import software.amazon.awssdk.core.SdkField; import software.amazon.awssdk.core.SdkPojo; import software.amazon.awssdk.core.document.Document; +import software.amazon.awssdk.core.document.Document.ListBuilder; import software.amazon.awssdk.core.document.Document.MapBuilder; import software.amazon.awssdk.core.protocol.MarshallingType; import software.amazon.awssdk.core.traits.ListTrait; @@ -219,11 +220,11 @@ private Document readDocument(SdkField field, JsonParser p, DeserializationCo case VALUE_NUMBER_INT: return Document.fromNumber(p.getText()); case START_ARRAY: { - List documents = new ArrayList<>(); + ListBuilder builder = Document.listBuilder(); while (p.nextToken() != JsonToken.END_ARRAY) { - documents.add(readDocument(field, p, ctxt)); + builder.addDocument(readDocument(field, p, ctxt)); } - return Document.fromList(documents); + return builder.build(); } case START_OBJECT: MapBuilder builder = Document.mapBuilder();