From f3e9dc58e3da45c28b5283ddb3251e4bf9a9cd2e Mon Sep 17 00:00:00 2001 From: Manuel Sugawara Date: Mon, 4 Nov 2024 11:32:43 -0800 Subject: [PATCH] Consolidate unmarshalling and parsing in a single pass (#5643) * Consolidate unmarshalling and parsing in a single pass * Address PR comments * Address PR comments * Add a test to assert that a non-object literal throws * Add more testing * Use Jackson's built-in fast float parsing * Add customizaion option to enable the fast unmarshalling path * Fix checkstyle issues * Account for tests with unset clientConfiguration * Fix codegen checkstyle --- .../feature-AWSSDKforJavav2-70d110c.json | 6 + .../customization/CustomizationConfig.java | 12 + .../poet/builder/BaseClientBuilderClass.java | 8 + .../codegen/poet/model/AwsServiceModel.java | 15 +- .../codegen/poet/model/ModelBuilderSpecs.java | 13 + .../codegen/poet/model/ShapeModelSpec.java | 49 +- .../codegen/poet/model/alltypesrequest.java | 53 + .../codegen/poet/model/alltypesresponse.java | 53 + .../poet/model/alltypesunionstructure.java | 1176 +++++++++-------- .../awssdk/codegen/poet/model/basetype.java | 53 +- .../poet/model/deprecatedrenamerequest.java | 62 +- .../poet/model/deprecatedrenameresponse.java | 62 +- .../poet/model/emptymodeledexception.java | 17 +- .../awssdk/codegen/poet/model/enumtype.java | 12 +- .../awssdk/codegen/poet/model/eventone.java | 33 +- .../codegen/poet/model/eventstream.java | 1 - .../model/eventstreamoperationrequest.java | 16 +- .../model/eventstreamoperationresponse.java | 17 +- ...ntstreamoperationwithonlyinputrequest.java | 16 +- ...tstreamoperationwithonlyinputresponse.java | 17 +- .../awssdk/codegen/poet/model/eventtwo.java | 33 +- ...onserviceinternalservererrorexception.java | 16 +- .../jsonserviceinvalidinputexception.java | 16 +- .../jsonservicethrottlingexception.java | 16 +- .../model/existencechecknamingrequest.java | 161 ++- .../model/existencechecknamingresponse.java | 161 ++- .../awssdk/codegen/poet/model/inputevent.java | 43 +- .../codegen/poet/model/inputeventstream.java | 1 - .../poet/model/inputeventstreamtwo.java | 1 - .../codegen/poet/model/inputeventtwo.java | 77 +- .../poet/model/nestedcontainersrequest.java | 260 ++-- .../poet/model/nestedcontainersresponse.java | 262 ++-- .../model/nestedqueryparameteroperation.java | 65 +- .../operationwithdeprecatedmemberrequest.java | 114 +- ...operationwithdeprecatedmemberresponse.java | 89 +- .../operationwithnoinputoroutputrequest.java | 16 +- .../operationwithnoinputoroutputresponse.java | 17 +- .../model/queryparameteroperationrequest.java | 226 ++-- .../queryparameteroperationresponse.java | 20 +- .../poet/model/recursivestructtype.java | 131 +- .../poet/model/sharedstream/eventstream.java | 1 - .../sharedstream/getrandompersonrequest.java | 16 +- .../sharedstream/getrandompersonresponse.java | 48 +- .../poet/model/sharedstream/person.java | 44 +- .../sharedstream/streambirthsrequest.java | 16 +- .../sharedstream/streambirthsresponse.java | 16 +- .../sharedstream/streamdeathsrequest.java | 16 +- .../sharedstream/streamdeathsresponse.java | 16 +- .../codegen/poet/model/simplestruct.java | 33 +- .../model/streaminginputoperationrequest.java | 16 +- .../streaminginputoperationresponse.java | 17 +- .../streamingoutputoperationrequest.java | 16 +- .../streamingoutputoperationresponse.java | 17 +- .../poet/model/structwithnestedblobtype.java | 35 +- .../poet/model/structwithtimestamp.java | 37 +- .../awssdk/codegen/poet/model/subtypeone.java | 35 +- .../poet/model/underscore_name_type.java | 17 +- .../xmlnamespace/testxmlnamespacerequest.java | 105 +- .../testxmlnamespaceresponse.java | 105 +- .../xmlnamespace/xmlnamespacemember.java | 64 +- .../json/BaseAwsJsonProtocolFactory.java | 10 + .../AwsStructuredPlainJsonFactory.java | 14 +- .../unmarshall/JsonProtocolUnmarshaller.java | 131 +- .../unmarshall/JsonUnmarshallingParser.java | 540 ++++++++ .../SdkClientJsonProtocolAdvancedOption.java | 32 + .../internal/unmarshall/ComplexStructure.java | 787 +++++++++++ .../JsonUnmarshallingParserTest.java | 119 ++ .../unmarshall/ListOfStringsCopier.java | 36 + .../unmarshall/MapOfStringToStringCopier.java | 38 + .../json/internal/unmarshall/TestRequest.java | 822 ++++++++++++ .../amazon/awssdk/core/SdkNumber.java | 38 +- .../software/amazon/awssdk/core/SdkPojo.java | 8 + .../amazon/awssdk/core/document/Document.java | 19 +- .../suites/cases/rest-json-output.json | 26 +- .../codegen-resources/restjson/service-2.json | 40 + .../benchmark/apicall/protocol/JsonCodec.java | 2 +- .../dynamodb/V2DynamoDbAttributeValue.java | 2 + 77 files changed, 5182 insertions(+), 1568 deletions(-) create mode 100644 .changes/next-release/feature-AWSSDKforJavav2-70d110c.json create mode 100644 core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonUnmarshallingParser.java create mode 100644 core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/SdkClientJsonProtocolAdvancedOption.java create mode 100644 core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/ComplexStructure.java create mode 100644 core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonUnmarshallingParserTest.java create mode 100644 core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/ListOfStringsCopier.java create mode 100644 core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/MapOfStringToStringCopier.java create mode 100644 core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/TestRequest.java diff --git a/.changes/next-release/feature-AWSSDKforJavav2-70d110c.json b/.changes/next-release/feature-AWSSDKforJavav2-70d110c.json new file mode 100644 index 000000000000..a17d92f4bb55 --- /dev/null +++ b/.changes/next-release/feature-AWSSDKforJavav2-70d110c.json @@ -0,0 +1,6 @@ +{ + "category": "AWS SDK for Java v2", + "contributor": "", + "type": "feature", + "description": "Improve unmarshalling performance of all JSON protocols by unifying parsing with unmarshalling instead of doing one after the other." +} diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/model/config/customization/CustomizationConfig.java b/codegen/src/main/java/software/amazon/awssdk/codegen/model/config/customization/CustomizationConfig.java index 70289e2a05a7..3cbdd6d83f60 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/model/config/customization/CustomizationConfig.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/model/config/customization/CustomizationConfig.java @@ -347,6 +347,11 @@ public class CustomizationConfig { */ private boolean batchManagerSupported; + /** + * A boolean flag to indicate if the fast unmarshaller code path is enabled. + */ + private boolean enableFastUnmarshaller; + private CustomizationConfig() { } @@ -914,4 +919,11 @@ public void setBatchManagerSupported(boolean batchManagerSupported) { this.batchManagerSupported = batchManagerSupported; } + public boolean getEnableFastUnmarshaller() { + return enableFastUnmarshaller; + } + + public void setEnableFastUnmarshaller(boolean enableFastUnmarshaller) { + this.enableFastUnmarshaller = enableFastUnmarshaller; + } } diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/builder/BaseClientBuilderClass.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/builder/BaseClientBuilderClass.java index d98b7556ae98..25269518b7b2 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/builder/BaseClientBuilderClass.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/builder/BaseClientBuilderClass.java @@ -73,6 +73,7 @@ import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; +import software.amazon.awssdk.protocols.json.internal.unmarshall.SdkClientJsonProtocolAdvancedOption; import software.amazon.awssdk.regions.ServiceMetadataAdvancedOption; import software.amazon.awssdk.utils.AttributeMap; import software.amazon.awssdk.utils.CollectionUtils; @@ -479,6 +480,13 @@ private MethodSpec finalizeServiceConfigurationMethod() { .addCode(" .fipsEnabled(c.get($T.FIPS_ENDPOINT_ENABLED))", AwsClientOption.class) .addCode(" .build());"); + if (model.getMetadata().isJsonProtocol()) { + if (model.getCustomizationConfig().getEnableFastUnmarshaller()) { + builder.addStatement("builder.option($1T.ENABLE_FAST_UNMARSHALLER, true)", + SdkClientJsonProtocolAdvancedOption.class); + } + } + builder.addStatement("return builder.build()"); return builder.build(); } diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/AwsServiceModel.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/AwsServiceModel.java index e2fbb81932b7..8168416c26b3 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/AwsServiceModel.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/AwsServiceModel.java @@ -38,6 +38,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -98,7 +99,6 @@ public TypeSpec poetSpec() { if (shapeModel.isEventStream()) { return eventStreamInterfaceSpec(); } - List fields = shapeModelSpec.fields(); TypeSpec.Builder specBuilder = TypeSpec.classBuilder(className()) @@ -110,9 +110,9 @@ public TypeSpec poetSpec() { .addFields(fields) .addFields(shapeModelSpec.staticFields()) .addMethod(addModifier(sdkFieldsMethod(), FINAL)) + .addMethod(addModifier(sdkFieldNameToFieldMethod(), FINAL)) .addTypes(nestedModelClassTypes()); - if (shapeModel.isUnion()) { specBuilder.addField(unionTypeField()); } @@ -316,6 +316,17 @@ private MethodSpec sdkFieldsMethod() { .build(); } + private MethodSpec sdkFieldNameToFieldMethod() { + ParameterizedTypeName sdkFieldType = ParameterizedTypeName.get(ClassName.get(SdkField.class), + WildcardTypeName.subtypeOf(ClassName.get(Object.class))); + return MethodSpec.methodBuilder("sdkFieldNameToField") + .addModifiers(PUBLIC) + .addAnnotation(Override.class) + .returns(ParameterizedTypeName.get(ClassName.get(Map.class), ClassName.get(String.class), sdkFieldType)) + .addCode("return SDK_NAME_TO_FIELD;") + .build(); + } + private MethodSpec getterCreator() { TypeVariableName t = TypeVariableName.get("T"); return MethodSpec.methodBuilder("getter") diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ModelBuilderSpecs.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ModelBuilderSpecs.java index 0be31c6dd61a..aa61dea0a16a 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ModelBuilderSpecs.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ModelBuilderSpecs.java @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.function.Consumer; import javax.lang.model.element.Modifier; @@ -141,6 +142,7 @@ public TypeSpec beanStyleBuilder() { builderClassBuilder.addMethods(accessors()); builderClassBuilder.addMethod(buildMethod()); builderClassBuilder.addMethod(sdkFieldsMethod()); + builderClassBuilder.addMethod(sdkFieldNameToFieldMethod()); if (shapeModel.isUnion()) { builderClassBuilder.addMethod(handleUnionValueChangeMethod()); @@ -169,6 +171,17 @@ private MethodSpec sdkFieldsMethod() { .build(); } + private MethodSpec sdkFieldNameToFieldMethod() { + ParameterizedTypeName sdkFieldType = ParameterizedTypeName.get(ClassName.get(SdkField.class), + WildcardTypeName.subtypeOf(ClassName.get(Object.class))); + return MethodSpec.methodBuilder("sdkFieldNameToField") + .addModifiers(PUBLIC) + .addAnnotation(Override.class) + .returns(ParameterizedTypeName.get(ClassName.get(Map.class), ClassName.get(String.class), sdkFieldType)) + .addCode("return SDK_NAME_TO_FIELD;") + .build(); + } + private TypeName builderImplSuperClass() { if (isRequest()) { return new AwsServiceBaseRequestSpec(intermediateModel).className().nestedClass("BuilderImpl"); diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ShapeModelSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ShapeModelSpec.java index d10ab65a8a27..531ef2dfff6e 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ShapeModelSpec.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ShapeModelSpec.java @@ -23,7 +23,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; import javax.lang.model.element.Modifier; @@ -95,6 +98,7 @@ public List fields(Modifier... modifiers) { public Iterable staticFields(Modifier... modifiers) { List fields = new ArrayList<>(); + Map nameToField = new LinkedHashMap<>(); shapeModel.getNonStreamingMembers().stream() // Exceptions can be members of event stream shapes, need to filter those out of the models .filter(m -> m.getShape() == null || m.getShape().getShapeType() != ShapeType.Exception) @@ -107,6 +111,8 @@ public Iterable staticFields(Modifier... modifiers) { Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL) .initializer(sdkFieldInitializer(m)) .build()); + String name = m.getHttp().getMarshallLocationName(); + nameToField.put(name, namingStrategy.getSdkFieldFieldName(m)); }); ParameterizedTypeName sdkFieldType = ParameterizedTypeName.get(ClassName.get(SdkField.class), @@ -115,13 +121,15 @@ public Iterable staticFields(Modifier... modifiers) { fields.add(FieldSpec.builder(ParameterizedTypeName.get(ClassName.get(List.class), sdkFieldType), "SDK_FIELDS", Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL) - .initializer("$T.unmodifiableList($T.asList($L))", - ClassName.get(Collections.class), - ClassName.get(Arrays.class), - fields.stream() - .map(f -> f.name) - .collect(Collectors.joining(","))) + .initializer(sdkFieldsInitializer(fields)) .build()); + fields.add(FieldSpec.builder(ParameterizedTypeName.get(ClassName.get(Map.class), + ClassName.get(String.class), + sdkFieldType), + "SDK_NAME_TO_FIELD", + Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL) + .initializer(memberNameToFieldInitializer(nameToField)) + .build()); return fields; } @@ -369,4 +377,33 @@ private CodeBlock constructor(MemberModel m) { } } + private CodeBlock sdkFieldsInitializer(List fields) { + CodeBlock.Builder builder = CodeBlock.builder(); + if (fields.isEmpty()) { + builder.add("$T.emptyList()", Collections.class); + return builder.build(); + } + builder.add("$T.unmodifiableList($T.asList($L))", + ClassName.get(Collections.class), + ClassName.get(Arrays.class), + fields.stream() + .map(f -> f.name) + .collect(Collectors.joining(","))); + return builder.build(); + } + + private CodeBlock memberNameToFieldInitializer(Map nameToField) { + CodeBlock.Builder builder = CodeBlock.builder(); + if (nameToField.isEmpty()) { + builder.add("$T.emptyMap()", Collections.class); + return builder.build(); + } + builder.add("$T.unmodifiableMap(", Collections.class); + builder.add("new $T<$T, $T>() {{\n", HashMap.class, String.class, SdkField.class); + nameToField.forEach((name, field) -> builder.add("put($S, $L);\n", name, field)); + builder.add("}}"); + builder.add(")"); + return builder.build(); + } + } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesrequest.java index 72788016688a..643a7d6bb765 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesrequest.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -450,6 +451,48 @@ SdkField. builder(MarshallingType.SDK_BYTES) POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD, ENUM_TYPE_FIELD, UNDERSCORE_NAME_TYPE_FIELD, MY_DOCUMENT_FIELD, ALL_TYPES_UNION_STRUCTURE_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("StringMember", STRING_MEMBER_FIELD); + put("IntegerMember", INTEGER_MEMBER_FIELD); + put("BooleanMember", BOOLEAN_MEMBER_FIELD); + put("FloatMember", FLOAT_MEMBER_FIELD); + put("DoubleMember", DOUBLE_MEMBER_FIELD); + put("LongMember", LONG_MEMBER_FIELD); + put("ShortMember", SHORT_MEMBER_FIELD); + put("ByteMember", BYTE_MEMBER_FIELD); + put("SimpleList", SIMPLE_LIST_FIELD); + put("ListOfEnums", LIST_OF_ENUMS_FIELD); + put("ListOfMaps", LIST_OF_MAPS_FIELD); + put("ListOfStructs", LIST_OF_STRUCTS_FIELD); + put("ListOfMapOfEnumToString", LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD); + put("ListOfMapOfStringToStruct", LIST_OF_MAP_OF_STRING_TO_STRUCT_FIELD); + put("MapOfStringToIntegerList", MAP_OF_STRING_TO_INTEGER_LIST_FIELD); + put("MapOfStringToString", MAP_OF_STRING_TO_STRING_FIELD); + put("MapOfStringToSimpleStruct", MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD); + put("MapOfEnumToEnum", MAP_OF_ENUM_TO_ENUM_FIELD); + put("MapOfEnumToString", MAP_OF_ENUM_TO_STRING_FIELD); + put("MapOfStringToEnum", MAP_OF_STRING_TO_ENUM_FIELD); + put("MapOfEnumToSimpleStruct", MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD); + put("MapOfEnumToListOfEnums", MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD); + put("MapOfEnumToMapOfStringToEnum", MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD); + put("TimestampMember", TIMESTAMP_MEMBER_FIELD); + put("StructWithNestedTimestampMember", STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD); + put("BlobArg", BLOB_ARG_FIELD); + put("StructWithNestedBlob", STRUCT_WITH_NESTED_BLOB_FIELD); + put("BlobMap", BLOB_MAP_FIELD); + put("ListOfBlobs", LIST_OF_BLOBS_FIELD); + put("RecursiveStruct", RECURSIVE_STRUCT_FIELD); + put("PolymorphicTypeWithSubTypes", POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD); + put("PolymorphicTypeWithoutSubTypes", POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD); + put("EnumType", ENUM_TYPE_FIELD); + put("Underscore_Name_Type", UNDERSCORE_NAME_TYPE_FIELD); + put("MyDocument", MY_DOCUMENT_FIELD); + put("AllTypesUnionStructure", ALL_TYPES_UNION_STRUCTURE_FIELD); + } + }); + private final String stringMember; private final Integer integerMember; @@ -1604,6 +1647,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((AllTypesRequest) obj); } @@ -3065,5 +3113,10 @@ public AllTypesRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesresponse.java index 27335cef0cec..80b06d4e8305 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesresponse.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -449,6 +450,48 @@ SdkField. builder(MarshallingType.SDK_BYTES) POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD, ENUM_TYPE_FIELD, UNDERSCORE_NAME_TYPE_FIELD, MY_DOCUMENT_FIELD, ALL_TYPES_UNION_STRUCTURE_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("StringMember", STRING_MEMBER_FIELD); + put("IntegerMember", INTEGER_MEMBER_FIELD); + put("BooleanMember", BOOLEAN_MEMBER_FIELD); + put("FloatMember", FLOAT_MEMBER_FIELD); + put("DoubleMember", DOUBLE_MEMBER_FIELD); + put("LongMember", LONG_MEMBER_FIELD); + put("ShortMember", SHORT_MEMBER_FIELD); + put("ByteMember", BYTE_MEMBER_FIELD); + put("SimpleList", SIMPLE_LIST_FIELD); + put("ListOfEnums", LIST_OF_ENUMS_FIELD); + put("ListOfMaps", LIST_OF_MAPS_FIELD); + put("ListOfStructs", LIST_OF_STRUCTS_FIELD); + put("ListOfMapOfEnumToString", LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD); + put("ListOfMapOfStringToStruct", LIST_OF_MAP_OF_STRING_TO_STRUCT_FIELD); + put("MapOfStringToIntegerList", MAP_OF_STRING_TO_INTEGER_LIST_FIELD); + put("MapOfStringToString", MAP_OF_STRING_TO_STRING_FIELD); + put("MapOfStringToSimpleStruct", MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD); + put("MapOfEnumToEnum", MAP_OF_ENUM_TO_ENUM_FIELD); + put("MapOfEnumToString", MAP_OF_ENUM_TO_STRING_FIELD); + put("MapOfStringToEnum", MAP_OF_STRING_TO_ENUM_FIELD); + put("MapOfEnumToSimpleStruct", MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD); + put("MapOfEnumToListOfEnums", MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD); + put("MapOfEnumToMapOfStringToEnum", MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD); + put("TimestampMember", TIMESTAMP_MEMBER_FIELD); + put("StructWithNestedTimestampMember", STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD); + put("BlobArg", BLOB_ARG_FIELD); + put("StructWithNestedBlob", STRUCT_WITH_NESTED_BLOB_FIELD); + put("BlobMap", BLOB_MAP_FIELD); + put("ListOfBlobs", LIST_OF_BLOBS_FIELD); + put("RecursiveStruct", RECURSIVE_STRUCT_FIELD); + put("PolymorphicTypeWithSubTypes", POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD); + put("PolymorphicTypeWithoutSubTypes", POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD); + put("EnumType", ENUM_TYPE_FIELD); + put("Underscore_Name_Type", UNDERSCORE_NAME_TYPE_FIELD); + put("MyDocument", MY_DOCUMENT_FIELD); + put("AllTypesUnionStructure", ALL_TYPES_UNION_STRUCTURE_FIELD); + } + }); + private final String stringMember; private final Integer integerMember; @@ -1603,6 +1646,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((AllTypesResponse) obj); } @@ -3046,5 +3094,10 @@ public AllTypesResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesunionstructure.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesunionstructure.java index c06e64940b14..c4d8daf656b7 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesunionstructure.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/alltypesunionstructure.java @@ -7,6 +7,7 @@ import java.util.Collection; import java.util.Collections; import java.util.EnumSet; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -39,418 +40,459 @@ */ @Generated("software.amazon.awssdk:codegen") public final class AllTypesUnionStructure implements SdkPojo, Serializable, - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField STRING_MEMBER_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("StringMember").getter(getter(AllTypesUnionStructure::stringMember)) - .setter(setter(Builder::stringMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StringMember").build()).build(); + .memberName("StringMember").getter(getter(AllTypesUnionStructure::stringMember)) + .setter(setter(Builder::stringMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StringMember").build()).build(); private static final SdkField INTEGER_MEMBER_FIELD = SdkField. builder(MarshallingType.INTEGER) - .memberName("IntegerMember").getter(getter(AllTypesUnionStructure::integerMember)) - .setter(setter(Builder::integerMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IntegerMember").build()).build(); + .memberName("IntegerMember").getter(getter(AllTypesUnionStructure::integerMember)) + .setter(setter(Builder::integerMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IntegerMember").build()).build(); private static final SdkField BOOLEAN_MEMBER_FIELD = SdkField. builder(MarshallingType.BOOLEAN) - .memberName("BooleanMember").getter(getter(AllTypesUnionStructure::booleanMember)) - .setter(setter(Builder::booleanMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BooleanMember").build()).build(); + .memberName("BooleanMember").getter(getter(AllTypesUnionStructure::booleanMember)) + .setter(setter(Builder::booleanMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BooleanMember").build()).build(); private static final SdkField FLOAT_MEMBER_FIELD = SdkField. builder(MarshallingType.FLOAT) - .memberName("FloatMember").getter(getter(AllTypesUnionStructure::floatMember)).setter(setter(Builder::floatMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FloatMember").build()).build(); + .memberName("FloatMember").getter(getter(AllTypesUnionStructure::floatMember)).setter(setter(Builder::floatMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FloatMember").build()).build(); private static final SdkField DOUBLE_MEMBER_FIELD = SdkField. builder(MarshallingType.DOUBLE) - .memberName("DoubleMember").getter(getter(AllTypesUnionStructure::doubleMember)) - .setter(setter(Builder::doubleMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DoubleMember").build()).build(); + .memberName("DoubleMember").getter(getter(AllTypesUnionStructure::doubleMember)) + .setter(setter(Builder::doubleMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DoubleMember").build()).build(); private static final SdkField LONG_MEMBER_FIELD = SdkField. builder(MarshallingType.LONG) - .memberName("LongMember").getter(getter(AllTypesUnionStructure::longMember)).setter(setter(Builder::longMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LongMember").build()).build(); + .memberName("LongMember").getter(getter(AllTypesUnionStructure::longMember)).setter(setter(Builder::longMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LongMember").build()).build(); private static final SdkField SHORT_MEMBER_FIELD = SdkField. builder(MarshallingType.SHORT) - .memberName("ShortMember").getter(getter(AllTypesUnionStructure::shortMember)).setter(setter(Builder::shortMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ShortMember").build()).build(); + .memberName("ShortMember").getter(getter(AllTypesUnionStructure::shortMember)).setter(setter(Builder::shortMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ShortMember").build()).build(); private static final SdkField> SIMPLE_LIST_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("SimpleList") - .getter(getter(AllTypesUnionStructure::simpleList)) - .setter(setter(Builder::simpleList)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SimpleList").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("SimpleList") + .getter(getter(AllTypesUnionStructure::simpleList)) + .setter(setter(Builder::simpleList)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SimpleList").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final SdkField> LIST_OF_ENUMS_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("ListOfEnums") - .getter(getter(AllTypesUnionStructure::listOfEnumsAsStrings)) - .setter(setter(Builder::listOfEnumsWithStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfEnums").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("ListOfEnums") + .getter(getter(AllTypesUnionStructure::listOfEnumsAsStrings)) + .setter(setter(Builder::listOfEnumsWithStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfEnums").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final SdkField>> LIST_OF_MAPS_FIELD = SdkField - .>> builder(MarshallingType.LIST) - .memberName("ListOfMaps") - .getter(getter(AllTypesUnionStructure::listOfMaps)) - .setter(setter(Builder::listOfMaps)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMaps").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.> builder(MarshallingType.MAP) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()) - .build()).build()).build()).build(); + .>> builder(MarshallingType.LIST) + .memberName("ListOfMaps") + .getter(getter(AllTypesUnionStructure::listOfMaps)) + .setter(setter(Builder::listOfMaps)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMaps").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.> builder(MarshallingType.MAP) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()) + .build()).build()).build()).build(); private static final SdkField> LIST_OF_STRUCTS_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("ListOfStructs") - .getter(getter(AllTypesUnionStructure::listOfStructs)) - .setter(setter(Builder::listOfStructs)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfStructs").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.SDK_POJO) - .constructor(SimpleStruct::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("ListOfStructs") + .getter(getter(AllTypesUnionStructure::listOfStructs)) + .setter(setter(Builder::listOfStructs)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfStructs").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.SDK_POJO) + .constructor(SimpleStruct::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final SdkField>> LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD = SdkField - .>> builder(MarshallingType.LIST) - .memberName("ListOfMapOfEnumToString") - .getter(getter(AllTypesUnionStructure::listOfMapOfEnumToStringAsStrings)) - .setter(setter(Builder::listOfMapOfEnumToStringWithStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMapOfEnumToString").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.> builder(MarshallingType.MAP) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()) - .build()).build()).build()).build(); + .>> builder(MarshallingType.LIST) + .memberName("ListOfMapOfEnumToString") + .getter(getter(AllTypesUnionStructure::listOfMapOfEnumToStringAsStrings)) + .setter(setter(Builder::listOfMapOfEnumToStringWithStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMapOfEnumToString").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.> builder(MarshallingType.MAP) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()) + .build()).build()).build()).build(); private static final SdkField>> LIST_OF_MAP_OF_STRING_TO_STRUCT_FIELD = SdkField - .>> builder(MarshallingType.LIST) - .memberName("ListOfMapOfStringToStruct") - .getter(getter(AllTypesUnionStructure::listOfMapOfStringToStruct)) - .setter(setter(Builder::listOfMapOfStringToStruct)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMapOfStringToStruct").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.> builder(MarshallingType.MAP) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.SDK_POJO) - .constructor(SimpleStruct::builder) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()) - .build()).build()).build()).build(); + .>> builder(MarshallingType.LIST) + .memberName("ListOfMapOfStringToStruct") + .getter(getter(AllTypesUnionStructure::listOfMapOfStringToStruct)) + .setter(setter(Builder::listOfMapOfStringToStruct)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMapOfStringToStruct").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.> builder(MarshallingType.MAP) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.SDK_POJO) + .constructor(SimpleStruct::builder) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()) + .build()).build()).build()).build(); private static final SdkField>> MAP_OF_STRING_TO_INTEGER_LIST_FIELD = SdkField - .>> builder(MarshallingType.MAP) - .memberName("MapOfStringToIntegerList") - .getter(getter(AllTypesUnionStructure::mapOfStringToIntegerList)) - .setter(setter(Builder::mapOfStringToIntegerList)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToIntegerList").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField.> builder(MarshallingType.LIST) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.INTEGER) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()) - .build()).build()).build()).build(); + .>> builder(MarshallingType.MAP) + .memberName("MapOfStringToIntegerList") + .getter(getter(AllTypesUnionStructure::mapOfStringToIntegerList)) + .setter(setter(Builder::mapOfStringToIntegerList)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToIntegerList").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField.> builder(MarshallingType.LIST) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.INTEGER) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()) + .build()).build()).build()).build(); private static final SdkField> MAP_OF_STRING_TO_STRING_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("MapOfStringToString") - .getter(getter(AllTypesUnionStructure::mapOfStringToString)) - .setter(setter(Builder::mapOfStringToString)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToString").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("MapOfStringToString") + .getter(getter(AllTypesUnionStructure::mapOfStringToString)) + .setter(setter(Builder::mapOfStringToString)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToString").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final SdkField> MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("MapOfStringToSimpleStruct") - .getter(getter(AllTypesUnionStructure::mapOfStringToSimpleStruct)) - .setter(setter(Builder::mapOfStringToSimpleStruct)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToSimpleStruct").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.SDK_POJO) - .constructor(SimpleStruct::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("MapOfStringToSimpleStruct") + .getter(getter(AllTypesUnionStructure::mapOfStringToSimpleStruct)) + .setter(setter(Builder::mapOfStringToSimpleStruct)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToSimpleStruct").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.SDK_POJO) + .constructor(SimpleStruct::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final SdkField> MAP_OF_ENUM_TO_ENUM_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("MapOfEnumToEnum") - .getter(getter(AllTypesUnionStructure::mapOfEnumToEnumAsStrings)) - .setter(setter(Builder::mapOfEnumToEnumWithStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToEnum").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("MapOfEnumToEnum") + .getter(getter(AllTypesUnionStructure::mapOfEnumToEnumAsStrings)) + .setter(setter(Builder::mapOfEnumToEnumWithStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToEnum").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final SdkField> MAP_OF_ENUM_TO_STRING_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("MapOfEnumToString") - .getter(getter(AllTypesUnionStructure::mapOfEnumToStringAsStrings)) - .setter(setter(Builder::mapOfEnumToStringWithStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToString").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("MapOfEnumToString") + .getter(getter(AllTypesUnionStructure::mapOfEnumToStringAsStrings)) + .setter(setter(Builder::mapOfEnumToStringWithStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToString").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final SdkField> MAP_OF_STRING_TO_ENUM_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("MapOfStringToEnum") - .getter(getter(AllTypesUnionStructure::mapOfStringToEnumAsStrings)) - .setter(setter(Builder::mapOfStringToEnumWithStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToEnum").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("MapOfStringToEnum") + .getter(getter(AllTypesUnionStructure::mapOfStringToEnumAsStrings)) + .setter(setter(Builder::mapOfStringToEnumWithStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToEnum").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final SdkField> MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("MapOfEnumToSimpleStruct") - .getter(getter(AllTypesUnionStructure::mapOfEnumToSimpleStructAsStrings)) - .setter(setter(Builder::mapOfEnumToSimpleStructWithStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToSimpleStruct").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.SDK_POJO) - .constructor(SimpleStruct::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("MapOfEnumToSimpleStruct") + .getter(getter(AllTypesUnionStructure::mapOfEnumToSimpleStructAsStrings)) + .setter(setter(Builder::mapOfEnumToSimpleStructWithStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToSimpleStruct").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.SDK_POJO) + .constructor(SimpleStruct::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final SdkField>> MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD = SdkField - .>> builder(MarshallingType.MAP) - .memberName("MapOfEnumToListOfEnums") - .getter(getter(AllTypesUnionStructure::mapOfEnumToListOfEnumsAsStrings)) - .setter(setter(Builder::mapOfEnumToListOfEnumsWithStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToListOfEnums").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField.> builder(MarshallingType.LIST) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()) - .build()).build()).build()).build(); + .>> builder(MarshallingType.MAP) + .memberName("MapOfEnumToListOfEnums") + .getter(getter(AllTypesUnionStructure::mapOfEnumToListOfEnumsAsStrings)) + .setter(setter(Builder::mapOfEnumToListOfEnumsWithStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToListOfEnums").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField.> builder(MarshallingType.LIST) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()) + .build()).build()).build()).build(); private static final SdkField>> MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD = SdkField - .>> builder(MarshallingType.MAP) - .memberName("MapOfEnumToMapOfStringToEnum") - .getter(getter(AllTypesUnionStructure::mapOfEnumToMapOfStringToEnumAsStrings)) - .setter(setter(Builder::mapOfEnumToMapOfStringToEnumWithStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToMapOfStringToEnum") - .build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField.> builder(MarshallingType.MAP) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()) - .build()).build()).build()).build(); + .>> builder(MarshallingType.MAP) + .memberName("MapOfEnumToMapOfStringToEnum") + .getter(getter(AllTypesUnionStructure::mapOfEnumToMapOfStringToEnumAsStrings)) + .setter(setter(Builder::mapOfEnumToMapOfStringToEnumWithStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToMapOfStringToEnum") + .build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField.> builder(MarshallingType.MAP) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()) + .build()).build()).build()).build(); private static final SdkField TIMESTAMP_MEMBER_FIELD = SdkField. builder(MarshallingType.INSTANT) - .memberName("TimestampMember").getter(getter(AllTypesUnionStructure::timestampMember)) - .setter(setter(Builder::timestampMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimestampMember").build()).build(); + .memberName("TimestampMember").getter(getter(AllTypesUnionStructure::timestampMember)) + .setter(setter(Builder::timestampMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimestampMember").build()).build(); private static final SdkField STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD = SdkField - . builder(MarshallingType.SDK_POJO) - .memberName("StructWithNestedTimestampMember") - .getter(getter(AllTypesUnionStructure::structWithNestedTimestampMember)) - .setter(setter(Builder::structWithNestedTimestampMember)) - .constructor(StructWithTimestamp::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StructWithNestedTimestampMember") - .build()).build(); + . builder(MarshallingType.SDK_POJO) + .memberName("StructWithNestedTimestampMember") + .getter(getter(AllTypesUnionStructure::structWithNestedTimestampMember)) + .setter(setter(Builder::structWithNestedTimestampMember)) + .constructor(StructWithTimestamp::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StructWithNestedTimestampMember") + .build()).build(); private static final SdkField BLOB_ARG_FIELD = SdkField. builder(MarshallingType.SDK_BYTES) - .memberName("BlobArg").getter(getter(AllTypesUnionStructure::blobArg)).setter(setter(Builder::blobArg)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BlobArg").build()).build(); + .memberName("BlobArg").getter(getter(AllTypesUnionStructure::blobArg)).setter(setter(Builder::blobArg)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BlobArg").build()).build(); private static final SdkField STRUCT_WITH_NESTED_BLOB_FIELD = SdkField - . builder(MarshallingType.SDK_POJO).memberName("StructWithNestedBlob") - .getter(getter(AllTypesUnionStructure::structWithNestedBlob)).setter(setter(Builder::structWithNestedBlob)) - .constructor(StructWithNestedBlobType::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StructWithNestedBlob").build()) - .build(); + . builder(MarshallingType.SDK_POJO).memberName("StructWithNestedBlob") + .getter(getter(AllTypesUnionStructure::structWithNestedBlob)).setter(setter(Builder::structWithNestedBlob)) + .constructor(StructWithNestedBlobType::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StructWithNestedBlob").build()) + .build(); private static final SdkField> BLOB_MAP_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("BlobMap") - .getter(getter(AllTypesUnionStructure::blobMap)) - .setter(setter(Builder::blobMap)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BlobMap").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.SDK_BYTES) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("BlobMap") + .getter(getter(AllTypesUnionStructure::blobMap)) + .setter(setter(Builder::blobMap)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BlobMap").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.SDK_BYTES) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final SdkField> LIST_OF_BLOBS_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("ListOfBlobs") - .getter(getter(AllTypesUnionStructure::listOfBlobs)) - .setter(setter(Builder::listOfBlobs)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfBlobs").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.SDK_BYTES) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("ListOfBlobs") + .getter(getter(AllTypesUnionStructure::listOfBlobs)) + .setter(setter(Builder::listOfBlobs)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfBlobs").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.SDK_BYTES) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final SdkField RECURSIVE_STRUCT_FIELD = SdkField - . builder(MarshallingType.SDK_POJO).memberName("RecursiveStruct") - .getter(getter(AllTypesUnionStructure::recursiveStruct)).setter(setter(Builder::recursiveStruct)) - .constructor(RecursiveStructType::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveStruct").build()).build(); + . builder(MarshallingType.SDK_POJO).memberName("RecursiveStruct") + .getter(getter(AllTypesUnionStructure::recursiveStruct)).setter(setter(Builder::recursiveStruct)) + .constructor(RecursiveStructType::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveStruct").build()).build(); private static final SdkField POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD = SdkField - . builder(MarshallingType.SDK_POJO) - .memberName("PolymorphicTypeWithSubTypes") - .getter(getter(AllTypesUnionStructure::polymorphicTypeWithSubTypes)) - .setter(setter(Builder::polymorphicTypeWithSubTypes)) - .constructor(BaseType::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolymorphicTypeWithSubTypes") - .build()).build(); + . builder(MarshallingType.SDK_POJO) + .memberName("PolymorphicTypeWithSubTypes") + .getter(getter(AllTypesUnionStructure::polymorphicTypeWithSubTypes)) + .setter(setter(Builder::polymorphicTypeWithSubTypes)) + .constructor(BaseType::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolymorphicTypeWithSubTypes") + .build()).build(); private static final SdkField POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD = SdkField - . builder(MarshallingType.SDK_POJO) - .memberName("PolymorphicTypeWithoutSubTypes") - .getter(getter(AllTypesUnionStructure::polymorphicTypeWithoutSubTypes)) - .setter(setter(Builder::polymorphicTypeWithoutSubTypes)) - .constructor(SubTypeOne::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolymorphicTypeWithoutSubTypes") - .build()).build(); + . builder(MarshallingType.SDK_POJO) + .memberName("PolymorphicTypeWithoutSubTypes") + .getter(getter(AllTypesUnionStructure::polymorphicTypeWithoutSubTypes)) + .setter(setter(Builder::polymorphicTypeWithoutSubTypes)) + .constructor(SubTypeOne::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolymorphicTypeWithoutSubTypes") + .build()).build(); private static final SdkField ENUM_TYPE_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("EnumType").getter(getter(AllTypesUnionStructure::enumTypeAsString)).setter(setter(Builder::enumType)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EnumType").build()).build(); + .memberName("EnumType").getter(getter(AllTypesUnionStructure::enumTypeAsString)).setter(setter(Builder::enumType)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EnumType").build()).build(); private static final SdkField UNDERSCORE_NAME_TYPE_FIELD = SdkField - . builder(MarshallingType.SDK_POJO).memberName("Underscore_Name_Type") - .getter(getter(AllTypesUnionStructure::underscore_Name_Type)).setter(setter(Builder::underscore_Name_Type)) - .constructor(Underscore_Name_Type::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Underscore_Name_Type").build()) - .build(); + . builder(MarshallingType.SDK_POJO).memberName("Underscore_Name_Type") + .getter(getter(AllTypesUnionStructure::underscore_Name_Type)).setter(setter(Builder::underscore_Name_Type)) + .constructor(Underscore_Name_Type::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Underscore_Name_Type").build()) + .build(); private static final SdkField MY_DOCUMENT_FIELD = SdkField. builder(MarshallingType.DOCUMENT) - .memberName("MyDocument").getter(getter(AllTypesUnionStructure::myDocument)).setter(setter(Builder::myDocument)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MyDocument").build()).build(); + .memberName("MyDocument").getter(getter(AllTypesUnionStructure::myDocument)).setter(setter(Builder::myDocument)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MyDocument").build()).build(); private static final SdkField ALL_TYPES_UNION_STRUCTURE_FIELD = SdkField - . builder(MarshallingType.SDK_POJO).memberName("AllTypesUnionStructure") - .getter(getter(AllTypesUnionStructure::allTypesUnionStructure)).setter(setter(Builder::allTypesUnionStructure)) - .constructor(AllTypesUnionStructure::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AllTypesUnionStructure").build()) - .build(); + . builder(MarshallingType.SDK_POJO).memberName("AllTypesUnionStructure") + .getter(getter(AllTypesUnionStructure::allTypesUnionStructure)).setter(setter(Builder::allTypesUnionStructure)) + .constructor(AllTypesUnionStructure::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AllTypesUnionStructure").build()) + .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STRING_MEMBER_FIELD, - INTEGER_MEMBER_FIELD, BOOLEAN_MEMBER_FIELD, FLOAT_MEMBER_FIELD, DOUBLE_MEMBER_FIELD, LONG_MEMBER_FIELD, - SHORT_MEMBER_FIELD, SIMPLE_LIST_FIELD, LIST_OF_ENUMS_FIELD, LIST_OF_MAPS_FIELD, LIST_OF_STRUCTS_FIELD, - LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD, LIST_OF_MAP_OF_STRING_TO_STRUCT_FIELD, MAP_OF_STRING_TO_INTEGER_LIST_FIELD, - MAP_OF_STRING_TO_STRING_FIELD, MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD, MAP_OF_ENUM_TO_ENUM_FIELD, - MAP_OF_ENUM_TO_STRING_FIELD, MAP_OF_STRING_TO_ENUM_FIELD, MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD, - MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD, MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD, TIMESTAMP_MEMBER_FIELD, - STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD, BLOB_ARG_FIELD, STRUCT_WITH_NESTED_BLOB_FIELD, BLOB_MAP_FIELD, - LIST_OF_BLOBS_FIELD, RECURSIVE_STRUCT_FIELD, POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD, - POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD, ENUM_TYPE_FIELD, UNDERSCORE_NAME_TYPE_FIELD, MY_DOCUMENT_FIELD, - ALL_TYPES_UNION_STRUCTURE_FIELD)); + INTEGER_MEMBER_FIELD, BOOLEAN_MEMBER_FIELD, FLOAT_MEMBER_FIELD, DOUBLE_MEMBER_FIELD, LONG_MEMBER_FIELD, + SHORT_MEMBER_FIELD, SIMPLE_LIST_FIELD, LIST_OF_ENUMS_FIELD, LIST_OF_MAPS_FIELD, LIST_OF_STRUCTS_FIELD, + LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD, LIST_OF_MAP_OF_STRING_TO_STRUCT_FIELD, MAP_OF_STRING_TO_INTEGER_LIST_FIELD, + MAP_OF_STRING_TO_STRING_FIELD, MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD, MAP_OF_ENUM_TO_ENUM_FIELD, + MAP_OF_ENUM_TO_STRING_FIELD, MAP_OF_STRING_TO_ENUM_FIELD, MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD, + MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD, MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD, TIMESTAMP_MEMBER_FIELD, + STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD, BLOB_ARG_FIELD, STRUCT_WITH_NESTED_BLOB_FIELD, BLOB_MAP_FIELD, + LIST_OF_BLOBS_FIELD, RECURSIVE_STRUCT_FIELD, POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD, + POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD, ENUM_TYPE_FIELD, UNDERSCORE_NAME_TYPE_FIELD, MY_DOCUMENT_FIELD, + ALL_TYPES_UNION_STRUCTURE_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("StringMember", STRING_MEMBER_FIELD); + put("IntegerMember", INTEGER_MEMBER_FIELD); + put("BooleanMember", BOOLEAN_MEMBER_FIELD); + put("FloatMember", FLOAT_MEMBER_FIELD); + put("DoubleMember", DOUBLE_MEMBER_FIELD); + put("LongMember", LONG_MEMBER_FIELD); + put("ShortMember", SHORT_MEMBER_FIELD); + put("SimpleList", SIMPLE_LIST_FIELD); + put("ListOfEnums", LIST_OF_ENUMS_FIELD); + put("ListOfMaps", LIST_OF_MAPS_FIELD); + put("ListOfStructs", LIST_OF_STRUCTS_FIELD); + put("ListOfMapOfEnumToString", LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD); + put("ListOfMapOfStringToStruct", LIST_OF_MAP_OF_STRING_TO_STRUCT_FIELD); + put("MapOfStringToIntegerList", MAP_OF_STRING_TO_INTEGER_LIST_FIELD); + put("MapOfStringToString", MAP_OF_STRING_TO_STRING_FIELD); + put("MapOfStringToSimpleStruct", MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD); + put("MapOfEnumToEnum", MAP_OF_ENUM_TO_ENUM_FIELD); + put("MapOfEnumToString", MAP_OF_ENUM_TO_STRING_FIELD); + put("MapOfStringToEnum", MAP_OF_STRING_TO_ENUM_FIELD); + put("MapOfEnumToSimpleStruct", MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD); + put("MapOfEnumToListOfEnums", MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD); + put("MapOfEnumToMapOfStringToEnum", MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD); + put("TimestampMember", TIMESTAMP_MEMBER_FIELD); + put("StructWithNestedTimestampMember", STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD); + put("BlobArg", BLOB_ARG_FIELD); + put("StructWithNestedBlob", STRUCT_WITH_NESTED_BLOB_FIELD); + put("BlobMap", BLOB_MAP_FIELD); + put("ListOfBlobs", LIST_OF_BLOBS_FIELD); + put("RecursiveStruct", RECURSIVE_STRUCT_FIELD); + put("PolymorphicTypeWithSubTypes", POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD); + put("PolymorphicTypeWithoutSubTypes", POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD); + put("EnumType", ENUM_TYPE_FIELD); + put("Underscore_Name_Type", UNDERSCORE_NAME_TYPE_FIELD); + put("MyDocument", MY_DOCUMENT_FIELD); + put("AllTypesUnionStructure", ALL_TYPES_UNION_STRUCTURE_FIELD); + } + }); private static final long serialVersionUID = 1L; @@ -567,7 +609,7 @@ private AllTypesUnionStructure(BuilderImpl builder) { /** * Returns the value of the StringMember property for this object. - * + * * @return The value of the StringMember property for this object. */ public final String stringMember() { @@ -576,7 +618,7 @@ public final String stringMember() { /** * Returns the value of the IntegerMember property for this object. - * + * * @return The value of the IntegerMember property for this object. */ public final Integer integerMember() { @@ -585,7 +627,7 @@ public final Integer integerMember() { /** * Returns the value of the BooleanMember property for this object. - * + * * @return The value of the BooleanMember property for this object. */ public final Boolean booleanMember() { @@ -594,7 +636,7 @@ public final Boolean booleanMember() { /** * Returns the value of the FloatMember property for this object. - * + * * @return The value of the FloatMember property for this object. */ public final Float floatMember() { @@ -603,7 +645,7 @@ public final Float floatMember() { /** * Returns the value of the DoubleMember property for this object. - * + * * @return The value of the DoubleMember property for this object. */ public final Double doubleMember() { @@ -612,7 +654,7 @@ public final Double doubleMember() { /** * Returns the value of the LongMember property for this object. - * + * * @return The value of the LongMember property for this object. */ public final Long longMember() { @@ -621,7 +663,7 @@ public final Long longMember() { /** * Returns the value of the ShortMember property for this object. - * + * * @return The value of the ShortMember property for this object. */ public final Short shortMember() { @@ -649,7 +691,7 @@ public final boolean hasSimpleList() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasSimpleList} method. *

- * + * * @return The value of the SimpleList property for this object. */ public final List simpleList() { @@ -665,7 +707,7 @@ public final List simpleList() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfEnums} method. *

- * + * * @return The value of the ListOfEnums property for this object. */ public final List listOfEnums() { @@ -693,7 +735,7 @@ public final boolean hasListOfEnums() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfEnums} method. *

- * + * * @return The value of the ListOfEnums property for this object. */ public final List listOfEnumsAsStrings() { @@ -721,7 +763,7 @@ public final boolean hasListOfMaps() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfMaps} method. *

- * + * * @return The value of the ListOfMaps property for this object. */ public final List> listOfMaps() { @@ -749,7 +791,7 @@ public final boolean hasListOfStructs() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfStructs} method. *

- * + * * @return The value of the ListOfStructs property for this object. */ public final List listOfStructs() { @@ -765,7 +807,7 @@ public final List listOfStructs() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfMapOfEnumToString} method. *

- * + * * @return The value of the ListOfMapOfEnumToString property for this object. */ public final List> listOfMapOfEnumToString() { @@ -793,7 +835,7 @@ public final boolean hasListOfMapOfEnumToString() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfMapOfEnumToString} method. *

- * + * * @return The value of the ListOfMapOfEnumToString property for this object. */ public final List> listOfMapOfEnumToStringAsStrings() { @@ -821,7 +863,7 @@ public final boolean hasListOfMapOfStringToStruct() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfMapOfStringToStruct} method. *

- * + * * @return The value of the ListOfMapOfStringToStruct property for this object. */ public final List> listOfMapOfStringToStruct() { @@ -849,7 +891,7 @@ public final boolean hasMapOfStringToIntegerList() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfStringToIntegerList} method. *

- * + * * @return The value of the MapOfStringToIntegerList property for this object. */ public final Map> mapOfStringToIntegerList() { @@ -877,7 +919,7 @@ public final boolean hasMapOfStringToString() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfStringToString} method. *

- * + * * @return The value of the MapOfStringToString property for this object. */ public final Map mapOfStringToString() { @@ -905,7 +947,7 @@ public final boolean hasMapOfStringToSimpleStruct() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfStringToSimpleStruct} method. *

- * + * * @return The value of the MapOfStringToSimpleStruct property for this object. */ public final Map mapOfStringToSimpleStruct() { @@ -921,7 +963,7 @@ public final Map mapOfStringToSimpleStruct() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToEnum} method. *

- * + * * @return The value of the MapOfEnumToEnum property for this object. */ public final Map mapOfEnumToEnum() { @@ -949,7 +991,7 @@ public final boolean hasMapOfEnumToEnum() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToEnum} method. *

- * + * * @return The value of the MapOfEnumToEnum property for this object. */ public final Map mapOfEnumToEnumAsStrings() { @@ -965,7 +1007,7 @@ public final Map mapOfEnumToEnumAsStrings() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToString} method. *

- * + * * @return The value of the MapOfEnumToString property for this object. */ public final Map mapOfEnumToString() { @@ -993,7 +1035,7 @@ public final boolean hasMapOfEnumToString() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToString} method. *

- * + * * @return The value of the MapOfEnumToString property for this object. */ public final Map mapOfEnumToStringAsStrings() { @@ -1009,7 +1051,7 @@ public final Map mapOfEnumToStringAsStrings() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfStringToEnum} method. *

- * + * * @return The value of the MapOfStringToEnum property for this object. */ public final Map mapOfStringToEnum() { @@ -1037,7 +1079,7 @@ public final boolean hasMapOfStringToEnum() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfStringToEnum} method. *

- * + * * @return The value of the MapOfStringToEnum property for this object. */ public final Map mapOfStringToEnumAsStrings() { @@ -1053,7 +1095,7 @@ public final Map mapOfStringToEnumAsStrings() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToSimpleStruct} method. *

- * + * * @return The value of the MapOfEnumToSimpleStruct property for this object. */ public final Map mapOfEnumToSimpleStruct() { @@ -1081,7 +1123,7 @@ public final boolean hasMapOfEnumToSimpleStruct() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToSimpleStruct} method. *

- * + * * @return The value of the MapOfEnumToSimpleStruct property for this object. */ public final Map mapOfEnumToSimpleStructAsStrings() { @@ -1097,7 +1139,7 @@ public final Map mapOfEnumToSimpleStructAsStrings() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToListOfEnums} method. *

- * + * * @return The value of the MapOfEnumToListOfEnums property for this object. */ public final Map> mapOfEnumToListOfEnums() { @@ -1125,7 +1167,7 @@ public final boolean hasMapOfEnumToListOfEnums() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToListOfEnums} method. *

- * + * * @return The value of the MapOfEnumToListOfEnums property for this object. */ public final Map> mapOfEnumToListOfEnumsAsStrings() { @@ -1141,7 +1183,7 @@ public final Map> mapOfEnumToListOfEnumsAsStrings() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToMapOfStringToEnum} method. *

- * + * * @return The value of the MapOfEnumToMapOfStringToEnum property for this object. */ public final Map> mapOfEnumToMapOfStringToEnum() { @@ -1169,7 +1211,7 @@ public final boolean hasMapOfEnumToMapOfStringToEnum() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMapOfEnumToMapOfStringToEnum} method. *

- * + * * @return The value of the MapOfEnumToMapOfStringToEnum property for this object. */ public final Map> mapOfEnumToMapOfStringToEnumAsStrings() { @@ -1178,7 +1220,7 @@ public final Map> mapOfEnumToMapOfStringToEnumAsStri /** * Returns the value of the TimestampMember property for this object. - * + * * @return The value of the TimestampMember property for this object. */ public final Instant timestampMember() { @@ -1187,7 +1229,7 @@ public final Instant timestampMember() { /** * Returns the value of the StructWithNestedTimestampMember property for this object. - * + * * @return The value of the StructWithNestedTimestampMember property for this object. */ public final StructWithTimestamp structWithNestedTimestampMember() { @@ -1196,7 +1238,7 @@ public final StructWithTimestamp structWithNestedTimestampMember() { /** * Returns the value of the BlobArg property for this object. - * + * * @return The value of the BlobArg property for this object. */ public final SdkBytes blobArg() { @@ -1205,7 +1247,7 @@ public final SdkBytes blobArg() { /** * Returns the value of the StructWithNestedBlob property for this object. - * + * * @return The value of the StructWithNestedBlob property for this object. */ public final StructWithNestedBlobType structWithNestedBlob() { @@ -1233,7 +1275,7 @@ public final boolean hasBlobMap() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasBlobMap} method. *

- * + * * @return The value of the BlobMap property for this object. */ public final Map blobMap() { @@ -1261,7 +1303,7 @@ public final boolean hasListOfBlobs() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfBlobs} method. *

- * + * * @return The value of the ListOfBlobs property for this object. */ public final List listOfBlobs() { @@ -1270,7 +1312,7 @@ public final List listOfBlobs() { /** * Returns the value of the RecursiveStruct property for this object. - * + * * @return The value of the RecursiveStruct property for this object. */ public final RecursiveStructType recursiveStruct() { @@ -1279,7 +1321,7 @@ public final RecursiveStructType recursiveStruct() { /** * Returns the value of the PolymorphicTypeWithSubTypes property for this object. - * + * * @return The value of the PolymorphicTypeWithSubTypes property for this object. */ public final BaseType polymorphicTypeWithSubTypes() { @@ -1288,7 +1330,7 @@ public final BaseType polymorphicTypeWithSubTypes() { /** * Returns the value of the PolymorphicTypeWithoutSubTypes property for this object. - * + * * @return The value of the PolymorphicTypeWithoutSubTypes property for this object. */ public final SubTypeOne polymorphicTypeWithoutSubTypes() { @@ -1302,7 +1344,7 @@ public final SubTypeOne polymorphicTypeWithoutSubTypes() { * return {@link EnumType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #enumTypeAsString}. *

- * + * * @return The value of the EnumType property for this object. * @see EnumType */ @@ -1317,7 +1359,7 @@ public final EnumType enumType() { * return {@link EnumType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #enumTypeAsString}. *

- * + * * @return The value of the EnumType property for this object. * @see EnumType */ @@ -1327,7 +1369,7 @@ public final String enumTypeAsString() { /** * Returns the value of the Underscore_Name_Type property for this object. - * + * * @return The value of the Underscore_Name_Type property for this object. */ public final Underscore_Name_Type underscore_Name_Type() { @@ -1336,7 +1378,7 @@ public final Underscore_Name_Type underscore_Name_Type() { /** * Returns the value of the MyDocument property for this object. - * + * * @return The value of the MyDocument property for this object. */ public final Document myDocument() { @@ -1345,7 +1387,7 @@ public final Document myDocument() { /** * Returns the value of the AllTypesUnionStructure property for this object. - * + * * @return The value of the AllTypesUnionStructure property for this object. */ public final AllTypesUnionStructure allTypesUnionStructure() { @@ -1390,7 +1432,7 @@ public final int hashCode() { hashCode = 31 * hashCode + Objects.hashCode(hasMapOfEnumToSimpleStruct() ? mapOfEnumToSimpleStructAsStrings() : null); hashCode = 31 * hashCode + Objects.hashCode(hasMapOfEnumToListOfEnums() ? mapOfEnumToListOfEnumsAsStrings() : null); hashCode = 31 * hashCode - + Objects.hashCode(hasMapOfEnumToMapOfStringToEnum() ? mapOfEnumToMapOfStringToEnumAsStrings() : null); + + Objects.hashCode(hasMapOfEnumToMapOfStringToEnum() ? mapOfEnumToMapOfStringToEnumAsStrings() : null); hashCode = 31 * hashCode + Objects.hashCode(timestampMember()); hashCode = 31 * hashCode + Objects.hashCode(structWithNestedTimestampMember()); hashCode = 31 * hashCode + Objects.hashCode(blobArg()); @@ -1425,48 +1467,48 @@ public final boolean equalsBySdkFields(Object obj) { } AllTypesUnionStructure other = (AllTypesUnionStructure) obj; return Objects.equals(stringMember(), other.stringMember()) && Objects.equals(integerMember(), other.integerMember()) - && Objects.equals(booleanMember(), other.booleanMember()) && Objects.equals(floatMember(), other.floatMember()) - && Objects.equals(doubleMember(), other.doubleMember()) && Objects.equals(longMember(), other.longMember()) - && Objects.equals(shortMember(), other.shortMember()) && hasSimpleList() == other.hasSimpleList() - && Objects.equals(simpleList(), other.simpleList()) && hasListOfEnums() == other.hasListOfEnums() - && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) - && hasListOfMaps() == other.hasListOfMaps() && Objects.equals(listOfMaps(), other.listOfMaps()) - && hasListOfStructs() == other.hasListOfStructs() && Objects.equals(listOfStructs(), other.listOfStructs()) - && hasListOfMapOfEnumToString() == other.hasListOfMapOfEnumToString() - && Objects.equals(listOfMapOfEnumToStringAsStrings(), other.listOfMapOfEnumToStringAsStrings()) - && hasListOfMapOfStringToStruct() == other.hasListOfMapOfStringToStruct() - && Objects.equals(listOfMapOfStringToStruct(), other.listOfMapOfStringToStruct()) - && hasMapOfStringToIntegerList() == other.hasMapOfStringToIntegerList() - && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) - && hasMapOfStringToString() == other.hasMapOfStringToString() - && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) - && hasMapOfStringToSimpleStruct() == other.hasMapOfStringToSimpleStruct() - && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) - && hasMapOfEnumToEnum() == other.hasMapOfEnumToEnum() - && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) - && hasMapOfEnumToString() == other.hasMapOfEnumToString() - && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) - && hasMapOfStringToEnum() == other.hasMapOfStringToEnum() - && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) - && hasMapOfEnumToSimpleStruct() == other.hasMapOfEnumToSimpleStruct() - && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) - && hasMapOfEnumToListOfEnums() == other.hasMapOfEnumToListOfEnums() - && Objects.equals(mapOfEnumToListOfEnumsAsStrings(), other.mapOfEnumToListOfEnumsAsStrings()) - && hasMapOfEnumToMapOfStringToEnum() == other.hasMapOfEnumToMapOfStringToEnum() - && Objects.equals(mapOfEnumToMapOfStringToEnumAsStrings(), other.mapOfEnumToMapOfStringToEnumAsStrings()) - && Objects.equals(timestampMember(), other.timestampMember()) - && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) - && Objects.equals(blobArg(), other.blobArg()) - && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) && hasBlobMap() == other.hasBlobMap() - && Objects.equals(blobMap(), other.blobMap()) && hasListOfBlobs() == other.hasListOfBlobs() - && Objects.equals(listOfBlobs(), other.listOfBlobs()) - && Objects.equals(recursiveStruct(), other.recursiveStruct()) - && Objects.equals(polymorphicTypeWithSubTypes(), other.polymorphicTypeWithSubTypes()) - && Objects.equals(polymorphicTypeWithoutSubTypes(), other.polymorphicTypeWithoutSubTypes()) - && Objects.equals(enumTypeAsString(), other.enumTypeAsString()) - && Objects.equals(underscore_Name_Type(), other.underscore_Name_Type()) - && Objects.equals(myDocument(), other.myDocument()) - && Objects.equals(allTypesUnionStructure(), other.allTypesUnionStructure()); + && Objects.equals(booleanMember(), other.booleanMember()) && Objects.equals(floatMember(), other.floatMember()) + && Objects.equals(doubleMember(), other.doubleMember()) && Objects.equals(longMember(), other.longMember()) + && Objects.equals(shortMember(), other.shortMember()) && hasSimpleList() == other.hasSimpleList() + && Objects.equals(simpleList(), other.simpleList()) && hasListOfEnums() == other.hasListOfEnums() + && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) + && hasListOfMaps() == other.hasListOfMaps() && Objects.equals(listOfMaps(), other.listOfMaps()) + && hasListOfStructs() == other.hasListOfStructs() && Objects.equals(listOfStructs(), other.listOfStructs()) + && hasListOfMapOfEnumToString() == other.hasListOfMapOfEnumToString() + && Objects.equals(listOfMapOfEnumToStringAsStrings(), other.listOfMapOfEnumToStringAsStrings()) + && hasListOfMapOfStringToStruct() == other.hasListOfMapOfStringToStruct() + && Objects.equals(listOfMapOfStringToStruct(), other.listOfMapOfStringToStruct()) + && hasMapOfStringToIntegerList() == other.hasMapOfStringToIntegerList() + && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) + && hasMapOfStringToString() == other.hasMapOfStringToString() + && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) + && hasMapOfStringToSimpleStruct() == other.hasMapOfStringToSimpleStruct() + && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) + && hasMapOfEnumToEnum() == other.hasMapOfEnumToEnum() + && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) + && hasMapOfEnumToString() == other.hasMapOfEnumToString() + && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) + && hasMapOfStringToEnum() == other.hasMapOfStringToEnum() + && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) + && hasMapOfEnumToSimpleStruct() == other.hasMapOfEnumToSimpleStruct() + && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) + && hasMapOfEnumToListOfEnums() == other.hasMapOfEnumToListOfEnums() + && Objects.equals(mapOfEnumToListOfEnumsAsStrings(), other.mapOfEnumToListOfEnumsAsStrings()) + && hasMapOfEnumToMapOfStringToEnum() == other.hasMapOfEnumToMapOfStringToEnum() + && Objects.equals(mapOfEnumToMapOfStringToEnumAsStrings(), other.mapOfEnumToMapOfStringToEnumAsStrings()) + && Objects.equals(timestampMember(), other.timestampMember()) + && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) + && Objects.equals(blobArg(), other.blobArg()) + && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) && hasBlobMap() == other.hasBlobMap() + && Objects.equals(blobMap(), other.blobMap()) && hasListOfBlobs() == other.hasListOfBlobs() + && Objects.equals(listOfBlobs(), other.listOfBlobs()) + && Objects.equals(recursiveStruct(), other.recursiveStruct()) + && Objects.equals(polymorphicTypeWithSubTypes(), other.polymorphicTypeWithSubTypes()) + && Objects.equals(polymorphicTypeWithoutSubTypes(), other.polymorphicTypeWithoutSubTypes()) + && Objects.equals(enumTypeAsString(), other.enumTypeAsString()) + && Objects.equals(underscore_Name_Type(), other.underscore_Name_Type()) + && Objects.equals(myDocument(), other.myDocument()) + && Objects.equals(allTypesUnionStructure(), other.allTypesUnionStructure()); } /** @@ -1476,114 +1518,114 @@ && hasMapOfEnumToMapOfStringToEnum() == other.hasMapOfEnumToMapOfStringToEnum() @Override public final String toString() { return ToString - .builder("AllTypesUnionStructure") - .add("StringMember", stringMember()) - .add("IntegerMember", integerMember()) - .add("BooleanMember", booleanMember()) - .add("FloatMember", floatMember()) - .add("DoubleMember", doubleMember()) - .add("LongMember", longMember()) - .add("ShortMember", shortMember()) - .add("SimpleList", hasSimpleList() ? simpleList() : null) - .add("ListOfEnums", hasListOfEnums() ? listOfEnumsAsStrings() : null) - .add("ListOfMaps", hasListOfMaps() ? listOfMaps() : null) - .add("ListOfStructs", hasListOfStructs() ? listOfStructs() : null) - .add("ListOfMapOfEnumToString", hasListOfMapOfEnumToString() ? listOfMapOfEnumToStringAsStrings() : null) - .add("ListOfMapOfStringToStruct", hasListOfMapOfStringToStruct() ? listOfMapOfStringToStruct() : null) - .add("MapOfStringToIntegerList", hasMapOfStringToIntegerList() ? mapOfStringToIntegerList() : null) - .add("MapOfStringToString", hasMapOfStringToString() ? mapOfStringToString() : null) - .add("MapOfStringToSimpleStruct", hasMapOfStringToSimpleStruct() ? mapOfStringToSimpleStruct() : null) - .add("MapOfEnumToEnum", hasMapOfEnumToEnum() ? mapOfEnumToEnumAsStrings() : null) - .add("MapOfEnumToString", hasMapOfEnumToString() ? mapOfEnumToStringAsStrings() : null) - .add("MapOfStringToEnum", hasMapOfStringToEnum() ? mapOfStringToEnumAsStrings() : null) - .add("MapOfEnumToSimpleStruct", hasMapOfEnumToSimpleStruct() ? mapOfEnumToSimpleStructAsStrings() : null) - .add("MapOfEnumToListOfEnums", hasMapOfEnumToListOfEnums() ? mapOfEnumToListOfEnumsAsStrings() : null) - .add("MapOfEnumToMapOfStringToEnum", - hasMapOfEnumToMapOfStringToEnum() ? mapOfEnumToMapOfStringToEnumAsStrings() : null) - .add("TimestampMember", timestampMember()) - .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) - .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", hasBlobMap() ? blobMap() : null) - .add("ListOfBlobs", hasListOfBlobs() ? listOfBlobs() : null).add("RecursiveStruct", recursiveStruct()) - .add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) - .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) - .add("Underscore_Name_Type", underscore_Name_Type()).add("MyDocument", myDocument()) - .add("AllTypesUnionStructure", allTypesUnionStructure()).build(); + .builder("AllTypesUnionStructure") + .add("StringMember", stringMember()) + .add("IntegerMember", integerMember()) + .add("BooleanMember", booleanMember()) + .add("FloatMember", floatMember()) + .add("DoubleMember", doubleMember()) + .add("LongMember", longMember()) + .add("ShortMember", shortMember()) + .add("SimpleList", hasSimpleList() ? simpleList() : null) + .add("ListOfEnums", hasListOfEnums() ? listOfEnumsAsStrings() : null) + .add("ListOfMaps", hasListOfMaps() ? listOfMaps() : null) + .add("ListOfStructs", hasListOfStructs() ? listOfStructs() : null) + .add("ListOfMapOfEnumToString", hasListOfMapOfEnumToString() ? listOfMapOfEnumToStringAsStrings() : null) + .add("ListOfMapOfStringToStruct", hasListOfMapOfStringToStruct() ? listOfMapOfStringToStruct() : null) + .add("MapOfStringToIntegerList", hasMapOfStringToIntegerList() ? mapOfStringToIntegerList() : null) + .add("MapOfStringToString", hasMapOfStringToString() ? mapOfStringToString() : null) + .add("MapOfStringToSimpleStruct", hasMapOfStringToSimpleStruct() ? mapOfStringToSimpleStruct() : null) + .add("MapOfEnumToEnum", hasMapOfEnumToEnum() ? mapOfEnumToEnumAsStrings() : null) + .add("MapOfEnumToString", hasMapOfEnumToString() ? mapOfEnumToStringAsStrings() : null) + .add("MapOfStringToEnum", hasMapOfStringToEnum() ? mapOfStringToEnumAsStrings() : null) + .add("MapOfEnumToSimpleStruct", hasMapOfEnumToSimpleStruct() ? mapOfEnumToSimpleStructAsStrings() : null) + .add("MapOfEnumToListOfEnums", hasMapOfEnumToListOfEnums() ? mapOfEnumToListOfEnumsAsStrings() : null) + .add("MapOfEnumToMapOfStringToEnum", + hasMapOfEnumToMapOfStringToEnum() ? mapOfEnumToMapOfStringToEnumAsStrings() : null) + .add("TimestampMember", timestampMember()) + .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) + .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", hasBlobMap() ? blobMap() : null) + .add("ListOfBlobs", hasListOfBlobs() ? listOfBlobs() : null).add("RecursiveStruct", recursiveStruct()) + .add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) + .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) + .add("Underscore_Name_Type", underscore_Name_Type()).add("MyDocument", myDocument()) + .add("AllTypesUnionStructure", allTypesUnionStructure()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "StringMember": - return Optional.ofNullable(clazz.cast(stringMember())); - case "IntegerMember": - return Optional.ofNullable(clazz.cast(integerMember())); - case "BooleanMember": - return Optional.ofNullable(clazz.cast(booleanMember())); - case "FloatMember": - return Optional.ofNullable(clazz.cast(floatMember())); - case "DoubleMember": - return Optional.ofNullable(clazz.cast(doubleMember())); - case "LongMember": - return Optional.ofNullable(clazz.cast(longMember())); - case "ShortMember": - return Optional.ofNullable(clazz.cast(shortMember())); - case "SimpleList": - return Optional.ofNullable(clazz.cast(simpleList())); - case "ListOfEnums": - return Optional.ofNullable(clazz.cast(listOfEnumsAsStrings())); - case "ListOfMaps": - return Optional.ofNullable(clazz.cast(listOfMaps())); - case "ListOfStructs": - return Optional.ofNullable(clazz.cast(listOfStructs())); - case "ListOfMapOfEnumToString": - return Optional.ofNullable(clazz.cast(listOfMapOfEnumToStringAsStrings())); - case "ListOfMapOfStringToStruct": - return Optional.ofNullable(clazz.cast(listOfMapOfStringToStruct())); - case "MapOfStringToIntegerList": - return Optional.ofNullable(clazz.cast(mapOfStringToIntegerList())); - case "MapOfStringToString": - return Optional.ofNullable(clazz.cast(mapOfStringToString())); - case "MapOfStringToSimpleStruct": - return Optional.ofNullable(clazz.cast(mapOfStringToSimpleStruct())); - case "MapOfEnumToEnum": - return Optional.ofNullable(clazz.cast(mapOfEnumToEnumAsStrings())); - case "MapOfEnumToString": - return Optional.ofNullable(clazz.cast(mapOfEnumToStringAsStrings())); - case "MapOfStringToEnum": - return Optional.ofNullable(clazz.cast(mapOfStringToEnumAsStrings())); - case "MapOfEnumToSimpleStruct": - return Optional.ofNullable(clazz.cast(mapOfEnumToSimpleStructAsStrings())); - case "MapOfEnumToListOfEnums": - return Optional.ofNullable(clazz.cast(mapOfEnumToListOfEnumsAsStrings())); - case "MapOfEnumToMapOfStringToEnum": - return Optional.ofNullable(clazz.cast(mapOfEnumToMapOfStringToEnumAsStrings())); - case "TimestampMember": - return Optional.ofNullable(clazz.cast(timestampMember())); - case "StructWithNestedTimestampMember": - return Optional.ofNullable(clazz.cast(structWithNestedTimestampMember())); - case "BlobArg": - return Optional.ofNullable(clazz.cast(blobArg())); - case "StructWithNestedBlob": - return Optional.ofNullable(clazz.cast(structWithNestedBlob())); - case "BlobMap": - return Optional.ofNullable(clazz.cast(blobMap())); - case "ListOfBlobs": - return Optional.ofNullable(clazz.cast(listOfBlobs())); - case "RecursiveStruct": - return Optional.ofNullable(clazz.cast(recursiveStruct())); - case "PolymorphicTypeWithSubTypes": - return Optional.ofNullable(clazz.cast(polymorphicTypeWithSubTypes())); - case "PolymorphicTypeWithoutSubTypes": - return Optional.ofNullable(clazz.cast(polymorphicTypeWithoutSubTypes())); - case "EnumType": - return Optional.ofNullable(clazz.cast(enumTypeAsString())); - case "Underscore_Name_Type": - return Optional.ofNullable(clazz.cast(underscore_Name_Type())); - case "MyDocument": - return Optional.ofNullable(clazz.cast(myDocument())); - case "AllTypesUnionStructure": - return Optional.ofNullable(clazz.cast(allTypesUnionStructure())); - default: - return Optional.empty(); + case "StringMember": + return Optional.ofNullable(clazz.cast(stringMember())); + case "IntegerMember": + return Optional.ofNullable(clazz.cast(integerMember())); + case "BooleanMember": + return Optional.ofNullable(clazz.cast(booleanMember())); + case "FloatMember": + return Optional.ofNullable(clazz.cast(floatMember())); + case "DoubleMember": + return Optional.ofNullable(clazz.cast(doubleMember())); + case "LongMember": + return Optional.ofNullable(clazz.cast(longMember())); + case "ShortMember": + return Optional.ofNullable(clazz.cast(shortMember())); + case "SimpleList": + return Optional.ofNullable(clazz.cast(simpleList())); + case "ListOfEnums": + return Optional.ofNullable(clazz.cast(listOfEnumsAsStrings())); + case "ListOfMaps": + return Optional.ofNullable(clazz.cast(listOfMaps())); + case "ListOfStructs": + return Optional.ofNullable(clazz.cast(listOfStructs())); + case "ListOfMapOfEnumToString": + return Optional.ofNullable(clazz.cast(listOfMapOfEnumToStringAsStrings())); + case "ListOfMapOfStringToStruct": + return Optional.ofNullable(clazz.cast(listOfMapOfStringToStruct())); + case "MapOfStringToIntegerList": + return Optional.ofNullable(clazz.cast(mapOfStringToIntegerList())); + case "MapOfStringToString": + return Optional.ofNullable(clazz.cast(mapOfStringToString())); + case "MapOfStringToSimpleStruct": + return Optional.ofNullable(clazz.cast(mapOfStringToSimpleStruct())); + case "MapOfEnumToEnum": + return Optional.ofNullable(clazz.cast(mapOfEnumToEnumAsStrings())); + case "MapOfEnumToString": + return Optional.ofNullable(clazz.cast(mapOfEnumToStringAsStrings())); + case "MapOfStringToEnum": + return Optional.ofNullable(clazz.cast(mapOfStringToEnumAsStrings())); + case "MapOfEnumToSimpleStruct": + return Optional.ofNullable(clazz.cast(mapOfEnumToSimpleStructAsStrings())); + case "MapOfEnumToListOfEnums": + return Optional.ofNullable(clazz.cast(mapOfEnumToListOfEnumsAsStrings())); + case "MapOfEnumToMapOfStringToEnum": + return Optional.ofNullable(clazz.cast(mapOfEnumToMapOfStringToEnumAsStrings())); + case "TimestampMember": + return Optional.ofNullable(clazz.cast(timestampMember())); + case "StructWithNestedTimestampMember": + return Optional.ofNullable(clazz.cast(structWithNestedTimestampMember())); + case "BlobArg": + return Optional.ofNullable(clazz.cast(blobArg())); + case "StructWithNestedBlob": + return Optional.ofNullable(clazz.cast(structWithNestedBlob())); + case "BlobMap": + return Optional.ofNullable(clazz.cast(blobMap())); + case "ListOfBlobs": + return Optional.ofNullable(clazz.cast(listOfBlobs())); + case "RecursiveStruct": + return Optional.ofNullable(clazz.cast(recursiveStruct())); + case "PolymorphicTypeWithSubTypes": + return Optional.ofNullable(clazz.cast(polymorphicTypeWithSubTypes())); + case "PolymorphicTypeWithoutSubTypes": + return Optional.ofNullable(clazz.cast(polymorphicTypeWithoutSubTypes())); + case "EnumType": + return Optional.ofNullable(clazz.cast(enumTypeAsString())); + case "Underscore_Name_Type": + return Optional.ofNullable(clazz.cast(underscore_Name_Type())); + case "MyDocument": + return Optional.ofNullable(clazz.cast(myDocument())); + case "AllTypesUnionStructure": + return Optional.ofNullable(clazz.cast(allTypesUnionStructure())); + default: + return Optional.empty(); } } @@ -1740,7 +1782,7 @@ public static AllTypesUnionStructure fromListOfStructs(List listOf * The new value for the ListOfMapOfEnumToString property for this object. */ public static AllTypesUnionStructure fromListOfMapOfEnumToStringWithStrings( - List> listOfMapOfEnumToStringWithStrings) { + List> listOfMapOfEnumToStringWithStrings) { return builder().listOfMapOfEnumToStringWithStrings(listOfMapOfEnumToStringWithStrings).build(); } @@ -1753,7 +1795,7 @@ public static AllTypesUnionStructure fromListOfMapOfEnumToStringWithStrings( * The new value for the ListOfMapOfEnumToString property for this object. */ public static AllTypesUnionStructure fromListOfMapOfEnumToString( - List> listOfMapOfEnumToStringWithStrings) { + List> listOfMapOfEnumToStringWithStrings) { return builder().listOfMapOfEnumToString(listOfMapOfEnumToStringWithStrings).build(); } @@ -1886,7 +1928,7 @@ public static AllTypesUnionStructure fromMapOfStringToEnum(Map * The new value for the MapOfEnumToSimpleStruct property for this object. */ public static AllTypesUnionStructure fromMapOfEnumToSimpleStructWithStrings( - Map mapOfEnumToSimpleStructWithStrings) { + Map mapOfEnumToSimpleStructWithStrings) { return builder().mapOfEnumToSimpleStructWithStrings(mapOfEnumToSimpleStructWithStrings).build(); } @@ -1899,7 +1941,7 @@ public static AllTypesUnionStructure fromMapOfEnumToSimpleStructWithStrings( * The new value for the MapOfEnumToSimpleStruct property for this object. */ public static AllTypesUnionStructure fromMapOfEnumToSimpleStruct( - Map mapOfEnumToSimpleStructWithStrings) { + Map mapOfEnumToSimpleStructWithStrings) { return builder().mapOfEnumToSimpleStruct(mapOfEnumToSimpleStructWithStrings).build(); } @@ -1912,7 +1954,7 @@ public static AllTypesUnionStructure fromMapOfEnumToSimpleStruct( * The new value for the MapOfEnumToListOfEnums property for this object. */ public static AllTypesUnionStructure fromMapOfEnumToListOfEnumsWithStrings( - Map> mapOfEnumToListOfEnumsWithStrings) { + Map> mapOfEnumToListOfEnumsWithStrings) { return builder().mapOfEnumToListOfEnumsWithStrings(mapOfEnumToListOfEnumsWithStrings).build(); } @@ -1925,7 +1967,7 @@ public static AllTypesUnionStructure fromMapOfEnumToListOfEnumsWithStrings( * The new value for the MapOfEnumToListOfEnums property for this object. */ public static AllTypesUnionStructure fromMapOfEnumToListOfEnums( - Map> mapOfEnumToListOfEnumsWithStrings) { + Map> mapOfEnumToListOfEnumsWithStrings) { return builder().mapOfEnumToListOfEnums(mapOfEnumToListOfEnumsWithStrings).build(); } @@ -1939,7 +1981,7 @@ public static AllTypesUnionStructure fromMapOfEnumToListOfEnums( * The new value for the MapOfEnumToMapOfStringToEnum property for this object. */ public static AllTypesUnionStructure fromMapOfEnumToMapOfStringToEnumWithStrings( - Map> mapOfEnumToMapOfStringToEnumWithStrings) { + Map> mapOfEnumToMapOfStringToEnumWithStrings) { return builder().mapOfEnumToMapOfStringToEnumWithStrings(mapOfEnumToMapOfStringToEnumWithStrings).build(); } @@ -1953,7 +1995,7 @@ public static AllTypesUnionStructure fromMapOfEnumToMapOfStringToEnumWithStrings * The new value for the MapOfEnumToMapOfStringToEnum property for this object. */ public static AllTypesUnionStructure fromMapOfEnumToMapOfStringToEnum( - Map> mapOfEnumToMapOfStringToEnumWithStrings) { + Map> mapOfEnumToMapOfStringToEnumWithStrings) { return builder().mapOfEnumToMapOfStringToEnum(mapOfEnumToMapOfStringToEnumWithStrings).build(); } @@ -1990,7 +2032,7 @@ public static AllTypesUnionStructure fromStructWithNestedTimestampMember(StructW * The new value for the StructWithNestedTimestampMember property for this object. */ public static AllTypesUnionStructure fromStructWithNestedTimestampMember( - Consumer structWithNestedTimestampMember) { + Consumer structWithNestedTimestampMember) { StructWithTimestamp.Builder builder = StructWithTimestamp.builder(); structWithNestedTimestampMember.accept(builder); return fromStructWithNestedTimestampMember(builder.build()); @@ -2131,7 +2173,7 @@ public static AllTypesUnionStructure fromPolymorphicTypeWithoutSubTypes(SubTypeO * The new value for the PolymorphicTypeWithoutSubTypes property for this object. */ public static AllTypesUnionStructure fromPolymorphicTypeWithoutSubTypes( - Consumer polymorphicTypeWithoutSubTypes) { + Consumer polymorphicTypeWithoutSubTypes) { SubTypeOne.Builder builder = SubTypeOne.builder(); polymorphicTypeWithoutSubTypes.accept(builder); return fromPolymorphicTypeWithoutSubTypes(builder.build()); @@ -2245,6 +2287,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((AllTypesUnionStructure) obj); } @@ -2419,7 +2466,7 @@ public interface Builder extends SdkPojo, CopyableBuilder)}. - * + * * @param listOfStructs * a consumer that will call methods on * {@link software.amazon.awssdk.services.jsonprotocoltests.model.SimpleStruct.Builder} @@ -2626,7 +2673,7 @@ public interface Builder extends SdkPojo, CopyableBuilder * When the {@link Consumer} completes, {@link StructWithTimestamp.Builder#build()} is called immediately and * its result is passed to {@link #structWithNestedTimestampMember(StructWithTimestamp)}. - * + * * @param structWithNestedTimestampMember * a consumer that will call methods on {@link StructWithTimestamp.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -2634,7 +2681,7 @@ public interface Builder extends SdkPojo, CopyableBuilder structWithNestedTimestampMember) { return structWithNestedTimestampMember(StructWithTimestamp.builder().applyMutation(structWithNestedTimestampMember) - .build()); + .build()); } /** @@ -2664,7 +2711,7 @@ default Builder structWithNestedTimestampMember(Consumer * When the {@link Consumer} completes, {@link StructWithNestedBlobType.Builder#build()} is called immediately * and its result is passed to {@link #structWithNestedBlob(StructWithNestedBlobType)}. - * + * * @param structWithNestedBlob * a consumer that will call methods on {@link StructWithNestedBlobType.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -2719,7 +2766,7 @@ default Builder structWithNestedBlob(Consumer *

* When the {@link Consumer} completes, {@link RecursiveStructType.Builder#build()} is called immediately and * its result is passed to {@link #recursiveStruct(RecursiveStructType)}. - * + * * @param recursiveStruct * a consumer that will call methods on {@link RecursiveStructType.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -2747,7 +2794,7 @@ default Builder recursiveStruct(Consumer recursiveS *

* When the {@link Consumer} completes, {@link BaseType.Builder#build()} is called immediately and its result is * passed to {@link #polymorphicTypeWithSubTypes(BaseType)}. - * + * * @param polymorphicTypeWithSubTypes * a consumer that will call methods on {@link BaseType.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -2775,7 +2822,7 @@ default Builder polymorphicTypeWithSubTypes(Consumer polymorph *

* When the {@link Consumer} completes, {@link SubTypeOne.Builder#build()} is called immediately and its result * is passed to {@link #polymorphicTypeWithoutSubTypes(SubTypeOne)}. - * + * * @param polymorphicTypeWithoutSubTypes * a consumer that will call methods on {@link SubTypeOne.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -2825,7 +2872,7 @@ default Builder polymorphicTypeWithoutSubTypes(Consumer poly *

* When the {@link Consumer} completes, {@link Underscore_Name_Type.Builder#build()} is called immediately and * its result is passed to {@link #underscore_Name_Type(Underscore_Name_Type)}. - * + * * @param underscore_Name_Type * a consumer that will call methods on {@link Underscore_Name_Type.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -2862,7 +2909,7 @@ default Builder underscore_Name_Type(Consumer unde *

* When the {@link Consumer} completes, {@link AllTypesUnionStructure.Builder#build()} is called immediately and * its result is passed to {@link #allTypesUnionStructure(AllTypesUnionStructure)}. - * + * * @param allTypesUnionStructure * a consumer that will call methods on {@link AllTypesUnionStructure.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -3247,7 +3294,7 @@ public final Builder listOfStructs(SimpleStruct... listOfStructs) { @SafeVarargs public final Builder listOfStructs(Consumer... listOfStructs) { listOfStructs(Stream.of(listOfStructs).map(c -> SimpleStruct.builder().applyMutation(c).build()) - .collect(Collectors.toList())); + .collect(Collectors.toList())); return this; } @@ -3281,7 +3328,7 @@ public final Builder listOfMapOfEnumToStringWithStrings(Map... l public final List> getListOfMapOfStringToStruct() { List> result = ListOfMapOfStringToStructCopier - .copyToBuilder(this.listOfMapOfStringToStruct); + .copyToBuilder(this.listOfMapOfStringToStruct); if (result instanceof SdkAutoConstructList) { return null; } @@ -3289,7 +3336,7 @@ public final List> getListOfMapOfStringToStruc } public final void setListOfMapOfStringToStruct( - Collection> listOfMapOfStringToStruct) { + Collection> listOfMapOfStringToStruct) { Object oldValue = this.listOfMapOfStringToStruct; this.listOfMapOfStringToStruct = ListOfMapOfStringToStructCopier.copyFromBuilder(listOfMapOfStringToStruct); handleUnionValueChange(Type.LIST_OF_MAP_OF_STRING_TO_STRUCT, oldValue, this.listOfMapOfStringToStruct); @@ -3354,7 +3401,7 @@ public final Builder mapOfStringToString(Map mapOfStringToString public final Map getMapOfStringToSimpleStruct() { Map result = MapOfStringToSimpleStructCopier - .copyToBuilder(this.mapOfStringToSimpleStruct); + .copyToBuilder(this.mapOfStringToSimpleStruct); if (result instanceof SdkAutoConstructMap) { return null; } @@ -3536,7 +3583,7 @@ public final void setMapOfEnumToMapOfStringToEnum(Map> mapOfEnumToMapOfStringToEnum) { + Map> mapOfEnumToMapOfStringToEnum) { Object oldValue = this.mapOfEnumToMapOfStringToEnum; this.mapOfEnumToMapOfStringToEnum = MapOfEnumToMapOfStringToEnumCopier.copy(mapOfEnumToMapOfStringToEnum); handleUnionValueChange(Type.MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM, oldValue, this.mapOfEnumToMapOfStringToEnum); @@ -3545,7 +3592,7 @@ public final Builder mapOfEnumToMapOfStringToEnumWithStrings( @Override public final Builder mapOfEnumToMapOfStringToEnum( - Map> mapOfEnumToMapOfStringToEnum) { + Map> mapOfEnumToMapOfStringToEnum) { Object oldValue = this.mapOfEnumToMapOfStringToEnum; this.mapOfEnumToMapOfStringToEnum = MapOfEnumToMapOfStringToEnumCopier.copyEnumToString(mapOfEnumToMapOfStringToEnum); handleUnionValueChange(Type.MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM, oldValue, this.mapOfEnumToMapOfStringToEnum); @@ -3577,7 +3624,7 @@ public final StructWithTimestamp.Builder getStructWithNestedTimestampMember() { public final void setStructWithNestedTimestampMember(StructWithTimestamp.BuilderImpl structWithNestedTimestampMember) { Object oldValue = this.structWithNestedTimestampMember; this.structWithNestedTimestampMember = structWithNestedTimestampMember != null ? structWithNestedTimestampMember - .build() : null; + .build() : null; handleUnionValueChange(Type.STRUCT_WITH_NESTED_TIMESTAMP_MEMBER, oldValue, this.structWithNestedTimestampMember); } @@ -3628,12 +3675,12 @@ public final Map getBlobMap() { return null; } return blobMap == null ? null : blobMap.entrySet().stream() - .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().asByteBuffer())); + .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().asByteBuffer())); } public final void setBlobMap(Map blobMap) { blobMap(blobMap == null ? null : blobMap.entrySet().stream() - .collect(Collectors.toMap(e -> e.getKey(), e -> SdkBytes.fromByteBuffer(e.getValue())))); + .collect(Collectors.toMap(e -> e.getKey(), e -> SdkBytes.fromByteBuffer(e.getValue())))); } @Override @@ -3653,7 +3700,7 @@ public final List getListOfBlobs() { public final void setListOfBlobs(Collection listOfBlobs) { listOfBlobs(listOfBlobs == null ? null : listOfBlobs.stream().map(SdkBytes::fromByteBuffer) - .collect(Collectors.toList())); + .collect(Collectors.toList())); } @Override @@ -3714,7 +3761,7 @@ public final SubTypeOne.Builder getPolymorphicTypeWithoutSubTypes() { public final void setPolymorphicTypeWithoutSubTypes(SubTypeOne.BuilderImpl polymorphicTypeWithoutSubTypes) { Object oldValue = this.polymorphicTypeWithoutSubTypes; this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.build() - : null; + : null; handleUnionValueChange(Type.POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES, oldValue, this.polymorphicTypeWithoutSubTypes); } @@ -3814,6 +3861,11 @@ public List> sdkFields() { return SDK_FIELDS; } + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private final void handleUnionValueChange(Type type, Object oldValue, Object newValue) { if (this.type == type || oldValue == newValue) { return; diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/basetype.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/basetype.java index c185dc837ab9..d7ad45dff2b6 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/basetype.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/basetype.java @@ -3,7 +3,9 @@ import java.io.Serializable; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -23,11 +25,18 @@ @Generated("software.amazon.awssdk:codegen") public final class BaseType implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField BASE_MEMBER_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("BaseMember").getter(getter(BaseType::baseMember)).setter(setter(Builder::baseMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BaseMember").build()).build(); + .memberName("BaseMember").getter(getter(BaseType::baseMember)).setter(setter(Builder::baseMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BaseMember").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BASE_MEMBER_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("BaseMember", BASE_MEMBER_FIELD); + } + }); + private static final long serialVersionUID = 1L; private final String baseMember; @@ -44,7 +53,7 @@ private BaseType(BuilderImpl builder) { /** * Returns the value of the BaseMember property for this object. - * + * * @return The value of the BaseMember property for this object. */ public final String baseMember() { @@ -53,7 +62,7 @@ public final String baseMember() { /** * Custom shape of type string - * + * * @return Custom shape of type string */ public final String customShape1() { @@ -62,7 +71,7 @@ public final String customShape1() { /** * Custom shape of type integer - * + * * @return Custom shape of type integer */ public final Integer customShape2() { @@ -109,7 +118,7 @@ public final boolean equalsBySdkFields(Object obj) { } BaseType other = (BaseType) obj; return Objects.equals(baseMember(), other.baseMember()) && Objects.equals(customShape1(), other.customShape1()) - && Objects.equals(customShape2(), other.customShape2()); + && Objects.equals(customShape2(), other.customShape2()); } /** @@ -119,19 +128,19 @@ public final boolean equalsBySdkFields(Object obj) { @Override public final String toString() { return ToString.builder("BaseType").add("BaseMember", baseMember()).add("CustomShape1", customShape1()) - .add("CustomShape2", customShape2()).build(); + .add("CustomShape2", customShape2()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "BaseMember": - return Optional.ofNullable(clazz.cast(baseMember())); - case "CustomShape1": - return Optional.ofNullable(clazz.cast(customShape1())); - case "CustomShape2": - return Optional.ofNullable(clazz.cast(customShape2())); - default: - return Optional.empty(); + case "BaseMember": + return Optional.ofNullable(clazz.cast(baseMember())); + case "CustomShape1": + return Optional.ofNullable(clazz.cast(customShape1())); + case "CustomShape2": + return Optional.ofNullable(clazz.cast(customShape2())); + default: + return Optional.empty(); } } @@ -140,6 +149,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((BaseType) obj); } @@ -160,7 +174,7 @@ public interface Builder extends SdkPojo, CopyableBuilder { /** * Custom shape of type string - * + * * @param customShape1 * Custom shape of type string * @return Returns a reference to this object so that method calls can be chained together. @@ -169,7 +183,7 @@ public interface Builder extends SdkPojo, CopyableBuilder { /** * Custom shape of type integer - * + * * @param customShape2 * Custom shape of type integer * @return Returns a reference to this object so that method calls can be chained together. @@ -244,5 +258,10 @@ public BaseType build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/deprecatedrenamerequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/deprecatedrenamerequest.java index 9a4d9ee156f5..bde519652764 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/deprecatedrenamerequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/deprecatedrenamerequest.java @@ -2,7 +2,9 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -23,20 +25,28 @@ */ @Generated("software.amazon.awssdk:codegen") public final class DeprecatedRenameRequest extends JsonProtocolTestsRequest implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField NEW_NAME_NO_DEPRECATION_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("NewNameNoDeprecation").getter(getter(DeprecatedRenameRequest::newNameNoDeprecation)) - .setter(setter(Builder::newNameNoDeprecation)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalNameNoDeprecation").build()) - .build(); + .memberName("NewNameNoDeprecation").getter(getter(DeprecatedRenameRequest::newNameNoDeprecation)) + .setter(setter(Builder::newNameNoDeprecation)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalNameNoDeprecation").build()) + .build(); private static final SdkField NEW_NAME_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("NewName").getter(getter(DeprecatedRenameRequest::newName)).setter(setter(Builder::newName)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalNameDeprecated").build()) - .build(); + .memberName("NewName").getter(getter(DeprecatedRenameRequest::newName)).setter(setter(Builder::newName)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalNameDeprecated").build()) + .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NEW_NAME_NO_DEPRECATION_FIELD, - NEW_NAME_FIELD)); + NEW_NAME_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("OriginalNameNoDeprecation", NEW_NAME_NO_DEPRECATION_FIELD); + put("OriginalNameDeprecated", NEW_NAME_FIELD); + } + }); private final String newNameNoDeprecation; @@ -50,7 +60,7 @@ private DeprecatedRenameRequest(BuilderImpl builder) { /** * Returns the value of the NewNameNoDeprecation property for this object. - * + * * @return The value of the NewNameNoDeprecation property for this object. */ public final String newNameNoDeprecation() { @@ -59,7 +69,7 @@ public final String newNameNoDeprecation() { /** * Returns the value of the NewName property for this object. - * + * * @return The value of the NewName property for this object. * @deprecated Use {@link #newName()} */ @@ -70,7 +80,7 @@ public final String originalNameDeprecated() { /** * Returns the value of the NewName property for this object. - * + * * @return The value of the NewName property for this object. */ public final String newName() { @@ -126,19 +136,19 @@ public final boolean equalsBySdkFields(Object obj) { @Override public final String toString() { return ToString.builder("DeprecatedRenameRequest").add("NewNameNoDeprecation", newNameNoDeprecation()) - .add("NewName", newName()).build(); + .add("NewName", newName()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "NewNameNoDeprecation": - return Optional.ofNullable(clazz.cast(newNameNoDeprecation())); - case "NewName": - return Optional.ofNullable(clazz.cast(newName())); - case "OriginalNameDeprecated": - return Optional.ofNullable(clazz.cast(newName())); - default: - return Optional.empty(); + case "NewNameNoDeprecation": + return Optional.ofNullable(clazz.cast(newNameNoDeprecation())); + case "NewName": + return Optional.ofNullable(clazz.cast(newName())); + case "OriginalNameDeprecated": + return Optional.ofNullable(clazz.cast(newName())); + default: + return Optional.empty(); } } @@ -147,6 +157,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((DeprecatedRenameRequest) obj); } @@ -269,5 +284,10 @@ public DeprecatedRenameRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/deprecatedrenameresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/deprecatedrenameresponse.java index eb428b9fbefb..314d419d9431 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/deprecatedrenameresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/deprecatedrenameresponse.java @@ -2,7 +2,9 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -21,21 +23,29 @@ */ @Generated("software.amazon.awssdk:codegen") public final class DeprecatedRenameResponse extends JsonProtocolTestsResponse implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField ORIGINAL_NAME_NO_DEPRECATION_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("OriginalNameNoDeprecation").getter(getter(DeprecatedRenameResponse::originalNameNoDeprecation)) - .setter(setter(Builder::originalNameNoDeprecation)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalNameNoDeprecation").build()) - .build(); + .memberName("OriginalNameNoDeprecation").getter(getter(DeprecatedRenameResponse::originalNameNoDeprecation)) + .setter(setter(Builder::originalNameNoDeprecation)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalNameNoDeprecation").build()) + .build(); private static final SdkField ORIGINAL_NAME_DEPRECATED_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("OriginalNameDeprecated").getter(getter(DeprecatedRenameResponse::originalNameDeprecated)) - .setter(setter(Builder::originalNameDeprecated)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalNameDeprecated").build()) - .build(); + .memberName("OriginalNameDeprecated").getter(getter(DeprecatedRenameResponse::originalNameDeprecated)) + .setter(setter(Builder::originalNameDeprecated)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalNameDeprecated").build()) + .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList( - ORIGINAL_NAME_NO_DEPRECATION_FIELD, ORIGINAL_NAME_DEPRECATED_FIELD)); + ORIGINAL_NAME_NO_DEPRECATION_FIELD, ORIGINAL_NAME_DEPRECATED_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("OriginalNameNoDeprecation", ORIGINAL_NAME_NO_DEPRECATION_FIELD); + put("OriginalNameDeprecated", ORIGINAL_NAME_DEPRECATED_FIELD); + } + }); private final String originalNameNoDeprecation; @@ -49,7 +59,7 @@ private DeprecatedRenameResponse(BuilderImpl builder) { /** * Returns the value of the OriginalNameNoDeprecation property for this object. - * + * * @return The value of the OriginalNameNoDeprecation property for this object. */ public final String originalNameNoDeprecation() { @@ -58,7 +68,7 @@ public final String originalNameNoDeprecation() { /** * Returns the value of the OriginalNameDeprecated property for this object. - * + * * @return The value of the OriginalNameDeprecated property for this object. */ public final String originalNameDeprecated() { @@ -105,7 +115,7 @@ public final boolean equalsBySdkFields(Object obj) { } DeprecatedRenameResponse other = (DeprecatedRenameResponse) obj; return Objects.equals(originalNameNoDeprecation(), other.originalNameNoDeprecation()) - && Objects.equals(originalNameDeprecated(), other.originalNameDeprecated()); + && Objects.equals(originalNameDeprecated(), other.originalNameDeprecated()); } /** @@ -115,17 +125,17 @@ public final boolean equalsBySdkFields(Object obj) { @Override public final String toString() { return ToString.builder("DeprecatedRenameResponse").add("OriginalNameNoDeprecation", originalNameNoDeprecation()) - .add("OriginalNameDeprecated", originalNameDeprecated()).build(); + .add("OriginalNameDeprecated", originalNameDeprecated()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "OriginalNameNoDeprecation": - return Optional.ofNullable(clazz.cast(originalNameNoDeprecation())); - case "OriginalNameDeprecated": - return Optional.ofNullable(clazz.cast(originalNameDeprecated())); - default: - return Optional.empty(); + case "OriginalNameNoDeprecation": + return Optional.ofNullable(clazz.cast(originalNameNoDeprecation())); + case "OriginalNameDeprecated": + return Optional.ofNullable(clazz.cast(originalNameDeprecated())); + default: + return Optional.empty(); } } @@ -134,6 +144,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((DeprecatedRenameResponse) obj); } @@ -143,7 +158,7 @@ private static BiConsumer setter(BiConsumer s) { } public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, - CopyableBuilder { + CopyableBuilder { /** * Sets the value of the OriginalNameNoDeprecation property for this object. * @@ -214,5 +229,10 @@ public DeprecatedRenameResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/emptymodeledexception.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/emptymodeledexception.java index 375a03a4a6c4..b0eeb19dacbb 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/emptymodeledexception.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/emptymodeledexception.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.awscore.exception.AwsErrorDetails; import software.amazon.awssdk.core.SdkField; @@ -15,7 +15,9 @@ @Generated("software.amazon.awssdk:codegen") public final class EmptyModeledException extends JsonProtocolTestsException implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private static final long serialVersionUID = 1L; @@ -41,6 +43,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SdkPojo, CopyableBuilder, JsonProtocolTestsException.Builder { @Override Builder awsErrorDetails(AwsErrorDetails awsErrorDetails); @@ -114,6 +121,10 @@ public EmptyModeledException build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/enumtype.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/enumtype.java index a0c4de83ea1f..3b186b01f69c 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/enumtype.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/enumtype.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -12,7 +12,9 @@ */ @Generated("software.amazon.awssdk:codegen") public final class EnumType { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private EnumType(EnumType.BuilderImpl builder) { } @@ -72,5 +74,9 @@ public final Optional getValueForField(String fieldName, Class clazz) public final List> sdkFields() { return SDK_FIELDS; } -} + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventone.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventone.java index a3ed6a8fda54..f15d3825c6f7 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventone.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventone.java @@ -3,7 +3,9 @@ import java.io.Serializable; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -24,11 +26,18 @@ @Generated("software.amazon.awssdk:codegen") public class EventOne implements SdkPojo, Serializable, ToCopyableBuilder, EventStream { private static final SdkField FOO_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Foo") - .getter(getter(EventOne::foo)).setter(setter(Builder::foo)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Foo").build()).build(); + .getter(getter(EventOne::foo)).setter(setter(Builder::foo)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Foo").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FOO_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("Foo", FOO_FIELD); + } + }); + private static final long serialVersionUID = 1L; private final String foo; @@ -39,7 +48,7 @@ protected EventOne(BuilderImpl builder) { /** * Returns the value of the Foo property for this object. - * + * * @return The value of the Foo property for this object. */ public final String foo() { @@ -97,10 +106,10 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "Foo": - return Optional.ofNullable(clazz.cast(foo())); - default: - return Optional.empty(); + case "Foo": + return Optional.ofNullable(clazz.cast(foo())); + default: + return Optional.empty(); } } @@ -114,6 +123,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((EventOne) obj); } @@ -177,5 +191,10 @@ public EventOne build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstream.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstream.java index f1496e690872..5ad94156118d 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstream.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstream.java @@ -144,4 +144,3 @@ public static Set knownValues() { } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationrequest.java index ea0b39f4f87e..94778bb0428d 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationrequest.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; @@ -18,7 +18,9 @@ @Generated("software.amazon.awssdk:codegen") public final class EventStreamOperationRequest extends JsonProtocolTestsRequest implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private EventStreamOperationRequest(BuilderImpl builder) { super(builder); @@ -81,6 +83,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, CopyableBuilder { @Override @@ -119,5 +126,10 @@ public EventStreamOperationRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationresponse.java index c70bfc6303df..f7744730c170 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationresponse.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -16,7 +16,9 @@ @Generated("software.amazon.awssdk:codegen") public final class EventStreamOperationResponse extends JsonProtocolTestsResponse implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private EventStreamOperationResponse(BuilderImpl builder) { super(builder); @@ -79,6 +81,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, CopyableBuilder { } @@ -100,6 +107,10 @@ public EventStreamOperationResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationwithonlyinputrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationwithonlyinputrequest.java index 8138680b03fb..b6ce6ec1abae 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationwithonlyinputrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationwithonlyinputrequest.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; @@ -18,7 +18,9 @@ @Generated("software.amazon.awssdk:codegen") public final class EventStreamOperationWithOnlyInputRequest extends JsonProtocolTestsRequest implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private EventStreamOperationWithOnlyInputRequest(BuilderImpl builder) { super(builder); @@ -81,6 +83,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, CopyableBuilder { @Override @@ -119,5 +126,10 @@ public EventStreamOperationWithOnlyInputRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationwithonlyinputresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationwithonlyinputresponse.java index e787d358e571..904c763cd46b 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationwithonlyinputresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventstreamoperationwithonlyinputresponse.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -14,7 +14,9 @@ @Generated("software.amazon.awssdk:codegen") public final class EventStreamOperationWithOnlyInputResponse extends JsonProtocolTestsResponse implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private EventStreamOperationWithOnlyInputResponse(BuilderImpl builder) { super(builder); @@ -77,6 +79,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, CopyableBuilder { } @@ -98,6 +105,10 @@ public EventStreamOperationWithOnlyInputResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventtwo.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventtwo.java index 7479f0f1dbc2..772a720be923 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventtwo.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/eventtwo.java @@ -3,7 +3,9 @@ import java.io.Serializable; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -24,11 +26,18 @@ @Generated("software.amazon.awssdk:codegen") public class EventTwo implements SdkPojo, Serializable, ToCopyableBuilder, EventStream { private static final SdkField BAR_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Bar") - .getter(getter(EventTwo::bar)).setter(setter(Builder::bar)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Bar").build()).build(); + .getter(getter(EventTwo::bar)).setter(setter(Builder::bar)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Bar").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BAR_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("Bar", BAR_FIELD); + } + }); + private static final long serialVersionUID = 1L; private final String bar; @@ -39,7 +48,7 @@ protected EventTwo(BuilderImpl builder) { /** * Returns the value of the Bar property for this object. - * + * * @return The value of the Bar property for this object. */ public final String bar() { @@ -97,10 +106,10 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "Bar": - return Optional.ofNullable(clazz.cast(bar())); - default: - return Optional.empty(); + case "Bar": + return Optional.ofNullable(clazz.cast(bar())); + default: + return Optional.empty(); } } @@ -114,6 +123,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((EventTwo) obj); } @@ -177,5 +191,10 @@ public EventTwo build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonserviceinternalservererrorexception.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonserviceinternalservererrorexception.java index 7175fbd58f3a..fbfe4a6804f6 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonserviceinternalservererrorexception.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonserviceinternalservererrorexception.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.json.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.awscore.exception.AwsErrorDetails; import software.amazon.awssdk.core.SdkField; @@ -18,7 +18,9 @@ @Generated("software.amazon.awssdk:codegen") public final class JsonServiceInternalServerErrorException extends JsonException implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private static final long serialVersionUID = 1L; @@ -49,6 +51,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SdkPojo, CopyableBuilder, JsonException.Builder { @Override @@ -123,5 +130,10 @@ public JsonServiceInternalServerErrorException build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonserviceinvalidinputexception.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonserviceinvalidinputexception.java index 437d4ffb774e..6cc5c9d64e45 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonserviceinvalidinputexception.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonserviceinvalidinputexception.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.json.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.awscore.exception.AwsErrorDetails; import software.amazon.awssdk.core.SdkField; @@ -18,7 +18,9 @@ @Generated("software.amazon.awssdk:codegen") public final class JsonServiceInvalidInputException extends JsonException implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private static final long serialVersionUID = 1L; @@ -44,6 +46,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SdkPojo, CopyableBuilder, JsonException.Builder { @Override Builder awsErrorDetails(AwsErrorDetails awsErrorDetails); @@ -117,5 +124,10 @@ public JsonServiceInvalidInputException build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonservicethrottlingexception.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonservicethrottlingexception.java index 95f032aeed0c..e3f1c26ef47a 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonservicethrottlingexception.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/exceptions/jsonservicethrottlingexception.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.json.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.awscore.exception.AwsErrorDetails; import software.amazon.awssdk.core.SdkField; @@ -18,7 +18,9 @@ @Generated("software.amazon.awssdk:codegen") public final class JsonServiceThrottlingException extends JsonException implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private static final long serialVersionUID = 1L; @@ -54,6 +56,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SdkPojo, CopyableBuilder, JsonException.Builder { @Override Builder awsErrorDetails(AwsErrorDetails awsErrorDetails); @@ -127,5 +134,10 @@ public JsonServiceThrottlingException build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/existencechecknamingrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/existencechecknamingrequest.java index 5b1813daaba2..5d5fce1a5c1b 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/existencechecknamingrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/existencechecknamingrequest.java @@ -3,6 +3,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -31,65 +32,75 @@ */ @Generated("software.amazon.awssdk:codegen") public final class ExistenceCheckNamingRequest extends JsonProtocolTestsRequest implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField> BUILD_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("Build") - .getter(getter(ExistenceCheckNamingRequest::build)) - .setter(setter(Builder::build)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Build").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("Build") + .getter(getter(ExistenceCheckNamingRequest::build)) + .setter(setter(Builder::build)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Build").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final SdkField> SUPER_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("super") - .getter(getter(ExistenceCheckNamingRequest::superValue)) - .setter(setter(Builder::superValue)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("super").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("super") + .getter(getter(ExistenceCheckNamingRequest::superValue)) + .setter(setter(Builder::superValue)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("super").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final SdkField> TO_STRING_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("toString") - .getter(getter(ExistenceCheckNamingRequest::toStringValue)) - .setter(setter(Builder::toStringValue)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("toString").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("toString") + .getter(getter(ExistenceCheckNamingRequest::toStringValue)) + .setter(setter(Builder::toStringValue)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("toString").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final SdkField> EQUALS_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("equals") - .getter(getter(ExistenceCheckNamingRequest::equalsValue)) - .setter(setter(Builder::equalsValue)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("equals").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("equals") + .getter(getter(ExistenceCheckNamingRequest::equalsValue)) + .setter(setter(Builder::equalsValue)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("equals").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BUILD_FIELD, SUPER_FIELD, - TO_STRING_FIELD, EQUALS_FIELD)); + TO_STRING_FIELD, EQUALS_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("Build", BUILD_FIELD); + put("super", SUPER_FIELD); + put("toString", TO_STRING_FIELD); + put("equals", EQUALS_FIELD); + } + }); private final List build; @@ -127,7 +138,7 @@ public final boolean hasBuild() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasBuild} method. *

- * + * * @return The value of the Build property for this object. */ public final List build() { @@ -154,7 +165,7 @@ public final boolean hasSuperValue() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasSuperValue} method. *

- * + * * @return The value of the Super property for this object. */ public final List superValue() { @@ -182,7 +193,7 @@ public final boolean hasToStringValue() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasToStringValue} method. *

- * + * * @return The value of the ToString property for this object. */ public final Map toStringValue() { @@ -210,7 +221,7 @@ public final boolean hasEqualsValue() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasEqualsValue} method. *

- * + * * @return The value of the Equals property for this object. */ public final Map equalsValue() { @@ -259,9 +270,9 @@ public final boolean equalsBySdkFields(Object obj) { } ExistenceCheckNamingRequest other = (ExistenceCheckNamingRequest) obj; return hasBuild() == other.hasBuild() && Objects.equals(build(), other.build()) - && hasSuperValue() == other.hasSuperValue() && Objects.equals(superValue(), other.superValue()) - && hasToStringValue() == other.hasToStringValue() && Objects.equals(toStringValue(), other.toStringValue()) - && hasEqualsValue() == other.hasEqualsValue() && Objects.equals(equalsValue(), other.equalsValue()); + && hasSuperValue() == other.hasSuperValue() && Objects.equals(superValue(), other.superValue()) + && hasToStringValue() == other.hasToStringValue() && Objects.equals(toStringValue(), other.toStringValue()) + && hasEqualsValue() == other.hasEqualsValue() && Objects.equals(equalsValue(), other.equalsValue()); } /** @@ -271,22 +282,22 @@ && hasToStringValue() == other.hasToStringValue() && Objects.equals(toStringValu @Override public final String toString() { return ToString.builder("ExistenceCheckNamingRequest").add("Build", hasBuild() ? build() : null) - .add("Super", hasSuperValue() ? superValue() : null).add("ToString", hasToStringValue() ? toStringValue() : null) - .add("Equals", hasEqualsValue() ? equalsValue() : null).build(); + .add("Super", hasSuperValue() ? superValue() : null).add("ToString", hasToStringValue() ? toStringValue() : null) + .add("Equals", hasEqualsValue() ? equalsValue() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "Build": - return Optional.ofNullable(clazz.cast(build())); - case "super": - return Optional.ofNullable(clazz.cast(superValue())); - case "toString": - return Optional.ofNullable(clazz.cast(toStringValue())); - case "equals": - return Optional.ofNullable(clazz.cast(equalsValue())); - default: - return Optional.empty(); + case "Build": + return Optional.ofNullable(clazz.cast(build())); + case "super": + return Optional.ofNullable(clazz.cast(superValue())); + case "toString": + return Optional.ofNullable(clazz.cast(toStringValue())); + case "equals": + return Optional.ofNullable(clazz.cast(equalsValue())); + default: + return Optional.empty(); } } @@ -295,6 +306,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((ExistenceCheckNamingRequest) obj); } @@ -304,7 +320,7 @@ private static BiConsumer setter(BiConsumer s) { } public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, - CopyableBuilder { + CopyableBuilder { /** * Sets the value of the Build property for this object. * @@ -489,5 +505,10 @@ public ExistenceCheckNamingRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/existencechecknamingresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/existencechecknamingresponse.java index eb26f7ccb682..2c2a748b811d 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/existencechecknamingresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/existencechecknamingresponse.java @@ -3,6 +3,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -29,65 +30,75 @@ */ @Generated("software.amazon.awssdk:codegen") public final class ExistenceCheckNamingResponse extends JsonProtocolTestsResponse implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField> BUILD_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("Build") - .getter(getter(ExistenceCheckNamingResponse::build)) - .setter(setter(Builder::build)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Build").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("Build") + .getter(getter(ExistenceCheckNamingResponse::build)) + .setter(setter(Builder::build)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Build").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final SdkField> SUPER_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("super") - .getter(getter(ExistenceCheckNamingResponse::superValue)) - .setter(setter(Builder::superValue)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("super").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("super") + .getter(getter(ExistenceCheckNamingResponse::superValue)) + .setter(setter(Builder::superValue)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("super").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final SdkField> TO_STRING_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("toString") - .getter(getter(ExistenceCheckNamingResponse::toStringValue)) - .setter(setter(Builder::toStringValue)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("toString").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("toString") + .getter(getter(ExistenceCheckNamingResponse::toStringValue)) + .setter(setter(Builder::toStringValue)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("toString").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final SdkField> EQUALS_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("equals") - .getter(getter(ExistenceCheckNamingResponse::equalsValue)) - .setter(setter(Builder::equalsValue)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("equals").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("equals") + .getter(getter(ExistenceCheckNamingResponse::equalsValue)) + .setter(setter(Builder::equalsValue)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("equals").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BUILD_FIELD, SUPER_FIELD, - TO_STRING_FIELD, EQUALS_FIELD)); + TO_STRING_FIELD, EQUALS_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("Build", BUILD_FIELD); + put("super", SUPER_FIELD); + put("toString", TO_STRING_FIELD); + put("equals", EQUALS_FIELD); + } + }); private final List build; @@ -125,7 +136,7 @@ public final boolean hasBuild() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasBuild} method. *

- * + * * @return The value of the Build property for this object. */ public final List build() { @@ -152,7 +163,7 @@ public final boolean hasSuperValue() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasSuperValue} method. *

- * + * * @return The value of the Super property for this object. */ public final List superValue() { @@ -180,7 +191,7 @@ public final boolean hasToStringValue() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasToStringValue} method. *

- * + * * @return The value of the ToString property for this object. */ public final Map toStringValue() { @@ -208,7 +219,7 @@ public final boolean hasEqualsValue() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasEqualsValue} method. *

- * + * * @return The value of the Equals property for this object. */ public final Map equalsValue() { @@ -257,9 +268,9 @@ public final boolean equalsBySdkFields(Object obj) { } ExistenceCheckNamingResponse other = (ExistenceCheckNamingResponse) obj; return hasBuild() == other.hasBuild() && Objects.equals(build(), other.build()) - && hasSuperValue() == other.hasSuperValue() && Objects.equals(superValue(), other.superValue()) - && hasToStringValue() == other.hasToStringValue() && Objects.equals(toStringValue(), other.toStringValue()) - && hasEqualsValue() == other.hasEqualsValue() && Objects.equals(equalsValue(), other.equalsValue()); + && hasSuperValue() == other.hasSuperValue() && Objects.equals(superValue(), other.superValue()) + && hasToStringValue() == other.hasToStringValue() && Objects.equals(toStringValue(), other.toStringValue()) + && hasEqualsValue() == other.hasEqualsValue() && Objects.equals(equalsValue(), other.equalsValue()); } /** @@ -269,22 +280,22 @@ && hasToStringValue() == other.hasToStringValue() && Objects.equals(toStringValu @Override public final String toString() { return ToString.builder("ExistenceCheckNamingResponse").add("Build", hasBuild() ? build() : null) - .add("Super", hasSuperValue() ? superValue() : null).add("ToString", hasToStringValue() ? toStringValue() : null) - .add("Equals", hasEqualsValue() ? equalsValue() : null).build(); + .add("Super", hasSuperValue() ? superValue() : null).add("ToString", hasToStringValue() ? toStringValue() : null) + .add("Equals", hasEqualsValue() ? equalsValue() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "Build": - return Optional.ofNullable(clazz.cast(build())); - case "super": - return Optional.ofNullable(clazz.cast(superValue())); - case "toString": - return Optional.ofNullable(clazz.cast(toStringValue())); - case "equals": - return Optional.ofNullable(clazz.cast(equalsValue())); - default: - return Optional.empty(); + case "Build": + return Optional.ofNullable(clazz.cast(build())); + case "super": + return Optional.ofNullable(clazz.cast(superValue())); + case "toString": + return Optional.ofNullable(clazz.cast(toStringValue())); + case "equals": + return Optional.ofNullable(clazz.cast(equalsValue())); + default: + return Optional.empty(); } } @@ -293,6 +304,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((ExistenceCheckNamingResponse) obj); } @@ -302,7 +318,7 @@ private static BiConsumer setter(BiConsumer s) { } public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, - CopyableBuilder { + CopyableBuilder { /** * Sets the value of the Build property for this object. * @@ -469,5 +485,10 @@ public ExistenceCheckNamingResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputevent.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputevent.java index 561fc411b7b9..87768235a9a7 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputevent.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputevent.java @@ -4,7 +4,9 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -27,15 +29,22 @@ @Generated("software.amazon.awssdk:codegen") public class InputEvent implements SdkPojo, Serializable, ToCopyableBuilder, InputEventStream { private static final SdkField EXPLICIT_PAYLOAD_MEMBER_FIELD = SdkField - . builder(MarshallingType.SDK_BYTES) - .memberName("ExplicitPayloadMember") - .getter(getter(InputEvent::explicitPayloadMember)) - .setter(setter(Builder::explicitPayloadMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExplicitPayloadMember").build(), - PayloadTrait.create()).build(); + . builder(MarshallingType.SDK_BYTES) + .memberName("ExplicitPayloadMember") + .getter(getter(InputEvent::explicitPayloadMember)) + .setter(setter(Builder::explicitPayloadMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExplicitPayloadMember").build(), + PayloadTrait.create()).build(); private static final List> SDK_FIELDS = Collections - .unmodifiableList(Arrays.asList(EXPLICIT_PAYLOAD_MEMBER_FIELD)); + .unmodifiableList(Arrays.asList(EXPLICIT_PAYLOAD_MEMBER_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("ExplicitPayloadMember", EXPLICIT_PAYLOAD_MEMBER_FIELD); + } + }); private static final long serialVersionUID = 1L; @@ -47,7 +56,7 @@ protected InputEvent(BuilderImpl builder) { /** * Returns the value of the ExplicitPayloadMember property for this object. - * + * * @return The value of the ExplicitPayloadMember property for this object. */ public final SdkBytes explicitPayloadMember() { @@ -105,10 +114,10 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "ExplicitPayloadMember": - return Optional.ofNullable(clazz.cast(explicitPayloadMember())); - default: - return Optional.empty(); + case "ExplicitPayloadMember": + return Optional.ofNullable(clazz.cast(explicitPayloadMember())); + default: + return Optional.empty(); } } @@ -122,6 +131,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((InputEvent) obj); } @@ -174,5 +188,10 @@ public InputEvent build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventstream.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventstream.java index a1c76b7f0947..3da0898bc8ce 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventstream.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventstream.java @@ -77,4 +77,3 @@ public static Set knownValues() { } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventstreamtwo.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventstreamtwo.java index 2b5fb27b9dc2..43530e1be8c1 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventstreamtwo.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventstreamtwo.java @@ -77,4 +77,3 @@ public static Set knownValues() { } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventtwo.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventtwo.java index d98d203d65e4..bafd06d97d2e 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventtwo.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/inputeventtwo.java @@ -4,7 +4,9 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -25,26 +27,35 @@ */ @Generated("software.amazon.awssdk:codegen") public class InputEventTwo implements SdkPojo, Serializable, ToCopyableBuilder, - InputEventStreamTwo { + InputEventStreamTwo { private static final SdkField IMPLICIT_PAYLOAD_MEMBER_ONE_FIELD = SdkField - . builder(MarshallingType.SDK_BYTES).memberName("ImplicitPayloadMemberOne") - .getter(getter(InputEventTwo::implicitPayloadMemberOne)).setter(setter(Builder::implicitPayloadMemberOne)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ImplicitPayloadMemberOne").build()) - .build(); + . builder(MarshallingType.SDK_BYTES).memberName("ImplicitPayloadMemberOne") + .getter(getter(InputEventTwo::implicitPayloadMemberOne)).setter(setter(Builder::implicitPayloadMemberOne)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ImplicitPayloadMemberOne").build()) + .build(); private static final SdkField IMPLICIT_PAYLOAD_MEMBER_TWO_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("ImplicitPayloadMemberTwo").getter(getter(InputEventTwo::implicitPayloadMemberTwo)) - .setter(setter(Builder::implicitPayloadMemberTwo)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ImplicitPayloadMemberTwo").build()) - .build(); + .memberName("ImplicitPayloadMemberTwo").getter(getter(InputEventTwo::implicitPayloadMemberTwo)) + .setter(setter(Builder::implicitPayloadMemberTwo)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ImplicitPayloadMemberTwo").build()) + .build(); private static final SdkField EVENT_HEADER_MEMBER_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("EventHeaderMember").getter(getter(InputEventTwo::eventHeaderMember)) - .setter(setter(Builder::eventHeaderMember)) - .traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("EventHeaderMember").build()).build(); + .memberName("EventHeaderMember").getter(getter(InputEventTwo::eventHeaderMember)) + .setter(setter(Builder::eventHeaderMember)) + .traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("EventHeaderMember").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList( - IMPLICIT_PAYLOAD_MEMBER_ONE_FIELD, IMPLICIT_PAYLOAD_MEMBER_TWO_FIELD, EVENT_HEADER_MEMBER_FIELD)); + IMPLICIT_PAYLOAD_MEMBER_ONE_FIELD, IMPLICIT_PAYLOAD_MEMBER_TWO_FIELD, EVENT_HEADER_MEMBER_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("ImplicitPayloadMemberOne", IMPLICIT_PAYLOAD_MEMBER_ONE_FIELD); + put("ImplicitPayloadMemberTwo", IMPLICIT_PAYLOAD_MEMBER_TWO_FIELD); + put("EventHeaderMember", EVENT_HEADER_MEMBER_FIELD); + } + }); private static final long serialVersionUID = 1L; @@ -62,7 +73,7 @@ protected InputEventTwo(BuilderImpl builder) { /** * Returns the value of the ImplicitPayloadMemberOne property for this object. - * + * * @return The value of the ImplicitPayloadMemberOne property for this object. */ public final SdkBytes implicitPayloadMemberOne() { @@ -71,7 +82,7 @@ public final SdkBytes implicitPayloadMemberOne() { /** * Returns the value of the ImplicitPayloadMemberTwo property for this object. - * + * * @return The value of the ImplicitPayloadMemberTwo property for this object. */ public final String implicitPayloadMemberTwo() { @@ -80,7 +91,7 @@ public final String implicitPayloadMemberTwo() { /** * Returns the value of the EventHeaderMember property for this object. - * + * * @return The value of the EventHeaderMember property for this object. */ public final String eventHeaderMember() { @@ -127,8 +138,8 @@ public final boolean equalsBySdkFields(Object obj) { } InputEventTwo other = (InputEventTwo) obj; return Objects.equals(implicitPayloadMemberOne(), other.implicitPayloadMemberOne()) - && Objects.equals(implicitPayloadMemberTwo(), other.implicitPayloadMemberTwo()) - && Objects.equals(eventHeaderMember(), other.eventHeaderMember()); + && Objects.equals(implicitPayloadMemberTwo(), other.implicitPayloadMemberTwo()) + && Objects.equals(eventHeaderMember(), other.eventHeaderMember()); } /** @@ -138,20 +149,20 @@ public final boolean equalsBySdkFields(Object obj) { @Override public final String toString() { return ToString.builder("InputEventTwo").add("ImplicitPayloadMemberOne", implicitPayloadMemberOne()) - .add("ImplicitPayloadMemberTwo", implicitPayloadMemberTwo()).add("EventHeaderMember", eventHeaderMember()) - .build(); + .add("ImplicitPayloadMemberTwo", implicitPayloadMemberTwo()).add("EventHeaderMember", eventHeaderMember()) + .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "ImplicitPayloadMemberOne": - return Optional.ofNullable(clazz.cast(implicitPayloadMemberOne())); - case "ImplicitPayloadMemberTwo": - return Optional.ofNullable(clazz.cast(implicitPayloadMemberTwo())); - case "EventHeaderMember": - return Optional.ofNullable(clazz.cast(eventHeaderMember())); - default: - return Optional.empty(); + case "ImplicitPayloadMemberOne": + return Optional.ofNullable(clazz.cast(implicitPayloadMemberOne())); + case "ImplicitPayloadMemberTwo": + return Optional.ofNullable(clazz.cast(implicitPayloadMemberTwo())); + case "EventHeaderMember": + return Optional.ofNullable(clazz.cast(eventHeaderMember())); + default: + return Optional.empty(); } } @@ -165,6 +176,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((InputEventTwo) obj); } @@ -269,5 +285,10 @@ public InputEventTwo build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedcontainersrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedcontainersrequest.java index eb8e48e4961d..5e2a4088da0c 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedcontainersrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedcontainersrequest.java @@ -3,6 +3,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -31,107 +32,116 @@ */ @Generated("software.amazon.awssdk:codegen") public final class NestedContainersRequest extends JsonProtocolTestsRequest implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField>> LIST_OF_LIST_OF_STRINGS_FIELD = SdkField - .>> builder(MarshallingType.LIST) - .memberName("ListOfListOfStrings") - .getter(getter(NestedContainersRequest::listOfListOfStrings)) - .setter(setter(Builder::listOfListOfStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfStrings").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.> builder(MarshallingType.LIST) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()) - .build()).build()).build()).build(); + .>> builder(MarshallingType.LIST) + .memberName("ListOfListOfStrings") + .getter(getter(NestedContainersRequest::listOfListOfStrings)) + .setter(setter(Builder::listOfListOfStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfStrings").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.> builder(MarshallingType.LIST) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()) + .build()).build()).build()).build(); private static final SdkField>>> LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD = SdkField - .>>> builder(MarshallingType.LIST) - .memberName("ListOfListOfListOfStrings") - .getter(getter(NestedContainersRequest::listOfListOfListOfStrings)) - .setter(setter(Builder::listOfListOfListOfStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfListOfStrings").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.>> builder(MarshallingType.LIST) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.> builder(MarshallingType.LIST) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder( - MarshallingType.STRING) - .traits(LocationTrait + .>>> builder(MarshallingType.LIST) + .memberName("ListOfListOfListOfStrings") + .getter(getter(NestedContainersRequest::listOfListOfListOfStrings)) + .setter(setter(Builder::listOfListOfListOfStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfListOfStrings").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.>> builder(MarshallingType.LIST) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.> builder(MarshallingType.LIST) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + ListTrait .builder() - .location( - MarshallLocation.PAYLOAD) - .locationName( - "member") - .build()) - .build()).build()) - .build()).build()).build()).build()).build(); + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder( + MarshallingType.STRING) + .traits(LocationTrait + .builder() + .location( + MarshallLocation.PAYLOAD) + .locationName( + "member") + .build()) + .build()).build()) + .build()).build()).build()).build()).build(); private static final SdkField>>> MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD = SdkField - .>>> builder(MarshallingType.MAP) - .memberName("MapOfStringToListOfListOfStrings") - .getter(getter(NestedContainersRequest::mapOfStringToListOfListOfStrings)) - .setter(setter(Builder::mapOfStringToListOfListOfStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToListOfListOfStrings") - .build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField.>> builder(MarshallingType.LIST) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.> builder(MarshallingType.LIST) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder( - MarshallingType.STRING) - .traits(LocationTrait - .builder() - .location( - MarshallLocation.PAYLOAD) - .locationName( - "member") - .build()) - .build()).build()) - .build()).build()).build()).build()).build(); + .>>> builder(MarshallingType.MAP) + .memberName("MapOfStringToListOfListOfStrings") + .getter(getter(NestedContainersRequest::mapOfStringToListOfListOfStrings)) + .setter(setter(Builder::mapOfStringToListOfListOfStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToListOfListOfStrings") + .build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField.>> builder(MarshallingType.LIST) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.> builder(MarshallingType.LIST) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder( + MarshallingType.STRING) + .traits(LocationTrait + .builder() + .location( + MarshallLocation.PAYLOAD) + .locationName( + "member") + .build()) + .build()).build()) + .build()).build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LIST_OF_LIST_OF_STRINGS_FIELD, - LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD, MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD)); + LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD, MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("ListOfListOfStrings", LIST_OF_LIST_OF_STRINGS_FIELD); + put("ListOfListOfListOfStrings", LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD); + put("MapOfStringToListOfListOfStrings", MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD); + } + }); private final List> listOfListOfStrings; @@ -167,7 +177,7 @@ public final boolean hasListOfListOfStrings() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfListOfStrings} method. *

- * + * * @return The value of the ListOfListOfStrings property for this object. */ public final List> listOfListOfStrings() { @@ -195,7 +205,7 @@ public final boolean hasListOfListOfListOfStrings() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfListOfListOfStrings} method. *

- * + * * @return The value of the ListOfListOfListOfStrings property for this object. */ public final List>> listOfListOfListOfStrings() { @@ -224,7 +234,7 @@ public final boolean hasMapOfStringToListOfListOfStrings() { * you can differentiate between null and empty), you can use the {@link #hasMapOfStringToListOfListOfStrings} * method. *

- * + * * @return The value of the MapOfStringToListOfListOfStrings property for this object. */ public final Map>> mapOfStringToListOfListOfStrings() { @@ -251,7 +261,7 @@ public final int hashCode() { hashCode = 31 * hashCode + Objects.hashCode(hasListOfListOfStrings() ? listOfListOfStrings() : null); hashCode = 31 * hashCode + Objects.hashCode(hasListOfListOfListOfStrings() ? listOfListOfListOfStrings() : null); hashCode = 31 * hashCode - + Objects.hashCode(hasMapOfStringToListOfListOfStrings() ? mapOfStringToListOfListOfStrings() : null); + + Objects.hashCode(hasMapOfStringToListOfListOfStrings() ? mapOfStringToListOfListOfStrings() : null); return hashCode; } @@ -273,11 +283,11 @@ public final boolean equalsBySdkFields(Object obj) { } NestedContainersRequest other = (NestedContainersRequest) obj; return hasListOfListOfStrings() == other.hasListOfListOfStrings() - && Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) - && hasListOfListOfListOfStrings() == other.hasListOfListOfListOfStrings() - && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) - && hasMapOfStringToListOfListOfStrings() == other.hasMapOfStringToListOfListOfStrings() - && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); + && Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) + && hasListOfListOfListOfStrings() == other.hasListOfListOfListOfStrings() + && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) + && hasMapOfStringToListOfListOfStrings() == other.hasMapOfStringToListOfListOfStrings() + && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); } /** @@ -287,23 +297,23 @@ && hasMapOfStringToListOfListOfStrings() == other.hasMapOfStringToListOfListOfSt @Override public final String toString() { return ToString - .builder("NestedContainersRequest") - .add("ListOfListOfStrings", hasListOfListOfStrings() ? listOfListOfStrings() : null) - .add("ListOfListOfListOfStrings", hasListOfListOfListOfStrings() ? listOfListOfListOfStrings() : null) - .add("MapOfStringToListOfListOfStrings", - hasMapOfStringToListOfListOfStrings() ? mapOfStringToListOfListOfStrings() : null).build(); + .builder("NestedContainersRequest") + .add("ListOfListOfStrings", hasListOfListOfStrings() ? listOfListOfStrings() : null) + .add("ListOfListOfListOfStrings", hasListOfListOfListOfStrings() ? listOfListOfListOfStrings() : null) + .add("MapOfStringToListOfListOfStrings", + hasMapOfStringToListOfListOfStrings() ? mapOfStringToListOfListOfStrings() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "ListOfListOfStrings": - return Optional.ofNullable(clazz.cast(listOfListOfStrings())); - case "ListOfListOfListOfStrings": - return Optional.ofNullable(clazz.cast(listOfListOfListOfStrings())); - case "MapOfStringToListOfListOfStrings": - return Optional.ofNullable(clazz.cast(mapOfStringToListOfListOfStrings())); - default: - return Optional.empty(); + case "ListOfListOfStrings": + return Optional.ofNullable(clazz.cast(listOfListOfStrings())); + case "ListOfListOfListOfStrings": + return Optional.ofNullable(clazz.cast(listOfListOfListOfStrings())); + case "MapOfStringToListOfListOfStrings": + return Optional.ofNullable(clazz.cast(mapOfStringToListOfListOfStrings())); + default: + return Optional.empty(); } } @@ -312,6 +322,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((NestedContainersRequest) obj); } @@ -365,7 +380,7 @@ public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, Copy * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToListOfListOfStrings( - Map>> mapOfStringToListOfListOfStrings); + Map>> mapOfStringToListOfListOfStrings); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @@ -423,13 +438,13 @@ public final Collection>> getL } public final void setListOfListOfListOfStrings( - Collection>> listOfListOfListOfStrings) { + Collection>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); } @Override public final Builder listOfListOfListOfStrings( - Collection>> listOfListOfListOfStrings) { + Collection>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); return this; } @@ -449,13 +464,13 @@ public final Builder listOfListOfListOfStrings(Collection>> mapOfStringToListOfListOfStrings) { + Map>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); } @Override public final Builder mapOfStringToListOfListOfStrings( - Map>> mapOfStringToListOfListOfStrings) { + Map>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); return this; } @@ -481,5 +496,10 @@ public NestedContainersRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedcontainersresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedcontainersresponse.java index 198a5ad663c0..4914706672a7 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedcontainersresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedcontainersresponse.java @@ -3,6 +3,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -29,107 +30,116 @@ */ @Generated("software.amazon.awssdk:codegen") public final class NestedContainersResponse extends JsonProtocolTestsResponse implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField>> LIST_OF_LIST_OF_STRINGS_FIELD = SdkField - .>> builder(MarshallingType.LIST) - .memberName("ListOfListOfStrings") - .getter(getter(NestedContainersResponse::listOfListOfStrings)) - .setter(setter(Builder::listOfListOfStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfStrings").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.> builder(MarshallingType.LIST) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.STRING) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()) - .build()).build()).build()).build(); + .>> builder(MarshallingType.LIST) + .memberName("ListOfListOfStrings") + .getter(getter(NestedContainersResponse::listOfListOfStrings)) + .setter(setter(Builder::listOfListOfStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfStrings").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.> builder(MarshallingType.LIST) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()) + .build()).build()).build()).build(); private static final SdkField>>> LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD = SdkField - .>>> builder(MarshallingType.LIST) - .memberName("ListOfListOfListOfStrings") - .getter(getter(NestedContainersResponse::listOfListOfListOfStrings)) - .setter(setter(Builder::listOfListOfListOfStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfListOfStrings").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.>> builder(MarshallingType.LIST) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.> builder(MarshallingType.LIST) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder( - MarshallingType.STRING) - .traits(LocationTrait + .>>> builder(MarshallingType.LIST) + .memberName("ListOfListOfListOfStrings") + .getter(getter(NestedContainersResponse::listOfListOfListOfStrings)) + .setter(setter(Builder::listOfListOfListOfStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfListOfStrings").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.>> builder(MarshallingType.LIST) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.> builder(MarshallingType.LIST) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + ListTrait .builder() - .location( - MarshallLocation.PAYLOAD) - .locationName( - "member") - .build()) - .build()).build()) - .build()).build()).build()).build()).build(); + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder( + MarshallingType.STRING) + .traits(LocationTrait + .builder() + .location( + MarshallLocation.PAYLOAD) + .locationName( + "member") + .build()) + .build()).build()) + .build()).build()).build()).build()).build(); private static final SdkField>>> MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD = SdkField - .>>> builder(MarshallingType.MAP) - .memberName("MapOfStringToListOfListOfStrings") - .getter(getter(NestedContainersResponse::mapOfStringToListOfListOfStrings)) - .setter(setter(Builder::mapOfStringToListOfListOfStrings)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToListOfListOfStrings") - .build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField.>> builder(MarshallingType.LIST) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField.> builder(MarshallingType.LIST) - .traits(LocationTrait.builder() - .location(MarshallLocation.PAYLOAD) - .locationName("member").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder( - MarshallingType.STRING) - .traits(LocationTrait - .builder() - .location( - MarshallLocation.PAYLOAD) - .locationName( - "member") - .build()) - .build()).build()) - .build()).build()).build()).build()).build(); + .>>> builder(MarshallingType.MAP) + .memberName("MapOfStringToListOfListOfStrings") + .getter(getter(NestedContainersResponse::mapOfStringToListOfListOfStrings)) + .setter(setter(Builder::mapOfStringToListOfListOfStrings)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToListOfListOfStrings") + .build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField.>> builder(MarshallingType.LIST) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField.> builder(MarshallingType.LIST) + .traits(LocationTrait.builder() + .location(MarshallLocation.PAYLOAD) + .locationName("member").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder( + MarshallingType.STRING) + .traits(LocationTrait + .builder() + .location( + MarshallLocation.PAYLOAD) + .locationName( + "member") + .build()) + .build()).build()) + .build()).build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LIST_OF_LIST_OF_STRINGS_FIELD, - LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD, MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD)); + LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD, MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("ListOfListOfStrings", LIST_OF_LIST_OF_STRINGS_FIELD); + put("ListOfListOfListOfStrings", LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD); + put("MapOfStringToListOfListOfStrings", MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD); + } + }); private final List> listOfListOfStrings; @@ -165,7 +175,7 @@ public final boolean hasListOfListOfStrings() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfListOfStrings} method. *

- * + * * @return The value of the ListOfListOfStrings property for this object. */ public final List> listOfListOfStrings() { @@ -193,7 +203,7 @@ public final boolean hasListOfListOfListOfStrings() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasListOfListOfListOfStrings} method. *

- * + * * @return The value of the ListOfListOfListOfStrings property for this object. */ public final List>> listOfListOfListOfStrings() { @@ -222,7 +232,7 @@ public final boolean hasMapOfStringToListOfListOfStrings() { * you can differentiate between null and empty), you can use the {@link #hasMapOfStringToListOfListOfStrings} * method. *

- * + * * @return The value of the MapOfStringToListOfListOfStrings property for this object. */ public final Map>> mapOfStringToListOfListOfStrings() { @@ -249,7 +259,7 @@ public final int hashCode() { hashCode = 31 * hashCode + Objects.hashCode(hasListOfListOfStrings() ? listOfListOfStrings() : null); hashCode = 31 * hashCode + Objects.hashCode(hasListOfListOfListOfStrings() ? listOfListOfListOfStrings() : null); hashCode = 31 * hashCode - + Objects.hashCode(hasMapOfStringToListOfListOfStrings() ? mapOfStringToListOfListOfStrings() : null); + + Objects.hashCode(hasMapOfStringToListOfListOfStrings() ? mapOfStringToListOfListOfStrings() : null); return hashCode; } @@ -271,11 +281,11 @@ public final boolean equalsBySdkFields(Object obj) { } NestedContainersResponse other = (NestedContainersResponse) obj; return hasListOfListOfStrings() == other.hasListOfListOfStrings() - && Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) - && hasListOfListOfListOfStrings() == other.hasListOfListOfListOfStrings() - && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) - && hasMapOfStringToListOfListOfStrings() == other.hasMapOfStringToListOfListOfStrings() - && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); + && Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) + && hasListOfListOfListOfStrings() == other.hasListOfListOfListOfStrings() + && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) + && hasMapOfStringToListOfListOfStrings() == other.hasMapOfStringToListOfListOfStrings() + && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); } /** @@ -285,23 +295,23 @@ && hasMapOfStringToListOfListOfStrings() == other.hasMapOfStringToListOfListOfSt @Override public final String toString() { return ToString - .builder("NestedContainersResponse") - .add("ListOfListOfStrings", hasListOfListOfStrings() ? listOfListOfStrings() : null) - .add("ListOfListOfListOfStrings", hasListOfListOfListOfStrings() ? listOfListOfListOfStrings() : null) - .add("MapOfStringToListOfListOfStrings", - hasMapOfStringToListOfListOfStrings() ? mapOfStringToListOfListOfStrings() : null).build(); + .builder("NestedContainersResponse") + .add("ListOfListOfStrings", hasListOfListOfStrings() ? listOfListOfStrings() : null) + .add("ListOfListOfListOfStrings", hasListOfListOfListOfStrings() ? listOfListOfListOfStrings() : null) + .add("MapOfStringToListOfListOfStrings", + hasMapOfStringToListOfListOfStrings() ? mapOfStringToListOfListOfStrings() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "ListOfListOfStrings": - return Optional.ofNullable(clazz.cast(listOfListOfStrings())); - case "ListOfListOfListOfStrings": - return Optional.ofNullable(clazz.cast(listOfListOfListOfStrings())); - case "MapOfStringToListOfListOfStrings": - return Optional.ofNullable(clazz.cast(mapOfStringToListOfListOfStrings())); - default: - return Optional.empty(); + case "ListOfListOfStrings": + return Optional.ofNullable(clazz.cast(listOfListOfStrings())); + case "ListOfListOfListOfStrings": + return Optional.ofNullable(clazz.cast(listOfListOfListOfStrings())); + case "MapOfStringToListOfListOfStrings": + return Optional.ofNullable(clazz.cast(mapOfStringToListOfListOfStrings())); + default: + return Optional.empty(); } } @@ -310,6 +320,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((NestedContainersResponse) obj); } @@ -319,7 +334,7 @@ private static BiConsumer setter(BiConsumer s) { } public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, - CopyableBuilder { + CopyableBuilder { /** * Sets the value of the ListOfListOfStrings property for this object. * @@ -364,7 +379,7 @@ public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToListOfListOfStrings( - Map>> mapOfStringToListOfListOfStrings); + Map>> mapOfStringToListOfListOfStrings); } static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl implements Builder { @@ -416,13 +431,13 @@ public final Collection>> getL } public final void setListOfListOfListOfStrings( - Collection>> listOfListOfListOfStrings) { + Collection>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); } @Override public final Builder listOfListOfListOfStrings( - Collection>> listOfListOfListOfStrings) { + Collection>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); return this; } @@ -442,13 +457,13 @@ public final Builder listOfListOfListOfStrings(Collection>> mapOfStringToListOfListOfStrings) { + Map>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); } @Override public final Builder mapOfStringToListOfListOfStrings( - Map>> mapOfStringToListOfListOfStrings) { + Map>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); return this; } @@ -462,5 +477,10 @@ public NestedContainersResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedqueryparameteroperation.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedqueryparameteroperation.java index 317db274746b..8fc81c9778f2 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedqueryparameteroperation.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nestedqueryparameteroperation.java @@ -3,7 +3,9 @@ import java.io.Serializable; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -23,23 +25,30 @@ */ @Generated("software.amazon.awssdk:codegen") public final class NestedQueryParameterOperation implements SdkPojo, Serializable, - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField QUERY_PARAM_ONE_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("QueryParamOne") - .getter(getter(NestedQueryParameterOperation::queryParamOne)) - .setter(setter(Builder::queryParamOne)) - .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("QueryParamOne").build(), - RequiredTrait.create()).build(); - - private static final SdkField QUERY_PARAM_TWO_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("QueryParamTwo").getter(getter(NestedQueryParameterOperation::queryParamTwo)) - .setter(setter(Builder::queryParamTwo)) - .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("QueryParamTwo").build()).build(); + . builder(MarshallingType.STRING) + .memberName("QueryParamOne") + .getter(getter(NestedQueryParameterOperation::queryParamOne)) + .setter(setter(Builder::queryParamOne)) + .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("QueryParamOne").build(), + RequiredTrait.create()).build(); + + private static final SdkField QUERY_PARAM_TWO_FIELD = SdkField. builder(MarshallingType.STRING) + .memberName("QueryParamTwo").getter(getter(NestedQueryParameterOperation::queryParamTwo)) + .setter(setter(Builder::queryParamTwo)) + .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("QueryParamTwo").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(QUERY_PARAM_ONE_FIELD, - QUERY_PARAM_TWO_FIELD)); + QUERY_PARAM_TWO_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("QueryParamOne", QUERY_PARAM_ONE_FIELD); + put("QueryParamTwo", QUERY_PARAM_TWO_FIELD); + } + }); private static final long serialVersionUID = 1L; @@ -54,7 +63,7 @@ private NestedQueryParameterOperation(BuilderImpl builder) { /** * Returns the value of the QueryParamOne property for this object. - * + * * @return The value of the QueryParamOne property for this object. */ public final String queryParamOne() { @@ -63,7 +72,7 @@ public final String queryParamOne() { /** * Returns the value of the QueryParamTwo property for this object. - * + * * @return The value of the QueryParamTwo property for this object. */ public final String queryParamTwo() { @@ -118,17 +127,17 @@ public final boolean equalsBySdkFields(Object obj) { @Override public final String toString() { return ToString.builder("NestedQueryParameterOperation").add("QueryParamOne", queryParamOne()) - .add("QueryParamTwo", queryParamTwo()).build(); + .add("QueryParamTwo", queryParamTwo()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "QueryParamOne": - return Optional.ofNullable(clazz.cast(queryParamOne())); - case "QueryParamTwo": - return Optional.ofNullable(clazz.cast(queryParamTwo())); - default: - return Optional.empty(); + case "QueryParamOne": + return Optional.ofNullable(clazz.cast(queryParamOne())); + case "QueryParamTwo": + return Optional.ofNullable(clazz.cast(queryParamTwo())); + default: + return Optional.empty(); } } @@ -137,6 +146,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((NestedQueryParameterOperation) obj); } @@ -215,5 +229,10 @@ public NestedQueryParameterOperation build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithdeprecatedmemberrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithdeprecatedmemberrequest.java index c14ae6ee3ede..3c7ca5a4f963 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithdeprecatedmemberrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithdeprecatedmemberrequest.java @@ -2,7 +2,9 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -24,40 +26,50 @@ */ @Generated("software.amazon.awssdk:codegen") public final class OperationWithDeprecatedMemberRequest extends JsonProtocolTestsRequest implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField MEMBER_MODELED_AS_DEPRECATED_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("MemberModeledAsDeprecated") - .getter(getter(OperationWithDeprecatedMemberRequest::memberModeledAsDeprecated)) - .setter(setter(Builder::memberModeledAsDeprecated)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberModeledAsDeprecated").build()) - .build(); + .memberName("MemberModeledAsDeprecated") + .getter(getter(OperationWithDeprecatedMemberRequest::memberModeledAsDeprecated)) + .setter(setter(Builder::memberModeledAsDeprecated)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberModeledAsDeprecated").build()) + .build(); private static final SdkField MEMBER_MODIFIED_AS_DEPRECATED_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("MemberModifiedAsDeprecated") - .getter(getter(OperationWithDeprecatedMemberRequest::memberModifiedAsDeprecated)) - .setter(setter(Builder::memberModifiedAsDeprecated)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberModifiedAsDeprecated").build()) - .build(); + . builder(MarshallingType.STRING) + .memberName("MemberModifiedAsDeprecated") + .getter(getter(OperationWithDeprecatedMemberRequest::memberModifiedAsDeprecated)) + .setter(setter(Builder::memberModifiedAsDeprecated)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberModifiedAsDeprecated").build()) + .build(); private static final SdkField UNDEPRECATED_MEMBER_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("UndeprecatedMember").getter(getter(OperationWithDeprecatedMemberRequest::undeprecatedMember)) - .setter(setter(Builder::undeprecatedMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UndeprecatedMember").build()) - .build(); + .memberName("UndeprecatedMember").getter(getter(OperationWithDeprecatedMemberRequest::undeprecatedMember)) + .setter(setter(Builder::undeprecatedMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UndeprecatedMember").build()) + .build(); private static final SdkField MEMBER_IGNORE_DATA_TYPE_FAILURE_HANDLING_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("MemberIgnoreDataTypeFailureHandling") - .getter(getter(OperationWithDeprecatedMemberRequest::memberIgnoreDataTypeFailureHandling)) - .setter(setter(Builder::memberIgnoreDataTypeFailureHandling)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("MemberIgnoreDataTypeFailureHandling").build(), new DataTypeConversionFailureHandlingTrait()) - .build(); + . builder(MarshallingType.STRING) + .memberName("MemberIgnoreDataTypeFailureHandling") + .getter(getter(OperationWithDeprecatedMemberRequest::memberIgnoreDataTypeFailureHandling)) + .setter(setter(Builder::memberIgnoreDataTypeFailureHandling)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("MemberIgnoreDataTypeFailureHandling").build(), new DataTypeConversionFailureHandlingTrait()) + .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList( - MEMBER_MODELED_AS_DEPRECATED_FIELD, MEMBER_MODIFIED_AS_DEPRECATED_FIELD, UNDEPRECATED_MEMBER_FIELD, - MEMBER_IGNORE_DATA_TYPE_FAILURE_HANDLING_FIELD)); + MEMBER_MODELED_AS_DEPRECATED_FIELD, MEMBER_MODIFIED_AS_DEPRECATED_FIELD, UNDEPRECATED_MEMBER_FIELD, + MEMBER_IGNORE_DATA_TYPE_FAILURE_HANDLING_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("MemberModeledAsDeprecated", MEMBER_MODELED_AS_DEPRECATED_FIELD); + put("MemberModifiedAsDeprecated", MEMBER_MODIFIED_AS_DEPRECATED_FIELD); + put("UndeprecatedMember", UNDEPRECATED_MEMBER_FIELD); + put("MemberIgnoreDataTypeFailureHandling", MEMBER_IGNORE_DATA_TYPE_FAILURE_HANDLING_FIELD); + } + }); private final String memberModeledAsDeprecated; @@ -77,7 +89,7 @@ private OperationWithDeprecatedMemberRequest(BuilderImpl builder) { /** * Returns the value of the MemberModeledAsDeprecated property for this object. - * + * * @return The value of the MemberModeledAsDeprecated property for this object. * @deprecated This field is modeled as deprecated. */ @@ -88,7 +100,7 @@ public final String memberModeledAsDeprecated() { /** * Returns the value of the MemberModifiedAsDeprecated property for this object. - * + * * @return The value of the MemberModifiedAsDeprecated property for this object. * @deprecated This field is modified as deprecated. */ @@ -99,7 +111,7 @@ public final String memberModifiedAsDeprecated() { /** * Returns the value of the UndeprecatedMember property for this object. - * + * * @return The value of the UndeprecatedMember property for this object. */ public final String undeprecatedMember() { @@ -108,7 +120,7 @@ public final String undeprecatedMember() { /** * Returns the value of the MemberIgnoreDataTypeFailureHandling property for this object. - * + * * @return The value of the MemberIgnoreDataTypeFailureHandling property for this object. */ public final String memberIgnoreDataTypeFailureHandling() { @@ -157,9 +169,9 @@ public final boolean equalsBySdkFields(Object obj) { } OperationWithDeprecatedMemberRequest other = (OperationWithDeprecatedMemberRequest) obj; return Objects.equals(memberModeledAsDeprecated(), other.memberModeledAsDeprecated()) - && Objects.equals(memberModifiedAsDeprecated(), other.memberModifiedAsDeprecated()) - && Objects.equals(undeprecatedMember(), other.undeprecatedMember()) - && Objects.equals(memberIgnoreDataTypeFailureHandling(), other.memberIgnoreDataTypeFailureHandling()); + && Objects.equals(memberModifiedAsDeprecated(), other.memberModifiedAsDeprecated()) + && Objects.equals(undeprecatedMember(), other.undeprecatedMember()) + && Objects.equals(memberIgnoreDataTypeFailureHandling(), other.memberIgnoreDataTypeFailureHandling()); } /** @@ -169,23 +181,23 @@ public final boolean equalsBySdkFields(Object obj) { @Override public final String toString() { return ToString.builder("OperationWithDeprecatedMemberRequest") - .add("MemberModeledAsDeprecated", memberModeledAsDeprecated()) - .add("MemberModifiedAsDeprecated", memberModifiedAsDeprecated()).add("UndeprecatedMember", undeprecatedMember()) - .add("MemberIgnoreDataTypeFailureHandling", memberIgnoreDataTypeFailureHandling()).build(); + .add("MemberModeledAsDeprecated", memberModeledAsDeprecated()) + .add("MemberModifiedAsDeprecated", memberModifiedAsDeprecated()).add("UndeprecatedMember", undeprecatedMember()) + .add("MemberIgnoreDataTypeFailureHandling", memberIgnoreDataTypeFailureHandling()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "MemberModeledAsDeprecated": - return Optional.ofNullable(clazz.cast(memberModeledAsDeprecated())); - case "MemberModifiedAsDeprecated": - return Optional.ofNullable(clazz.cast(memberModifiedAsDeprecated())); - case "UndeprecatedMember": - return Optional.ofNullable(clazz.cast(undeprecatedMember())); - case "MemberIgnoreDataTypeFailureHandling": - return Optional.ofNullable(clazz.cast(memberIgnoreDataTypeFailureHandling())); - default: - return Optional.empty(); + case "MemberModeledAsDeprecated": + return Optional.ofNullable(clazz.cast(memberModeledAsDeprecated())); + case "MemberModifiedAsDeprecated": + return Optional.ofNullable(clazz.cast(memberModifiedAsDeprecated())); + case "UndeprecatedMember": + return Optional.ofNullable(clazz.cast(undeprecatedMember())); + case "MemberIgnoreDataTypeFailureHandling": + return Optional.ofNullable(clazz.cast(memberIgnoreDataTypeFailureHandling())); + default: + return Optional.empty(); } } @@ -194,6 +206,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((OperationWithDeprecatedMemberRequest) obj); } @@ -203,7 +220,7 @@ private static BiConsumer setter(BiConsumer s) { } public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, - CopyableBuilder { + CopyableBuilder { /** * Sets the value of the MemberModeledAsDeprecated property for this object. * @@ -354,5 +371,10 @@ public OperationWithDeprecatedMemberRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithdeprecatedmemberresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithdeprecatedmemberresponse.java index abb3f9951f0d..56c4b9ac22f8 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithdeprecatedmemberresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithdeprecatedmemberresponse.java @@ -2,7 +2,9 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -21,30 +23,39 @@ */ @Generated("software.amazon.awssdk:codegen") public final class OperationWithDeprecatedMemberResponse extends JsonProtocolTestsResponse implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField MEMBER_MODELED_AS_DEPRECATED_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("MemberModeledAsDeprecated") - .getter(getter(OperationWithDeprecatedMemberResponse::memberModeledAsDeprecated)) - .setter(setter(Builder::memberModeledAsDeprecated)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberModeledAsDeprecated").build()) - .build(); + .memberName("MemberModeledAsDeprecated") + .getter(getter(OperationWithDeprecatedMemberResponse::memberModeledAsDeprecated)) + .setter(setter(Builder::memberModeledAsDeprecated)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberModeledAsDeprecated").build()) + .build(); private static final SdkField MEMBER_MODIFIED_AS_DEPRECATED_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("MemberModifiedAsDeprecated") - .getter(getter(OperationWithDeprecatedMemberResponse::memberModifiedAsDeprecated)) - .setter(setter(Builder::memberModifiedAsDeprecated)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberModifiedAsDeprecated").build()) - .build(); + . builder(MarshallingType.STRING) + .memberName("MemberModifiedAsDeprecated") + .getter(getter(OperationWithDeprecatedMemberResponse::memberModifiedAsDeprecated)) + .setter(setter(Builder::memberModifiedAsDeprecated)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberModifiedAsDeprecated").build()) + .build(); private static final SdkField UNDEPRECATED_MEMBER_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("UndeprecatedMember").getter(getter(OperationWithDeprecatedMemberResponse::undeprecatedMember)) - .setter(setter(Builder::undeprecatedMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UndeprecatedMember").build()) - .build(); + .memberName("UndeprecatedMember").getter(getter(OperationWithDeprecatedMemberResponse::undeprecatedMember)) + .setter(setter(Builder::undeprecatedMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UndeprecatedMember").build()) + .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList( - MEMBER_MODELED_AS_DEPRECATED_FIELD, MEMBER_MODIFIED_AS_DEPRECATED_FIELD, UNDEPRECATED_MEMBER_FIELD)); + MEMBER_MODELED_AS_DEPRECATED_FIELD, MEMBER_MODIFIED_AS_DEPRECATED_FIELD, UNDEPRECATED_MEMBER_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("MemberModeledAsDeprecated", MEMBER_MODELED_AS_DEPRECATED_FIELD); + put("MemberModifiedAsDeprecated", MEMBER_MODIFIED_AS_DEPRECATED_FIELD); + put("UndeprecatedMember", UNDEPRECATED_MEMBER_FIELD); + } + }); private final String memberModeledAsDeprecated; @@ -61,7 +72,7 @@ private OperationWithDeprecatedMemberResponse(BuilderImpl builder) { /** * Returns the value of the MemberModeledAsDeprecated property for this object. - * + * * @return The value of the MemberModeledAsDeprecated property for this object. * @deprecated This field is modeled as deprecated. */ @@ -72,7 +83,7 @@ public final String memberModeledAsDeprecated() { /** * Returns the value of the MemberModifiedAsDeprecated property for this object. - * + * * @return The value of the MemberModifiedAsDeprecated property for this object. */ public final String memberModifiedAsDeprecated() { @@ -81,7 +92,7 @@ public final String memberModifiedAsDeprecated() { /** * Returns the value of the UndeprecatedMember property for this object. - * + * * @return The value of the UndeprecatedMember property for this object. */ public final String undeprecatedMember() { @@ -129,8 +140,8 @@ public final boolean equalsBySdkFields(Object obj) { } OperationWithDeprecatedMemberResponse other = (OperationWithDeprecatedMemberResponse) obj; return Objects.equals(memberModeledAsDeprecated(), other.memberModeledAsDeprecated()) - && Objects.equals(memberModifiedAsDeprecated(), other.memberModifiedAsDeprecated()) - && Objects.equals(undeprecatedMember(), other.undeprecatedMember()); + && Objects.equals(memberModifiedAsDeprecated(), other.memberModifiedAsDeprecated()) + && Objects.equals(undeprecatedMember(), other.undeprecatedMember()); } /** @@ -140,21 +151,21 @@ public final boolean equalsBySdkFields(Object obj) { @Override public final String toString() { return ToString.builder("OperationWithDeprecatedMemberResponse") - .add("MemberModeledAsDeprecated", memberModeledAsDeprecated()) - .add("MemberModifiedAsDeprecated", memberModifiedAsDeprecated()).add("UndeprecatedMember", undeprecatedMember()) - .build(); + .add("MemberModeledAsDeprecated", memberModeledAsDeprecated()) + .add("MemberModifiedAsDeprecated", memberModifiedAsDeprecated()).add("UndeprecatedMember", undeprecatedMember()) + .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "MemberModeledAsDeprecated": - return Optional.ofNullable(clazz.cast(memberModeledAsDeprecated())); - case "MemberModifiedAsDeprecated": - return Optional.ofNullable(clazz.cast(memberModifiedAsDeprecated())); - case "UndeprecatedMember": - return Optional.ofNullable(clazz.cast(undeprecatedMember())); - default: - return Optional.empty(); + case "MemberModeledAsDeprecated": + return Optional.ofNullable(clazz.cast(memberModeledAsDeprecated())); + case "MemberModifiedAsDeprecated": + return Optional.ofNullable(clazz.cast(memberModifiedAsDeprecated())); + case "UndeprecatedMember": + return Optional.ofNullable(clazz.cast(undeprecatedMember())); + default: + return Optional.empty(); } } @@ -163,6 +174,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((OperationWithDeprecatedMemberResponse) obj); } @@ -172,7 +188,7 @@ private static BiConsumer setter(BiConsumer s) { } public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, - CopyableBuilder { + CopyableBuilder { /** * Sets the value of the MemberModeledAsDeprecated property for this object. * @@ -274,5 +290,10 @@ public OperationWithDeprecatedMemberResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithnoinputoroutputrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithnoinputoroutputrequest.java index 55b4018a03d1..674b18a08e82 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithnoinputoroutputrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithnoinputoroutputrequest.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; @@ -16,7 +16,9 @@ @Generated("software.amazon.awssdk:codegen") public final class OperationWithNoInputOrOutputRequest extends JsonProtocolTestsRequest implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private OperationWithNoInputOrOutputRequest(BuilderImpl builder) { super(builder); @@ -79,6 +81,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, CopyableBuilder { @Override @@ -117,5 +124,10 @@ public OperationWithNoInputOrOutputRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithnoinputoroutputresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithnoinputoroutputresponse.java index 264de5529590..cfbedcd33ee9 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithnoinputoroutputresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/operationwithnoinputoroutputresponse.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -14,7 +14,9 @@ @Generated("software.amazon.awssdk:codegen") public final class OperationWithNoInputOrOutputResponse extends JsonProtocolTestsResponse implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private OperationWithNoInputOrOutputResponse(BuilderImpl builder) { super(builder); @@ -77,6 +79,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, CopyableBuilder { } @@ -98,6 +105,10 @@ public OperationWithNoInputOrOutputResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/queryparameteroperationrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/queryparameteroperationrequest.java index 4b117b63420d..0e93e5e4ba9d 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/queryparameteroperationrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/queryparameteroperationrequest.java @@ -3,7 +3,9 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -29,80 +31,92 @@ */ @Generated("software.amazon.awssdk:codegen") public final class QueryParameterOperationRequest extends JsonProtocolTestsRequest implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField PATH_PARAM_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("PathParam") - .getter(getter(QueryParameterOperationRequest::pathParam)) - .setter(setter(Builder::pathParam)) - .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("PathParam").build(), - RequiredTrait.create()).build(); + . builder(MarshallingType.STRING) + .memberName("PathParam") + .getter(getter(QueryParameterOperationRequest::pathParam)) + .setter(setter(Builder::pathParam)) + .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("PathParam").build(), + RequiredTrait.create()).build(); private static final SdkField QUERY_PARAM_ONE_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("QueryParamOne") - .getter(getter(QueryParameterOperationRequest::queryParamOne)) - .setter(setter(Builder::queryParamOne)) - .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("QueryParamOne").build(), - RequiredTrait.create()).build(); - - private static final SdkField QUERY_PARAM_TWO_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("QueryParamTwo").getter(getter(QueryParameterOperationRequest::queryParamTwo)) - .setter(setter(Builder::queryParamTwo)) - .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("QueryParamTwo").build()).build(); + . builder(MarshallingType.STRING) + .memberName("QueryParamOne") + .getter(getter(QueryParameterOperationRequest::queryParamOne)) + .setter(setter(Builder::queryParamOne)) + .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("QueryParamOne").build(), + RequiredTrait.create()).build(); + + private static final SdkField QUERY_PARAM_TWO_FIELD = SdkField. builder(MarshallingType.STRING) + .memberName("QueryParamTwo").getter(getter(QueryParameterOperationRequest::queryParamTwo)) + .setter(setter(Builder::queryParamTwo)) + .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("QueryParamTwo").build()).build(); private static final SdkField STRING_HEADER_MEMBER_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("StringHeaderMember") - .getter(getter(QueryParameterOperationRequest::stringHeaderMember)) - .setter(setter(Builder::stringHeaderMember)) - .traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-header-string").build(), - RequiredTrait.create()).build(); + . builder(MarshallingType.STRING) + .memberName("StringHeaderMember") + .getter(getter(QueryParameterOperationRequest::stringHeaderMember)) + .setter(setter(Builder::stringHeaderMember)) + .traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-header-string").build(), + RequiredTrait.create()).build(); private static final SdkField NESTED_QUERY_PARAMETER_OPERATION_FIELD = SdkField - . builder(MarshallingType.SDK_POJO) - .memberName("NestedQueryParameterOperation") - .getter(getter(QueryParameterOperationRequest::nestedQueryParameterOperation)) - .setter(setter(Builder::nestedQueryParameterOperation)) - .constructor(NestedQueryParameterOperation::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NestedQueryParameterOperation") - .build(), PayloadTrait.create()).build(); + . builder(MarshallingType.SDK_POJO) + .memberName("NestedQueryParameterOperation") + .getter(getter(QueryParameterOperationRequest::nestedQueryParameterOperation)) + .setter(setter(Builder::nestedQueryParameterOperation)) + .constructor(NestedQueryParameterOperation::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NestedQueryParameterOperation") + .build(), PayloadTrait.create()).build(); private static final SdkField> REQUIRED_LIST_QUERY_PARAMS_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("RequiredListQueryParams") - .getter(getter(QueryParameterOperationRequest::requiredListQueryParams)) - .setter(setter(Builder::requiredListQueryParams)) - .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("RequiredListQueryParams") - .build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.INTEGER) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build(), RequiredTrait.create()) - .build(); + .> builder(MarshallingType.LIST) + .memberName("RequiredListQueryParams") + .getter(getter(QueryParameterOperationRequest::requiredListQueryParams)) + .setter(setter(Builder::requiredListQueryParams)) + .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("RequiredListQueryParams") + .build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.INTEGER) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build(), RequiredTrait.create()) + .build(); private static final SdkField> OPTIONAL_LIST_QUERY_PARAMS_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("OptionalListQueryParams") - .getter(getter(QueryParameterOperationRequest::optionalListQueryParams)) - .setter(setter(Builder::optionalListQueryParams)) - .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("OptionalListQueryParams") - .build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.INTEGER) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("OptionalListQueryParams") + .getter(getter(QueryParameterOperationRequest::optionalListQueryParams)) + .setter(setter(Builder::optionalListQueryParams)) + .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("OptionalListQueryParams") + .build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.INTEGER) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PATH_PARAM_FIELD, - QUERY_PARAM_ONE_FIELD, QUERY_PARAM_TWO_FIELD, STRING_HEADER_MEMBER_FIELD, NESTED_QUERY_PARAMETER_OPERATION_FIELD, - REQUIRED_LIST_QUERY_PARAMS_FIELD, OPTIONAL_LIST_QUERY_PARAMS_FIELD)); + QUERY_PARAM_ONE_FIELD, QUERY_PARAM_TWO_FIELD, STRING_HEADER_MEMBER_FIELD, NESTED_QUERY_PARAMETER_OPERATION_FIELD, + REQUIRED_LIST_QUERY_PARAMS_FIELD, OPTIONAL_LIST_QUERY_PARAMS_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("PathParam", PATH_PARAM_FIELD); + put("QueryParamOne", QUERY_PARAM_ONE_FIELD); + put("QueryParamTwo", QUERY_PARAM_TWO_FIELD); + put("x-amz-header-string", STRING_HEADER_MEMBER_FIELD); + put("NestedQueryParameterOperation", NESTED_QUERY_PARAMETER_OPERATION_FIELD); + put("RequiredListQueryParams", REQUIRED_LIST_QUERY_PARAMS_FIELD); + put("OptionalListQueryParams", OPTIONAL_LIST_QUERY_PARAMS_FIELD); + } + }); private final String pathParam; @@ -131,7 +145,7 @@ private QueryParameterOperationRequest(BuilderImpl builder) { /** * Returns the value of the PathParam property for this object. - * + * * @return The value of the PathParam property for this object. */ public final String pathParam() { @@ -140,7 +154,7 @@ public final String pathParam() { /** * Returns the value of the QueryParamOne property for this object. - * + * * @return The value of the QueryParamOne property for this object. */ public final String queryParamOne() { @@ -149,7 +163,7 @@ public final String queryParamOne() { /** * Returns the value of the QueryParamTwo property for this object. - * + * * @return The value of the QueryParamTwo property for this object. */ public final String queryParamTwo() { @@ -158,7 +172,7 @@ public final String queryParamTwo() { /** * Returns the value of the StringHeaderMember property for this object. - * + * * @return The value of the StringHeaderMember property for this object. */ public final String stringHeaderMember() { @@ -167,7 +181,7 @@ public final String stringHeaderMember() { /** * Returns the value of the NestedQueryParameterOperation property for this object. - * + * * @return The value of the NestedQueryParameterOperation property for this object. */ public final NestedQueryParameterOperation nestedQueryParameterOperation() { @@ -195,7 +209,7 @@ public final boolean hasRequiredListQueryParams() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasRequiredListQueryParams} method. *

- * + * * @return The value of the RequiredListQueryParams property for this object. */ public final List requiredListQueryParams() { @@ -223,7 +237,7 @@ public final boolean hasOptionalListQueryParams() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasOptionalListQueryParams} method. *

- * + * * @return The value of the OptionalListQueryParams property for this object. */ public final List optionalListQueryParams() { @@ -275,13 +289,13 @@ public final boolean equalsBySdkFields(Object obj) { } QueryParameterOperationRequest other = (QueryParameterOperationRequest) obj; return Objects.equals(pathParam(), other.pathParam()) && Objects.equals(queryParamOne(), other.queryParamOne()) - && Objects.equals(queryParamTwo(), other.queryParamTwo()) - && Objects.equals(stringHeaderMember(), other.stringHeaderMember()) - && Objects.equals(nestedQueryParameterOperation(), other.nestedQueryParameterOperation()) - && hasRequiredListQueryParams() == other.hasRequiredListQueryParams() - && Objects.equals(requiredListQueryParams(), other.requiredListQueryParams()) - && hasOptionalListQueryParams() == other.hasOptionalListQueryParams() - && Objects.equals(optionalListQueryParams(), other.optionalListQueryParams()); + && Objects.equals(queryParamTwo(), other.queryParamTwo()) + && Objects.equals(stringHeaderMember(), other.stringHeaderMember()) + && Objects.equals(nestedQueryParameterOperation(), other.nestedQueryParameterOperation()) + && hasRequiredListQueryParams() == other.hasRequiredListQueryParams() + && Objects.equals(requiredListQueryParams(), other.requiredListQueryParams()) + && hasOptionalListQueryParams() == other.hasOptionalListQueryParams() + && Objects.equals(optionalListQueryParams(), other.optionalListQueryParams()); } /** @@ -291,31 +305,31 @@ && hasOptionalListQueryParams() == other.hasOptionalListQueryParams() @Override public final String toString() { return ToString.builder("QueryParameterOperationRequest").add("PathParam", pathParam()) - .add("QueryParamOne", queryParamOne()).add("QueryParamTwo", queryParamTwo()) - .add("StringHeaderMember", stringHeaderMember()) - .add("NestedQueryParameterOperation", nestedQueryParameterOperation()) - .add("RequiredListQueryParams", hasRequiredListQueryParams() ? requiredListQueryParams() : null) - .add("OptionalListQueryParams", hasOptionalListQueryParams() ? optionalListQueryParams() : null).build(); + .add("QueryParamOne", queryParamOne()).add("QueryParamTwo", queryParamTwo()) + .add("StringHeaderMember", stringHeaderMember()) + .add("NestedQueryParameterOperation", nestedQueryParameterOperation()) + .add("RequiredListQueryParams", hasRequiredListQueryParams() ? requiredListQueryParams() : null) + .add("OptionalListQueryParams", hasOptionalListQueryParams() ? optionalListQueryParams() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "PathParam": - return Optional.ofNullable(clazz.cast(pathParam())); - case "QueryParamOne": - return Optional.ofNullable(clazz.cast(queryParamOne())); - case "QueryParamTwo": - return Optional.ofNullable(clazz.cast(queryParamTwo())); - case "StringHeaderMember": - return Optional.ofNullable(clazz.cast(stringHeaderMember())); - case "NestedQueryParameterOperation": - return Optional.ofNullable(clazz.cast(nestedQueryParameterOperation())); - case "RequiredListQueryParams": - return Optional.ofNullable(clazz.cast(requiredListQueryParams())); - case "OptionalListQueryParams": - return Optional.ofNullable(clazz.cast(optionalListQueryParams())); - default: - return Optional.empty(); + case "PathParam": + return Optional.ofNullable(clazz.cast(pathParam())); + case "QueryParamOne": + return Optional.ofNullable(clazz.cast(queryParamOne())); + case "QueryParamTwo": + return Optional.ofNullable(clazz.cast(queryParamTwo())); + case "StringHeaderMember": + return Optional.ofNullable(clazz.cast(stringHeaderMember())); + case "NestedQueryParameterOperation": + return Optional.ofNullable(clazz.cast(nestedQueryParameterOperation())); + case "RequiredListQueryParams": + return Optional.ofNullable(clazz.cast(requiredListQueryParams())); + case "OptionalListQueryParams": + return Optional.ofNullable(clazz.cast(optionalListQueryParams())); + default: + return Optional.empty(); } } @@ -324,6 +338,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((QueryParameterOperationRequest) obj); } @@ -333,7 +352,7 @@ private static BiConsumer setter(BiConsumer s) { } public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, - CopyableBuilder { + CopyableBuilder { /** * Sets the value of the PathParam property for this object. * @@ -388,16 +407,16 @@ public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, *

* When the {@link Consumer} completes, {@link NestedQueryParameterOperation.Builder#build()} is called * immediately and its result is passed to {@link #nestedQueryParameterOperation(NestedQueryParameterOperation)}. - * + * * @param nestedQueryParameterOperation * a consumer that will call methods on {@link NestedQueryParameterOperation.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #nestedQueryParameterOperation(NestedQueryParameterOperation) */ default Builder nestedQueryParameterOperation( - Consumer nestedQueryParameterOperation) { + Consumer nestedQueryParameterOperation) { return nestedQueryParameterOperation(NestedQueryParameterOperation.builder() - .applyMutation(nestedQueryParameterOperation).build()); + .applyMutation(nestedQueryParameterOperation).build()); } /** @@ -534,7 +553,7 @@ public final NestedQueryParameterOperation.Builder getNestedQueryParameterOperat public final void setNestedQueryParameterOperation(NestedQueryParameterOperation.BuilderImpl nestedQueryParameterOperation) { this.nestedQueryParameterOperation = nestedQueryParameterOperation != null ? nestedQueryParameterOperation.build() - : null; + : null; } @Override @@ -612,5 +631,10 @@ public QueryParameterOperationRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/queryparameteroperationresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/queryparameteroperationresponse.java index eb4a235c6097..6cc43e538db8 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/queryparameteroperationresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/queryparameteroperationresponse.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -13,8 +13,10 @@ @Generated("software.amazon.awssdk:codegen") public final class QueryParameterOperationResponse extends JsonProtocolTestsResponse implements - ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + ToCopyableBuilder { + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private QueryParameterOperationResponse(BuilderImpl builder) { super(builder); @@ -77,8 +79,13 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, - CopyableBuilder { + CopyableBuilder { } static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl implements Builder { @@ -98,5 +105,10 @@ public QueryParameterOperationResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/recursivestructtype.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/recursivestructtype.java index b952493bc537..79c15ec68bf8 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/recursivestructtype.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/recursivestructtype.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -33,49 +34,59 @@ */ @Generated("software.amazon.awssdk:codegen") public final class RecursiveStructType implements SdkPojo, Serializable, - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField NO_RECURSE_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("NoRecurse").getter(getter(RecursiveStructType::noRecurse)).setter(setter(Builder::noRecurse)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NoRecurse").build()).build(); + .memberName("NoRecurse").getter(getter(RecursiveStructType::noRecurse)).setter(setter(Builder::noRecurse)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NoRecurse").build()).build(); private static final SdkField RECURSIVE_STRUCT_FIELD = SdkField - . builder(MarshallingType.SDK_POJO).memberName("RecursiveStruct") - .getter(getter(RecursiveStructType::recursiveStruct)).setter(setter(Builder::recursiveStruct)) - .constructor(RecursiveStructType::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveStruct").build()).build(); + . builder(MarshallingType.SDK_POJO).memberName("RecursiveStruct") + .getter(getter(RecursiveStructType::recursiveStruct)).setter(setter(Builder::recursiveStruct)) + .constructor(RecursiveStructType::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveStruct").build()).build(); private static final SdkField> RECURSIVE_LIST_FIELD = SdkField - .> builder(MarshallingType.LIST) - .memberName("RecursiveList") - .getter(getter(RecursiveStructType::recursiveList)) - .setter(setter(Builder::recursiveList)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveList").build(), - ListTrait - .builder() - .memberLocationName(null) - .memberFieldInfo( - SdkField. builder(MarshallingType.SDK_POJO) - .constructor(RecursiveStructType::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("member").build()).build()).build()).build(); + .> builder(MarshallingType.LIST) + .memberName("RecursiveList") + .getter(getter(RecursiveStructType::recursiveList)) + .setter(setter(Builder::recursiveList)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveList").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.SDK_POJO) + .constructor(RecursiveStructType::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); private static final SdkField> RECURSIVE_MAP_FIELD = SdkField - .> builder(MarshallingType.MAP) - .memberName("RecursiveMap") - .getter(getter(RecursiveStructType::recursiveMap)) - .setter(setter(Builder::recursiveMap)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveMap").build(), - MapTrait.builder() - .keyLocationName("key") - .valueLocationName("value") - .valueFieldInfo( - SdkField. builder(MarshallingType.SDK_POJO) - .constructor(RecursiveStructType::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) - .locationName("value").build()).build()).build()).build(); + .> builder(MarshallingType.MAP) + .memberName("RecursiveMap") + .getter(getter(RecursiveStructType::recursiveMap)) + .setter(setter(Builder::recursiveMap)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveMap").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.SDK_POJO) + .constructor(RecursiveStructType::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NO_RECURSE_FIELD, - RECURSIVE_STRUCT_FIELD, RECURSIVE_LIST_FIELD, RECURSIVE_MAP_FIELD)); + RECURSIVE_STRUCT_FIELD, RECURSIVE_LIST_FIELD, RECURSIVE_MAP_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("NoRecurse", NO_RECURSE_FIELD); + put("RecursiveStruct", RECURSIVE_STRUCT_FIELD); + put("RecursiveList", RECURSIVE_LIST_FIELD); + put("RecursiveMap", RECURSIVE_MAP_FIELD); + } + }); private static final long serialVersionUID = 1L; @@ -96,7 +107,7 @@ private RecursiveStructType(BuilderImpl builder) { /** * Returns the value of the NoRecurse property for this object. - * + * * @return The value of the NoRecurse property for this object. */ public final String noRecurse() { @@ -105,7 +116,7 @@ public final String noRecurse() { /** * Returns the value of the RecursiveStruct property for this object. - * + * * @return The value of the RecursiveStruct property for this object. */ public final RecursiveStructType recursiveStruct() { @@ -133,7 +144,7 @@ public final boolean hasRecursiveList() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasRecursiveList} method. *

- * + * * @return The value of the RecursiveList property for this object. */ public final List recursiveList() { @@ -161,7 +172,7 @@ public final boolean hasRecursiveMap() { * This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasRecursiveMap} method. *

- * + * * @return The value of the RecursiveMap property for this object. */ public final Map recursiveMap() { @@ -209,8 +220,8 @@ public final boolean equalsBySdkFields(Object obj) { } RecursiveStructType other = (RecursiveStructType) obj; return Objects.equals(noRecurse(), other.noRecurse()) && Objects.equals(recursiveStruct(), other.recursiveStruct()) - && hasRecursiveList() == other.hasRecursiveList() && Objects.equals(recursiveList(), other.recursiveList()) - && hasRecursiveMap() == other.hasRecursiveMap() && Objects.equals(recursiveMap(), other.recursiveMap()); + && hasRecursiveList() == other.hasRecursiveList() && Objects.equals(recursiveList(), other.recursiveList()) + && hasRecursiveMap() == other.hasRecursiveMap() && Objects.equals(recursiveMap(), other.recursiveMap()); } /** @@ -220,22 +231,22 @@ && hasRecursiveList() == other.hasRecursiveList() && Objects.equals(recursiveLis @Override public final String toString() { return ToString.builder("RecursiveStructType").add("NoRecurse", noRecurse()).add("RecursiveStruct", recursiveStruct()) - .add("RecursiveList", hasRecursiveList() ? recursiveList() : null) - .add("RecursiveMap", hasRecursiveMap() ? recursiveMap() : null).build(); + .add("RecursiveList", hasRecursiveList() ? recursiveList() : null) + .add("RecursiveMap", hasRecursiveMap() ? recursiveMap() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "NoRecurse": - return Optional.ofNullable(clazz.cast(noRecurse())); - case "RecursiveStruct": - return Optional.ofNullable(clazz.cast(recursiveStruct())); - case "RecursiveList": - return Optional.ofNullable(clazz.cast(recursiveList())); - case "RecursiveMap": - return Optional.ofNullable(clazz.cast(recursiveMap())); - default: - return Optional.empty(); + case "NoRecurse": + return Optional.ofNullable(clazz.cast(noRecurse())); + case "RecursiveStruct": + return Optional.ofNullable(clazz.cast(recursiveStruct())); + case "RecursiveList": + return Optional.ofNullable(clazz.cast(recursiveList())); + case "RecursiveMap": + return Optional.ofNullable(clazz.cast(recursiveMap())); + default: + return Optional.empty(); } } @@ -244,6 +255,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((RecursiveStructType) obj); } @@ -280,7 +296,7 @@ public interface Builder extends SdkPojo, CopyableBuilder * When the {@link Consumer} completes, {@link RecursiveStructType.Builder#build()} is called immediately and * its result is passed to {@link #recursiveStruct(RecursiveStructType)}. - * + * * @param recursiveStruct * a consumer that will call methods on {@link RecursiveStructType.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -320,7 +336,7 @@ default Builder recursiveStruct(Consumer recursiveStruct) { * When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.jsonprotocoltests.model.RecursiveStructType.Builder#build()} is called * immediately and its result is passed to {@link #recursiveList(List)}. - * + * * @param recursiveList * a consumer that will call methods on * {@link software.amazon.awssdk.services.jsonprotocoltests.model.RecursiveStructType.Builder} @@ -415,7 +431,7 @@ public final Builder recursiveList(RecursiveStructType... recursiveList) { @SafeVarargs public final Builder recursiveList(Consumer... recursiveList) { recursiveList(Stream.of(recursiveList).map(c -> RecursiveStructType.builder().applyMutation(c).build()) - .collect(Collectors.toList())); + .collect(Collectors.toList())); return this; } @@ -446,5 +462,10 @@ public RecursiveStructType build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/eventstream.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/eventstream.java index 6b72288939d8..7b4ee13981f9 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/eventstream.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/eventstream.java @@ -117,4 +117,3 @@ public static Set knownValues() { } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/getrandompersonrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/getrandompersonrequest.java index fe6a522a879d..3e45e3386348 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/getrandompersonrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/getrandompersonrequest.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.sharedeventstream.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; @@ -16,7 +16,9 @@ @Generated("software.amazon.awssdk:codegen") public final class GetRandomPersonRequest extends SharedEventStreamRequest implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private GetRandomPersonRequest(BuilderImpl builder) { super(builder); @@ -79,6 +81,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SharedEventStreamRequest.Builder, SdkPojo, CopyableBuilder { @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @@ -116,5 +123,10 @@ public GetRandomPersonRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/getrandompersonresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/getrandompersonresponse.java index 33c982648f3e..86b8edc6c1fc 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/getrandompersonresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/getrandompersonresponse.java @@ -3,7 +3,9 @@ import java.time.Instant; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -23,17 +25,25 @@ */ @Generated("software.amazon.awssdk:codegen") public class GetRandomPersonResponse extends SharedEventStreamResponse implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name") - .getter(getter(GetRandomPersonResponse::name)).setter(setter(Builder::name)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build(); + .getter(getter(GetRandomPersonResponse::name)).setter(setter(Builder::name)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build(); private static final SdkField BIRTHDAY_FIELD = SdkField. builder(MarshallingType.INSTANT) - .memberName("Birthday").getter(getter(GetRandomPersonResponse::birthday)).setter(setter(Builder::birthday)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Birthday").build()).build(); + .memberName("Birthday").getter(getter(GetRandomPersonResponse::birthday)).setter(setter(Builder::birthday)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Birthday").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, BIRTHDAY_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("Name", NAME_FIELD); + put("Birthday", BIRTHDAY_FIELD); + } + }); + private final String name; private final Instant birthday; @@ -46,7 +56,7 @@ protected GetRandomPersonResponse(BuilderImpl builder) { /** * Returns the value of the Name property for this object. - * + * * @return The value of the Name property for this object. */ public final String name() { @@ -55,7 +65,7 @@ public final String name() { /** * Returns the value of the Birthday property for this object. - * + * * @return The value of the Birthday property for this object. */ public final Instant birthday() { @@ -115,12 +125,12 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "Name": - return Optional.ofNullable(clazz.cast(name())); - case "Birthday": - return Optional.ofNullable(clazz.cast(birthday())); - default: - return Optional.empty(); + case "Name": + return Optional.ofNullable(clazz.cast(name())); + case "Birthday": + return Optional.ofNullable(clazz.cast(birthday())); + default: + return Optional.empty(); } } @@ -134,6 +144,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((GetRandomPersonResponse) obj); } @@ -143,7 +158,7 @@ private static BiConsumer setter(BiConsumer s) { } public interface Builder extends SharedEventStreamResponse.Builder, SdkPojo, - CopyableBuilder { + CopyableBuilder { /** * Sets the value of the Name property for this object. * @@ -214,5 +229,10 @@ public GetRandomPersonResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/person.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/person.java index 8db40e9730ab..024f95e4fa6e 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/person.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/person.java @@ -4,7 +4,9 @@ import java.time.Instant; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -25,15 +27,23 @@ @Generated("software.amazon.awssdk:codegen") public class Person implements SdkPojo, Serializable, ToCopyableBuilder, EventStream { private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name") - .getter(getter(Person::name)).setter(setter(Builder::name)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build(); + .getter(getter(Person::name)).setter(setter(Builder::name)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build(); private static final SdkField BIRTHDAY_FIELD = SdkField. builder(MarshallingType.INSTANT) - .memberName("Birthday").getter(getter(Person::birthday)).setter(setter(Builder::birthday)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Birthday").build()).build(); + .memberName("Birthday").getter(getter(Person::birthday)).setter(setter(Builder::birthday)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Birthday").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, BIRTHDAY_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("Name", NAME_FIELD); + put("Birthday", BIRTHDAY_FIELD); + } + }); + private static final long serialVersionUID = 1L; private final String name; @@ -47,7 +57,7 @@ protected Person(BuilderImpl builder) { /** * Returns the value of the Name property for this object. - * + * * @return The value of the Name property for this object. */ public final String name() { @@ -56,7 +66,7 @@ public final String name() { /** * Returns the value of the Birthday property for this object. - * + * * @return The value of the Birthday property for this object. */ public final Instant birthday() { @@ -115,12 +125,12 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "Name": - return Optional.ofNullable(clazz.cast(name())); - case "Birthday": - return Optional.ofNullable(clazz.cast(birthday())); - default: - return Optional.empty(); + case "Name": + return Optional.ofNullable(clazz.cast(name())); + case "Birthday": + return Optional.ofNullable(clazz.cast(birthday())); + default: + return Optional.empty(); } } @@ -134,6 +144,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((Person) obj); } @@ -234,5 +249,10 @@ public Person build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsrequest.java index ce82614a114b..00261160e668 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsrequest.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.sharedeventstream.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; @@ -16,7 +16,9 @@ @Generated("software.amazon.awssdk:codegen") public final class StreamBirthsRequest extends SharedEventStreamRequest implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private StreamBirthsRequest(BuilderImpl builder) { super(builder); @@ -79,6 +81,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SharedEventStreamRequest.Builder, SdkPojo, CopyableBuilder { @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @@ -116,5 +123,10 @@ public StreamBirthsRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsresponse.java index ff15117bac35..df7e64448e81 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsresponse.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.sharedeventstream.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -16,7 +16,9 @@ @Generated("software.amazon.awssdk:codegen") public final class StreamBirthsResponse extends SharedEventStreamResponse implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private StreamBirthsResponse(BuilderImpl builder) { super(builder); @@ -79,6 +81,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SharedEventStreamResponse.Builder, SdkPojo, CopyableBuilder { } @@ -99,5 +106,10 @@ public StreamBirthsResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsrequest.java index fd46bd164640..ae73dab63f42 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsrequest.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.sharedeventstream.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; @@ -16,7 +16,9 @@ @Generated("software.amazon.awssdk:codegen") public final class StreamDeathsRequest extends SharedEventStreamRequest implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private StreamDeathsRequest(BuilderImpl builder) { super(builder); @@ -79,6 +81,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SharedEventStreamRequest.Builder, SdkPojo, CopyableBuilder { @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @@ -116,5 +123,10 @@ public StreamDeathsRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsresponse.java index f524a65fac8b..fc7c6e434d44 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsresponse.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.sharedeventstream.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -16,7 +16,9 @@ @Generated("software.amazon.awssdk:codegen") public final class StreamDeathsResponse extends SharedEventStreamResponse implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private StreamDeathsResponse(BuilderImpl builder) { super(builder); @@ -79,6 +81,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SharedEventStreamResponse.Builder, SdkPojo, CopyableBuilder { } @@ -99,5 +106,10 @@ public StreamDeathsResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/simplestruct.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/simplestruct.java index 21b1389a8a4e..cc841851d37f 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/simplestruct.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/simplestruct.java @@ -3,7 +3,9 @@ import java.io.Serializable; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -23,11 +25,18 @@ @Generated("software.amazon.awssdk:codegen") public final class SimpleStruct implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField STRING_MEMBER_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("StringMember").getter(getter(SimpleStruct::stringMember)).setter(setter(Builder::stringMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StringMember").build()).build(); + .memberName("StringMember").getter(getter(SimpleStruct::stringMember)).setter(setter(Builder::stringMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StringMember").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STRING_MEMBER_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("StringMember", STRING_MEMBER_FIELD); + } + }); + private static final long serialVersionUID = 1L; private final String stringMember; @@ -38,7 +47,7 @@ private SimpleStruct(BuilderImpl builder) { /** * Returns the value of the StringMember property for this object. - * + * * @return The value of the StringMember property for this object. */ public final String stringMember() { @@ -96,10 +105,10 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "StringMember": - return Optional.ofNullable(clazz.cast(stringMember())); - default: - return Optional.empty(); + case "StringMember": + return Optional.ofNullable(clazz.cast(stringMember())); + default: + return Optional.empty(); } } @@ -108,6 +117,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((SimpleStruct) obj); } @@ -160,5 +174,10 @@ public SimpleStruct build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streaminginputoperationrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streaminginputoperationrequest.java index f34af78fc192..82bee4346318 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streaminginputoperationrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streaminginputoperationrequest.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; @@ -18,7 +18,9 @@ @Generated("software.amazon.awssdk:codegen") public final class StreamingInputOperationRequest extends JsonProtocolTestsRequest implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private StreamingInputOperationRequest(BuilderImpl builder) { super(builder); @@ -81,6 +83,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, CopyableBuilder { @Override @@ -119,5 +126,10 @@ public StreamingInputOperationRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streaminginputoperationresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streaminginputoperationresponse.java index cb025aac891d..47b3cbc068e8 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streaminginputoperationresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streaminginputoperationresponse.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -14,7 +14,9 @@ @Generated("software.amazon.awssdk:codegen") public final class StreamingInputOperationResponse extends JsonProtocolTestsResponse implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private StreamingInputOperationResponse(BuilderImpl builder) { super(builder); @@ -77,6 +79,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, CopyableBuilder { } @@ -98,6 +105,10 @@ public StreamingInputOperationResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streamingoutputoperationrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streamingoutputoperationrequest.java index 4ad67e9f6e1e..4967c7996847 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streamingoutputoperationrequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streamingoutputoperationrequest.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; @@ -16,7 +16,9 @@ @Generated("software.amazon.awssdk:codegen") public final class StreamingOutputOperationRequest extends JsonProtocolTestsRequest implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private StreamingOutputOperationRequest(BuilderImpl builder) { super(builder); @@ -79,6 +81,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, CopyableBuilder { @Override @@ -117,5 +124,10 @@ public StreamingOutputOperationRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streamingoutputoperationresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streamingoutputoperationresponse.java index 90616ea19ffc..912e89b8d55f 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streamingoutputoperationresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/streamingoutputoperationresponse.java @@ -1,8 +1,8 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -16,7 +16,9 @@ @Generated("software.amazon.awssdk:codegen") public final class StreamingOutputOperationResponse extends JsonProtocolTestsResponse implements ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private StreamingOutputOperationResponse(BuilderImpl builder) { super(builder); @@ -79,6 +81,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, CopyableBuilder { } @@ -100,6 +107,10 @@ public StreamingOutputOperationResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/structwithnestedblobtype.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/structwithnestedblobtype.java index aa09ec34238d..23222c5eda66 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/structwithnestedblobtype.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/structwithnestedblobtype.java @@ -4,7 +4,9 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -24,13 +26,20 @@ */ @Generated("software.amazon.awssdk:codegen") public final class StructWithNestedBlobType implements SdkPojo, Serializable, - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField NESTED_BLOB_FIELD = SdkField. builder(MarshallingType.SDK_BYTES) - .memberName("NestedBlob").getter(getter(StructWithNestedBlobType::nestedBlob)).setter(setter(Builder::nestedBlob)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NestedBlob").build()).build(); + .memberName("NestedBlob").getter(getter(StructWithNestedBlobType::nestedBlob)).setter(setter(Builder::nestedBlob)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NestedBlob").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NESTED_BLOB_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("NestedBlob", NESTED_BLOB_FIELD); + } + }); + private static final long serialVersionUID = 1L; private final SdkBytes nestedBlob; @@ -41,7 +50,7 @@ private StructWithNestedBlobType(BuilderImpl builder) { /** * Returns the value of the NestedBlob property for this object. - * + * * @return The value of the NestedBlob property for this object. */ public final SdkBytes nestedBlob() { @@ -99,10 +108,10 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "NestedBlob": - return Optional.ofNullable(clazz.cast(nestedBlob())); - default: - return Optional.empty(); + case "NestedBlob": + return Optional.ofNullable(clazz.cast(nestedBlob())); + default: + return Optional.empty(); } } @@ -111,6 +120,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((StructWithNestedBlobType) obj); } @@ -163,5 +177,10 @@ public StructWithNestedBlobType build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/structwithtimestamp.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/structwithtimestamp.java index 431f83012f67..f0c59e64b8a5 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/structwithtimestamp.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/structwithtimestamp.java @@ -4,7 +4,9 @@ import java.time.Instant; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -23,14 +25,21 @@ */ @Generated("software.amazon.awssdk:codegen") public final class StructWithTimestamp implements SdkPojo, Serializable, - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField NESTED_TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT) - .memberName("NestedTimestamp").getter(getter(StructWithTimestamp::nestedTimestamp)) - .setter(setter(Builder::nestedTimestamp)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NestedTimestamp").build()).build(); + .memberName("NestedTimestamp").getter(getter(StructWithTimestamp::nestedTimestamp)) + .setter(setter(Builder::nestedTimestamp)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NestedTimestamp").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NESTED_TIMESTAMP_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("NestedTimestamp", NESTED_TIMESTAMP_FIELD); + } + }); + private static final long serialVersionUID = 1L; private final Instant nestedTimestamp; @@ -41,7 +50,7 @@ private StructWithTimestamp(BuilderImpl builder) { /** * Returns the value of the NestedTimestamp property for this object. - * + * * @return The value of the NestedTimestamp property for this object. */ public final Instant nestedTimestamp() { @@ -99,10 +108,10 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "NestedTimestamp": - return Optional.ofNullable(clazz.cast(nestedTimestamp())); - default: - return Optional.empty(); + case "NestedTimestamp": + return Optional.ofNullable(clazz.cast(nestedTimestamp())); + default: + return Optional.empty(); } } @@ -111,6 +120,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((StructWithTimestamp) obj); } @@ -163,5 +177,10 @@ public StructWithTimestamp build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/subtypeone.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/subtypeone.java index 512a2779291f..99cc38b8fdc5 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/subtypeone.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/subtypeone.java @@ -3,7 +3,9 @@ import java.io.Serializable; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -23,12 +25,19 @@ @Generated("software.amazon.awssdk:codegen") public final class SubTypeOne implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField SUB_TYPE_ONE_MEMBER_FIELD = SdkField. builder(MarshallingType.STRING) - .memberName("SubTypeOneMember").getter(getter(SubTypeOne::subTypeOneMember)) - .setter(setter(Builder::subTypeOneMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubTypeOneMember").build()).build(); + .memberName("SubTypeOneMember").getter(getter(SubTypeOne::subTypeOneMember)) + .setter(setter(Builder::subTypeOneMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubTypeOneMember").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SUB_TYPE_ONE_MEMBER_FIELD)); + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("SubTypeOneMember", SUB_TYPE_ONE_MEMBER_FIELD); + } + }); + private static final long serialVersionUID = 1L; private final String subTypeOneMember; @@ -39,7 +48,7 @@ private SubTypeOne(BuilderImpl builder) { /** * Returns the value of the SubTypeOneMember property for this object. - * + * * @return The value of the SubTypeOneMember property for this object. */ public final String subTypeOneMember() { @@ -97,10 +106,10 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "SubTypeOneMember": - return Optional.ofNullable(clazz.cast(subTypeOneMember())); - default: - return Optional.empty(); + case "SubTypeOneMember": + return Optional.ofNullable(clazz.cast(subTypeOneMember())); + default: + return Optional.empty(); } } @@ -109,6 +118,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((SubTypeOne) obj); } @@ -161,5 +175,10 @@ public SubTypeOne build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/underscore_name_type.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/underscore_name_type.java index 91328161e3ec..d70c63b4fe10 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/underscore_name_type.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/underscore_name_type.java @@ -1,9 +1,9 @@ package software.amazon.awssdk.services.jsonprotocoltests.model; import java.io.Serializable; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; @@ -17,7 +17,9 @@ @Generated("software.amazon.awssdk:codegen") public final class Underscore_Name_Type implements SdkPojo, Serializable, ToCopyableBuilder { - private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); + private static final List> SDK_FIELDS = Collections.emptyList(); + + private static final Map> SDK_NAME_TO_FIELD = Collections.emptyMap(); private static final long serialVersionUID = 1L; @@ -80,6 +82,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + public interface Builder extends SdkPojo, CopyableBuilder { } @@ -99,6 +106,10 @@ public Underscore_Name_Type build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/testxmlnamespacerequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/testxmlnamespacerequest.java index 907a75855a50..63c56170e330 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/testxmlnamespacerequest.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/testxmlnamespacerequest.java @@ -2,7 +2,9 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -25,41 +27,50 @@ */ @Generated("software.amazon.awssdk:codegen") public final class TestXmlNamespaceRequest extends ProtocolRestXmlRequest implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField STRING_MEMBER_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("stringMember") - .getter(getter(TestXmlNamespaceRequest::stringMember)) - .setter(setter(Builder::stringMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stringMember") - .unmarshallLocationName("stringMember").build()).build(); + . builder(MarshallingType.STRING) + .memberName("stringMember") + .getter(getter(TestXmlNamespaceRequest::stringMember)) + .setter(setter(Builder::stringMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stringMember") + .unmarshallLocationName("stringMember").build()).build(); private static final SdkField INTEGER_MEMBER_FIELD = SdkField - . builder(MarshallingType.INTEGER) - .memberName("integerMember") - .getter(getter(TestXmlNamespaceRequest::integerMember)) - .setter(setter(Builder::integerMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("integerMember") - .unmarshallLocationName("integerMember").build()).build(); + . builder(MarshallingType.INTEGER) + .memberName("integerMember") + .getter(getter(TestXmlNamespaceRequest::integerMember)) + .setter(setter(Builder::integerMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("integerMember") + .unmarshallLocationName("integerMember").build()).build(); private static final SdkField XML_NAMESPACE_MEMBER_FIELD = SdkField - . builder(MarshallingType.SDK_POJO) - .memberName("xmlNamespaceMember") - .getter(getter(TestXmlNamespaceRequest::xmlNamespaceMember)) - .setter(setter(Builder::xmlNamespaceMember)) - .constructor(XmlNamespaceMember::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("xmlNamespaceMember") - .unmarshallLocationName("xmlNamespaceMember").build(), - XmlAttributesTrait.create( - Pair.of("xmlns:foo", - XmlAttributesTrait.AttributeAccessors.builder().attributeGetter((ignore) -> "http://bar") - .build()), - Pair.of("foo:type", - XmlAttributesTrait.AttributeAccessors.builder() - .attributeGetter(t -> ((XmlNamespaceMember) t).type()).build()))).build(); + . builder(MarshallingType.SDK_POJO) + .memberName("xmlNamespaceMember") + .getter(getter(TestXmlNamespaceRequest::xmlNamespaceMember)) + .setter(setter(Builder::xmlNamespaceMember)) + .constructor(XmlNamespaceMember::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("xmlNamespaceMember") + .unmarshallLocationName("xmlNamespaceMember").build(), + XmlAttributesTrait.create( + Pair.of("xmlns:foo", + XmlAttributesTrait.AttributeAccessors.builder().attributeGetter((ignore) -> "http://bar") + .build()), + Pair.of("foo:type", + XmlAttributesTrait.AttributeAccessors.builder() + .attributeGetter(t -> ((XmlNamespaceMember) t).type()).build()))).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STRING_MEMBER_FIELD, - INTEGER_MEMBER_FIELD, XML_NAMESPACE_MEMBER_FIELD)); + INTEGER_MEMBER_FIELD, XML_NAMESPACE_MEMBER_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("stringMember", STRING_MEMBER_FIELD); + put("integerMember", INTEGER_MEMBER_FIELD); + put("xmlNamespaceMember", XML_NAMESPACE_MEMBER_FIELD); + } + }); private final String stringMember; @@ -76,7 +87,7 @@ private TestXmlNamespaceRequest(BuilderImpl builder) { /** * Returns the value of the StringMember property for this object. - * + * * @return The value of the StringMember property for this object. */ public final String stringMember() { @@ -85,7 +96,7 @@ public final String stringMember() { /** * Returns the value of the IntegerMember property for this object. - * + * * @return The value of the IntegerMember property for this object. */ public final Integer integerMember() { @@ -94,7 +105,7 @@ public final Integer integerMember() { /** * Returns the value of the XmlNamespaceMember property for this object. - * + * * @return The value of the XmlNamespaceMember property for this object. */ public final XmlNamespaceMember xmlNamespaceMember() { @@ -142,7 +153,7 @@ public final boolean equalsBySdkFields(Object obj) { } TestXmlNamespaceRequest other = (TestXmlNamespaceRequest) obj; return Objects.equals(stringMember(), other.stringMember()) && Objects.equals(integerMember(), other.integerMember()) - && Objects.equals(xmlNamespaceMember(), other.xmlNamespaceMember()); + && Objects.equals(xmlNamespaceMember(), other.xmlNamespaceMember()); } /** @@ -152,19 +163,19 @@ public final boolean equalsBySdkFields(Object obj) { @Override public final String toString() { return ToString.builder("TestXmlNamespaceRequest").add("StringMember", stringMember()) - .add("IntegerMember", integerMember()).add("XmlNamespaceMember", xmlNamespaceMember()).build(); + .add("IntegerMember", integerMember()).add("XmlNamespaceMember", xmlNamespaceMember()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "stringMember": - return Optional.ofNullable(clazz.cast(stringMember())); - case "integerMember": - return Optional.ofNullable(clazz.cast(integerMember())); - case "xmlNamespaceMember": - return Optional.ofNullable(clazz.cast(xmlNamespaceMember())); - default: - return Optional.empty(); + case "stringMember": + return Optional.ofNullable(clazz.cast(stringMember())); + case "integerMember": + return Optional.ofNullable(clazz.cast(integerMember())); + case "xmlNamespaceMember": + return Optional.ofNullable(clazz.cast(xmlNamespaceMember())); + default: + return Optional.empty(); } } @@ -173,6 +184,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((TestXmlNamespaceRequest) obj); } @@ -218,7 +234,7 @@ public interface Builder extends ProtocolRestXmlRequest.Builder, SdkPojo, Copyab *

* When the {@link Consumer} completes, {@link XmlNamespaceMember.Builder#build()} is called immediately and its * result is passed to {@link #xmlNamespaceMember(XmlNamespaceMember)}. - * + * * @param xmlNamespaceMember * a consumer that will call methods on {@link XmlNamespaceMember.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -315,5 +331,10 @@ public TestXmlNamespaceRequest build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/testxmlnamespaceresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/testxmlnamespaceresponse.java index 5cc0fc34be26..9af5fc42f84c 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/testxmlnamespaceresponse.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/testxmlnamespaceresponse.java @@ -2,7 +2,9 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -24,41 +26,50 @@ */ @Generated("software.amazon.awssdk:codegen") public final class TestXmlNamespaceResponse extends ProtocolRestXmlResponse implements - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField STRING_MEMBER_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("stringMember") - .getter(getter(TestXmlNamespaceResponse::stringMember)) - .setter(setter(Builder::stringMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stringMember") - .unmarshallLocationName("stringMember").build()).build(); + . builder(MarshallingType.STRING) + .memberName("stringMember") + .getter(getter(TestXmlNamespaceResponse::stringMember)) + .setter(setter(Builder::stringMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stringMember") + .unmarshallLocationName("stringMember").build()).build(); private static final SdkField INTEGER_MEMBER_FIELD = SdkField - . builder(MarshallingType.INTEGER) - .memberName("integerMember") - .getter(getter(TestXmlNamespaceResponse::integerMember)) - .setter(setter(Builder::integerMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("integerMember") - .unmarshallLocationName("integerMember").build()).build(); + . builder(MarshallingType.INTEGER) + .memberName("integerMember") + .getter(getter(TestXmlNamespaceResponse::integerMember)) + .setter(setter(Builder::integerMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("integerMember") + .unmarshallLocationName("integerMember").build()).build(); private static final SdkField XML_NAMESPACE_MEMBER_FIELD = SdkField - . builder(MarshallingType.SDK_POJO) - .memberName("xmlNamespaceMember") - .getter(getter(TestXmlNamespaceResponse::xmlNamespaceMember)) - .setter(setter(Builder::xmlNamespaceMember)) - .constructor(XmlNamespaceMember::builder) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("xmlNamespaceMember") - .unmarshallLocationName("xmlNamespaceMember").build(), - XmlAttributesTrait.create( - Pair.of("xmlns:foo", - XmlAttributesTrait.AttributeAccessors.builder().attributeGetter((ignore) -> "http://bar") - .build()), - Pair.of("foo:type", - XmlAttributesTrait.AttributeAccessors.builder() - .attributeGetter(t -> ((XmlNamespaceMember) t).type()).build()))).build(); + . builder(MarshallingType.SDK_POJO) + .memberName("xmlNamespaceMember") + .getter(getter(TestXmlNamespaceResponse::xmlNamespaceMember)) + .setter(setter(Builder::xmlNamespaceMember)) + .constructor(XmlNamespaceMember::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("xmlNamespaceMember") + .unmarshallLocationName("xmlNamespaceMember").build(), + XmlAttributesTrait.create( + Pair.of("xmlns:foo", + XmlAttributesTrait.AttributeAccessors.builder().attributeGetter((ignore) -> "http://bar") + .build()), + Pair.of("foo:type", + XmlAttributesTrait.AttributeAccessors.builder() + .attributeGetter(t -> ((XmlNamespaceMember) t).type()).build()))).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STRING_MEMBER_FIELD, - INTEGER_MEMBER_FIELD, XML_NAMESPACE_MEMBER_FIELD)); + INTEGER_MEMBER_FIELD, XML_NAMESPACE_MEMBER_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("stringMember", STRING_MEMBER_FIELD); + put("integerMember", INTEGER_MEMBER_FIELD); + put("xmlNamespaceMember", XML_NAMESPACE_MEMBER_FIELD); + } + }); private final String stringMember; @@ -75,7 +86,7 @@ private TestXmlNamespaceResponse(BuilderImpl builder) { /** * Returns the value of the StringMember property for this object. - * + * * @return The value of the StringMember property for this object. */ public final String stringMember() { @@ -84,7 +95,7 @@ public final String stringMember() { /** * Returns the value of the IntegerMember property for this object. - * + * * @return The value of the IntegerMember property for this object. */ public final Integer integerMember() { @@ -93,7 +104,7 @@ public final Integer integerMember() { /** * Returns the value of the XmlNamespaceMember property for this object. - * + * * @return The value of the XmlNamespaceMember property for this object. */ public final XmlNamespaceMember xmlNamespaceMember() { @@ -141,7 +152,7 @@ public final boolean equalsBySdkFields(Object obj) { } TestXmlNamespaceResponse other = (TestXmlNamespaceResponse) obj; return Objects.equals(stringMember(), other.stringMember()) && Objects.equals(integerMember(), other.integerMember()) - && Objects.equals(xmlNamespaceMember(), other.xmlNamespaceMember()); + && Objects.equals(xmlNamespaceMember(), other.xmlNamespaceMember()); } /** @@ -151,19 +162,19 @@ public final boolean equalsBySdkFields(Object obj) { @Override public final String toString() { return ToString.builder("TestXmlNamespaceResponse").add("StringMember", stringMember()) - .add("IntegerMember", integerMember()).add("XmlNamespaceMember", xmlNamespaceMember()).build(); + .add("IntegerMember", integerMember()).add("XmlNamespaceMember", xmlNamespaceMember()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "stringMember": - return Optional.ofNullable(clazz.cast(stringMember())); - case "integerMember": - return Optional.ofNullable(clazz.cast(integerMember())); - case "xmlNamespaceMember": - return Optional.ofNullable(clazz.cast(xmlNamespaceMember())); - default: - return Optional.empty(); + case "stringMember": + return Optional.ofNullable(clazz.cast(stringMember())); + case "integerMember": + return Optional.ofNullable(clazz.cast(integerMember())); + case "xmlNamespaceMember": + return Optional.ofNullable(clazz.cast(xmlNamespaceMember())); + default: + return Optional.empty(); } } @@ -172,6 +183,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((TestXmlNamespaceResponse) obj); } @@ -217,7 +233,7 @@ public interface Builder extends ProtocolRestXmlResponse.Builder, SdkPojo, Copya *

* When the {@link Consumer} completes, {@link XmlNamespaceMember.Builder#build()} is called immediately and its * result is passed to {@link #xmlNamespaceMember(XmlNamespaceMember)}. - * + * * @param xmlNamespaceMember * a consumer that will call methods on {@link XmlNamespaceMember.Builder} * @return Returns a reference to this object so that method calls can be chained together. @@ -296,5 +312,10 @@ public TestXmlNamespaceResponse build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/xmlnamespacemember.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/xmlnamespacemember.java index fa7b140ee887..1d4137f0f732 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/xmlnamespacemember.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/xmlnamespace/xmlnamespacemember.java @@ -3,7 +3,9 @@ import java.io.Serializable; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; @@ -23,25 +25,33 @@ */ @Generated("software.amazon.awssdk:codegen") public final class XmlNamespaceMember implements SdkPojo, Serializable, - ToCopyableBuilder { + ToCopyableBuilder { private static final SdkField TYPE_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("Type") - .getter(getter(XmlNamespaceMember::type)) - .setter(setter(Builder::type)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("foo:type") - .unmarshallLocationName("foo:type").build(), XmlAttributeTrait.create()).build(); + . builder(MarshallingType.STRING) + .memberName("Type") + .getter(getter(XmlNamespaceMember::type)) + .setter(setter(Builder::type)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("foo:type") + .unmarshallLocationName("foo:type").build(), XmlAttributeTrait.create()).build(); private static final SdkField STRING_MEMBER_FIELD = SdkField - . builder(MarshallingType.STRING) - .memberName("stringMember") - .getter(getter(XmlNamespaceMember::stringMember)) - .setter(setter(Builder::stringMember)) - .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stringMember") - .unmarshallLocationName("stringMember").build()).build(); + . builder(MarshallingType.STRING) + .memberName("stringMember") + .getter(getter(XmlNamespaceMember::stringMember)) + .setter(setter(Builder::stringMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stringMember") + .unmarshallLocationName("stringMember").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TYPE_FIELD, - STRING_MEMBER_FIELD)); + STRING_MEMBER_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("foo:type", TYPE_FIELD); + put("stringMember", STRING_MEMBER_FIELD); + } + }); private static final long serialVersionUID = 1L; @@ -56,7 +66,7 @@ private XmlNamespaceMember(BuilderImpl builder) { /** * Returns the value of the Type property for this object. - * + * * @return The value of the Type property for this object. */ public final String type() { @@ -65,7 +75,7 @@ public final String type() { /** * Returns the value of the StringMember property for this object. - * + * * @return The value of the StringMember property for this object. */ public final String stringMember() { @@ -124,12 +134,12 @@ public final String toString() { public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "Type": - return Optional.ofNullable(clazz.cast(type())); - case "stringMember": - return Optional.ofNullable(clazz.cast(stringMember())); - default: - return Optional.empty(); + case "Type": + return Optional.ofNullable(clazz.cast(type())); + case "stringMember": + return Optional.ofNullable(clazz.cast(stringMember())); + default: + return Optional.empty(); } } @@ -138,6 +148,11 @@ public final List> sdkFields() { return SDK_FIELDS; } + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + private static Function getter(Function g) { return obj -> g.apply((XmlNamespaceMember) obj); } @@ -216,5 +231,10 @@ public XmlNamespaceMember build() { public List> sdkFields() { return SDK_FIELDS; } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } } } diff --git a/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/BaseAwsJsonProtocolFactory.java b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/BaseAwsJsonProtocolFactory.java index cb076dcc721d..8453a0f646ec 100644 --- a/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/BaseAwsJsonProtocolFactory.java +++ b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/BaseAwsJsonProtocolFactory.java @@ -53,6 +53,7 @@ import software.amazon.awssdk.protocols.json.internal.unmarshall.JsonProtocolUnmarshaller; import software.amazon.awssdk.protocols.json.internal.unmarshall.JsonResponseHandler; import software.amazon.awssdk.protocols.json.internal.unmarshall.ProtocolUnmarshallDependencies; +import software.amazon.awssdk.protocols.json.internal.unmarshall.SdkClientJsonProtocolAdvancedOption; @SdkProtectedApi public abstract class BaseAwsJsonProtocolFactory { @@ -87,7 +88,16 @@ protected BaseAwsJsonProtocolFactory(Builder builder) { this.customErrorCodeFieldName = builder.customErrorCodeFieldName; this.hasAwsQueryCompatible = builder.hasAwsQueryCompatible; this.clientConfiguration = builder.clientConfiguration; + Boolean enableFastUnmarshalling = false; + if (clientConfiguration != null) { + enableFastUnmarshalling = + clientConfiguration.option(SdkClientJsonProtocolAdvancedOption.ENABLE_FAST_UNMARSHALLER); + if (enableFastUnmarshalling == null) { + enableFastUnmarshalling = false; + } + } this.protocolUnmarshaller = JsonProtocolUnmarshaller.builder() + .enableFastUnmarshalling(enableFastUnmarshalling) .protocolUnmarshallDependencies( builder.protocolUnmarshallDependencies.get()) .build(); diff --git a/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/AwsStructuredPlainJsonFactory.java b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/AwsStructuredPlainJsonFactory.java index fcdb6d705237..f9a751f094c7 100644 --- a/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/AwsStructuredPlainJsonFactory.java +++ b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/AwsStructuredPlainJsonFactory.java @@ -19,8 +19,9 @@ import software.amazon.awssdk.protocols.json.BaseAwsStructuredJsonFactory; import software.amazon.awssdk.protocols.json.SdkJsonGenerator; import software.amazon.awssdk.protocols.json.StructuredJsonGenerator; -import software.amazon.awssdk.protocols.jsoncore.JsonNodeParser; import software.amazon.awssdk.thirdparty.jackson.core.JsonFactory; +import software.amazon.awssdk.thirdparty.jackson.core.StreamReadFeature; +import software.amazon.awssdk.thirdparty.jackson.core.StreamWriteFeature; /** * Creates generators and protocol handlers for plain text JSON wire format. @@ -29,10 +30,13 @@ public final class AwsStructuredPlainJsonFactory { /** - * Recommended to share JsonFactory instances per http://wiki.fasterxml - * .com/JacksonBestPracticesPerformance + * Recommended to share JsonFactory instances per http://wiki.fasterxml.com/JacksonBestPracticesPerformance */ - private static final JsonFactory JSON_FACTORY = new JsonFactory(); + private static final JsonFactory JSON_FACTORY = JsonFactory.builder() + .enable(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER) + .enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER) + .enable(StreamWriteFeature.USE_FAST_DOUBLE_WRITER) + .build(); public static final BaseAwsStructuredJsonFactory SDK_JSON_FACTORY = new BaseAwsStructuredJsonFactory(JSON_FACTORY) { @Override @@ -43,7 +47,7 @@ protected StructuredJsonGenerator createWriter(JsonFactory jsonFactory, @Override public JsonFactory getJsonFactory() { - return JsonNodeParser.DEFAULT_JSON_FACTORY; + return JSON_FACTORY; } }; diff --git a/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonProtocolUnmarshaller.java b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonProtocolUnmarshaller.java index 6613ed82d573..526d205ca221 100644 --- a/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonProtocolUnmarshaller.java +++ b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonProtocolUnmarshaller.java @@ -18,6 +18,7 @@ import static software.amazon.awssdk.protocols.core.StringToValueConverter.TO_SDK_BYTES; import java.io.IOException; +import java.io.InputStream; import java.time.Instant; import java.util.ArrayList; import java.util.Collections; @@ -63,12 +64,26 @@ public class JsonProtocolUnmarshaller { new Lazy<>(JsonProtocolUnmarshaller::newProtocolUnmarshallDependencies); private final JsonUnmarshallerRegistry registry; + private final JsonUnmarshallingParser unmarshallingParser; private final JsonNodeParser parser; private JsonProtocolUnmarshaller(Builder builder) { ProtocolUnmarshallDependencies dependencies = builder.protocolUnmarshallDependencies; - this.parser = createParser(builder, dependencies); this.registry = dependencies.jsonUnmarshallerRegistry(); + if (builder.enableFastUnmarshalling) { + this.unmarshallingParser = JsonUnmarshallingParser.builder() + .jsonValueNodeFactory(dependencies.nodeValueFactory()) + .jsonFactory(dependencies.jsonFactory()) + .unmarshallerRegistry(dependencies.jsonUnmarshallerRegistry()) + .defaultTimestampFormat(dependencies.timestampFormats() + .get(MarshallLocation.PAYLOAD)) + + .build(); + this.parser = null; + } else { + this.unmarshallingParser = null; + this.parser = createParser(builder, dependencies); + } } private JsonNodeParser createParser(Builder builder, ProtocolUnmarshallDependencies dependencies) { @@ -224,23 +239,120 @@ public T unmarshall(JsonUnmarshallerContext context, public TypeT unmarshall(SdkPojo sdkPojo, SdkHttpFullResponse response) throws IOException { + if (this.unmarshallingParser != null) { + return fastUnmarshall(sdkPojo, response); + } JsonNode jsonNode = hasJsonPayload(sdkPojo, response) ? parser.parse(response.content().get()) : null; return unmarshall(sdkPojo, response, jsonNode); } + private TypeT fastUnmarshall(SdkPojo sdkPojo, + SdkHttpFullResponse response) throws IOException { + if (!hasJsonPayload(sdkPojo, response)) { + return unmarshallResponse(sdkPojo, response); + } + if (hasExplicitJsonPayloadMember(sdkPojo)) { + return unmarshallResponse(sdkPojo, response); + } + if (hasMixedLocations(sdkPojo)) { + unmarshallFromJson(sdkPojo, response.content().get()); + return unmarshallResponse(sdkPojo, response); + } + return unmarshallFromJson(sdkPojo, response.content().get()); + } + + @SuppressWarnings("unchecked") + private T unmarshallFromJson(SdkPojo sdkPojo, InputStream inputStream) { + return (T) unmarshallingParser.parse(sdkPojo, inputStream); + } + + private TypeT unmarshallResponse(SdkPojo sdkPojo, + SdkHttpFullResponse response) throws IOException { + JsonUnmarshallerContext context = JsonUnmarshallerContext.builder() + .unmarshallerRegistry(registry) + .response(response) + .build(); + for (SdkField field : sdkPojo.sdkFields()) { + if (isExplicitPayloadMember(field) && field.marshallingType() == MarshallingType.SDK_BYTES) { + Optional responseContent = context.response().content(); + if (responseContent.isPresent()) { + field.set(sdkPojo, SdkBytes.fromInputStream(responseContent.get())); + } else { + field.set(sdkPojo, SdkBytes.fromByteArrayUnsafe(new byte[0])); + } + } else if (isExplicitPayloadMember(field) && field.marshallingType() == MarshallingType.STRING) { + Optional responseContent = context.response().content(); + if (responseContent.isPresent()) { + field.set(sdkPojo, SdkBytes.fromInputStream(responseContent.get()).asUtf8String()); + } else { + field.set(sdkPojo, ""); + } + } else if (isExplicitPayloadMember(field) && field.marshallingType() == MarshallingType.SDK_POJO) { + Optional responseContent = context.response().content(); + if (responseContent.isPresent()) { + field.set(sdkPojo, unmarshallFromJson(field.constructor().get(), responseContent.get())); + } else { + field.set(sdkPojo, null); + } + } else if (!isPayloadUnmarshalling(field.location())) { + JsonUnmarshaller unmarshaller = context.getUnmarshaller(field.location(), field.marshallingType()); + field.set(sdkPojo, unmarshaller.unmarshall(context, null, (SdkField) field)); + } + } + return (TypeT) ((Buildable) sdkPojo).build(); + } + private boolean hasJsonPayload(SdkPojo sdkPojo, SdkHttpFullResponse response) { if (!response.content().isPresent()) { return false; } for (SdkField field : sdkPojo.sdkFields()) { - if (isPayloadMemberOnUnmarshall(field) && !isExplicitBlobPayloadMember(field) - && !isExplicitStringPayloadMember(field)) { + if (isPayloadMemberOnUnmarshall(field) + && !(isExplicitBlobPayloadMember(field) || isExplicitStringPayloadMember(field))) { + return true; + } + } + return false; + } + + private boolean hasExplicitJsonPayloadMember(SdkPojo sdkPojo) { + for (SdkField field : sdkPojo.sdkFields()) { + if (isExplicitSdkPojoPayloadMember(field)) { return true; } } return false; } + private boolean hasMixedLocations(SdkPojo sdkPojo) { + int payload = 0; + int header = 0; + int statusCode = 0; + for (SdkField field : sdkPojo.sdkFields()) { + MarshallLocation location = field.location(); + if (isPayloadUnmarshalling(location)) { + payload = 1; + } else if (location == MarshallLocation.HEADER) { + header = 1; + } else if (location == MarshallLocation.STATUS_CODE) { + statusCode = 1; + } + } + return (payload + header + statusCode) > 1; + } + + private boolean isPayloadUnmarshalling(MarshallLocation location) { + switch (location) { + case PAYLOAD: + case PATH: + case QUERY_PARAM: + case GREEDY_PATH: + return true; + default: + return false; + } + } + private boolean isExplicitBlobPayloadMember(SdkField f) { return isExplicitPayloadMember(f) && f.marshallingType() == MarshallingType.SDK_BYTES; } @@ -249,6 +361,10 @@ private boolean isExplicitStringPayloadMember(SdkField f) { return isExplicitPayloadMember(f) && f.marshallingType() == MarshallingType.STRING; } + private boolean isExplicitSdkPojoPayloadMember(SdkField f) { + return isExplicitPayloadMember(f) && f.marshallingType() == MarshallingType.SDK_POJO; + } + private static boolean isExplicitPayloadMember(SdkField f) { return f.containsTrait(PayloadTrait.class, TraitType.PAYLOAD_TRAIT); } @@ -340,6 +456,7 @@ public static final class Builder { private JsonNodeParser parser; private ProtocolUnmarshallDependencies protocolUnmarshallDependencies; + private boolean enableFastUnmarshalling = false; private Builder() { } @@ -374,6 +491,14 @@ public Builder protocolUnmarshallDependencies( return this; } + /** + * @param enableFastUnmarshalling Whether to enable the fast unmarshalling codepath. Default to {@code false}. + * @return This builder for method chaining. + */ + public Builder enableFastUnmarshalling(boolean enableFastUnmarshalling) { + this.enableFastUnmarshalling = enableFastUnmarshalling; + return this; + } /** * @return New instance of {@link JsonProtocolUnmarshaller}. diff --git a/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonUnmarshallingParser.java b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonUnmarshallingParser.java new file mode 100644 index 000000000000..780e50b0e4bf --- /dev/null +++ b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonUnmarshallingParser.java @@ -0,0 +1,540 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.protocols.json.internal.unmarshall; + +import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely; + +import java.io.IOException; +import java.io.InputStream; +import java.time.Instant; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import software.amazon.awssdk.annotations.SdkInternalApi; +import software.amazon.awssdk.annotations.ThreadSafe; +import software.amazon.awssdk.core.SdkBytes; +import software.amazon.awssdk.core.SdkField; +import software.amazon.awssdk.core.SdkPojo; +import software.amazon.awssdk.core.document.Document; +import software.amazon.awssdk.core.protocol.MarshallLocation; +import software.amazon.awssdk.core.protocol.MarshallingKnownType; +import software.amazon.awssdk.core.protocol.MarshallingType; +import software.amazon.awssdk.core.traits.ListTrait; +import software.amazon.awssdk.core.traits.MapTrait; +import software.amazon.awssdk.core.traits.TimestampFormatTrait; +import software.amazon.awssdk.core.traits.TraitType; +import software.amazon.awssdk.protocols.jsoncore.JsonNodeParser; +import software.amazon.awssdk.protocols.jsoncore.JsonValueNodeFactory; +import software.amazon.awssdk.thirdparty.jackson.core.JsonFactory; +import software.amazon.awssdk.thirdparty.jackson.core.JsonParseException; +import software.amazon.awssdk.thirdparty.jackson.core.JsonParser; +import software.amazon.awssdk.thirdparty.jackson.core.JsonToken; +import software.amazon.awssdk.utils.BinaryUtils; +import software.amazon.awssdk.utils.builder.Buildable; + +/** + * Parses and unmarshalls an JSON document. + */ +@SdkInternalApi +@ThreadSafe +@SuppressWarnings("unchecked") +final class JsonUnmarshallingParser { + private final JsonFactory jsonFactory; + private final JsonValueNodeFactory jsonValueNodeFactory; + private final JsonUnmarshallerRegistry unmarshallerRegistry; + private final TimestampFormatTrait.Format defaultFormat; + + private JsonUnmarshallingParser(Builder builder) { + this.jsonFactory = builder.jsonFactory; + this.jsonValueNodeFactory = builder.jsonValueNodeFactory; + this.unmarshallerRegistry = builder.unmarshallerRegistry; + this.defaultFormat = builder.defaultFormat; + } + + /** + * Create a parser using custom configuration. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Parse the provided {@link InputStream} and return the deserialized {@link SdkPojo}. + */ + public SdkPojo parse(SdkPojo pojo, InputStream content) { + return invokeSafely(() -> { + try (JsonParser parser = jsonFactory.createParser(content) + .configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false)) { + + JsonUnmarshallerContext c = JsonUnmarshallerContext.builder().build(); + JsonToken token = parser.nextToken(); + if (token == null) { + return (SdkPojo) ((Buildable) pojo).build(); + } + if (token == JsonToken.VALUE_NULL) { + return null; + } + if (token != JsonToken.START_OBJECT) { + throw new JsonParseException("expecting start object, got instead: " + token); + } + return parseSdkPojo(c, pojo, parser); + } + }); + } + + /** + * Parses an sdk pojo and fills its fields. The given SdkPojo instance is expected to be a {@link Buildable} instance. This + * method expects that the START_OBJECT token has been already consumed, so the next token should be either a field name or an + * END_OBJECT. + */ + private SdkPojo parseSdkPojo(JsonUnmarshallerContext c, SdkPojo pojo, JsonParser parser) throws IOException { + Map> pojoFields = pojo.sdkFieldNameToField(); + JsonToken currentToken = parser.nextToken(); + while (currentToken != JsonToken.END_OBJECT) { + String fieldName = parser.getText(); + SdkField pojoField = pojoFields.get(fieldName); + // if the name of the field is unknown or the field is expected in a non-payload location (e.g., header), we ignore + // its value here. + if (pojoField == null || !isPayloadUnmarshalling(pojoField.location())) { + skipValue(parser, null); + currentToken = parser.nextToken(); + continue; + } + currentToken = parser.nextToken(); + Object valueFor = valueFor(pojoField, c, pojoField.marshallingType(), parser, currentToken); + pojoField.set(pojo, valueFor); + currentToken = parser.nextToken(); + } + + return (SdkPojo) ((Buildable) pojo).build(); + } + + /** + * Returns true if the given location is considered as in the payload for unmarshalling. Those include + *
    + *
  • {@link MarshallLocation#PAYLOAD}
  • + *
  • {@link MarshallLocation#PATH}
  • + *
  • {@link MarshallLocation#QUERY_PARAM}
  • + *
  • {@link MarshallLocation#GREEDY_PATH}
  • + *
+ */ + private boolean isPayloadUnmarshalling(MarshallLocation location) { + switch (location) { + case PAYLOAD: + case PATH: + case QUERY_PARAM: + case GREEDY_PATH: + return true; + default: + return false; + } + } + + /** + * Parses a list of the field member field info. This method expects that the BEGIN_ARRAY token has been already consumed. + */ + private List parseList(JsonUnmarshallerContext c, SdkField field, JsonParser parser) throws IOException { + SdkField memberInfo = (SdkField) field.getTrait(ListTrait.class).memberFieldInfo(); + MarshallingType marshallingType = memberInfo.marshallingType(); + List result = new ArrayList<>(); + JsonToken currentToken = parser.nextToken(); + + // For lists of scalar types we use directly the unmarshaller here to reduce the work done, instead of calling the + // valueFor method. + + if (isScalarType(marshallingType)) { + MarshallingKnownType marshallingKnownType = marshallingType.getKnownType(); + while (currentToken != JsonToken.END_ARRAY) { + result.add(simpleValueFor(field, marshallingKnownType, c, parser, currentToken)); + currentToken = parser.nextToken(); + } + return result; + } + + + while (currentToken != JsonToken.END_ARRAY) { + result.add(valueFor(memberInfo, c, marshallingType, parser, currentToken)); + currentToken = parser.nextToken(); + } + return result; + } + + /** + * Parses a map of the field member value field info. This method expects that the BEGIN_OBJECT token has been already + * consumed. + */ + private Map parseMap(JsonUnmarshallerContext c, SdkField field, JsonParser parser) throws IOException { + Map result = new LinkedHashMap<>(); + SdkField valueInfo = field.getTrait(MapTrait.class, TraitType.MAP_TRAIT).valueFieldInfo(); + MarshallingType valueMarshallingType = valueInfo.marshallingType(); + + // For maps of string to scalar types we use directly the unmarshaller here to reduce the work done, instead of + // calling the valueFor method. + JsonToken currentToken = parser.nextToken(); + if (isScalarType(valueMarshallingType)) { + MarshallingKnownType valueMarshallingKnownType = valueMarshallingType.getKnownType(); + while (currentToken != JsonToken.END_OBJECT) { + String fieldName = parser.getText(); + currentToken = parser.nextToken(); + Object valueFor = simpleValueFor(field, valueMarshallingKnownType, c, parser, currentToken); + result.put(fieldName, valueFor); + currentToken = parser.nextToken(); + } + return result; + } + + while (currentToken != JsonToken.END_OBJECT) { + String fieldName = parser.getText(); + currentToken = parser.nextToken(); + Object valueFor = valueFor(valueInfo, c, valueMarshallingType, parser, currentToken); + result.put(fieldName, valueFor); + currentToken = parser.nextToken(); + } + return result; + } + + /** + * Parses and returns the value for the given field. This can be a scalar value (e.g., number, string, boolean), or a + * composite one (e.g., list, map, pojo). This method is expected to be called with a valid lookAhead token. + */ + @SuppressWarnings("unchecked") + private Object valueFor( + SdkField field, + JsonUnmarshallerContext context, + MarshallingType type, + JsonParser parser, + JsonToken lookAhead + ) throws IOException { + MarshallingKnownType marshallingKnownType = type.getKnownType(); + // We check first if we are unmarshalling a document, if so we + // delegate to a different method, this is needed since documents + // have their own class to represent null values: NullDocument. + if (marshallingKnownType == MarshallingKnownType.DOCUMENT) { + return parseDocumentValue(context, parser, lookAhead); + } + if (lookAhead == JsonToken.VALUE_NULL) { + if (marshallingKnownType == MarshallingKnownType.DOCUMENT) { + return Document.fromNull(); + } + return null; + } + switch (marshallingKnownType) { + case DOCUMENT: + return parseDocumentValue(context, parser, lookAhead); + case SDK_POJO: + expect(lookAhead, JsonToken.START_OBJECT); + return parseSdkPojo(context, field.constructor().get(), parser); + case LIST: + expect(lookAhead, JsonToken.START_ARRAY); + return parseList(context, field, parser); + case MAP: + expect(lookAhead, JsonToken.START_OBJECT); + return parseMap(context, field, parser); + case INSTANT: + return instantValueFor(field, parser, context, lookAhead); + default: + if (lookAhead == JsonToken.VALUE_STRING + && marshallingKnownType != MarshallingKnownType.STRING + && marshallingKnownType != MarshallingKnownType.SDK_BYTES + ) { + JsonUnmarshaller unmarshaller = unmarshallerRegistry.getUnmarshaller(MarshallLocation.PAYLOAD, type); + return unmarshaller.unmarshall(context, jsonValueNodeFactory.node(parser, lookAhead), + (SdkField) field); + } + return simpleValueFor(field, marshallingKnownType, context, parser, lookAhead); + } + } + + /** + * Returns a parsed simple value for the given SdkField. + */ + private Object simpleValueFor( + SdkField field, + MarshallingKnownType knownType, + JsonUnmarshallerContext context, + JsonParser parser, + JsonToken lookAhead + ) throws IOException { + if (lookAhead == JsonToken.VALUE_NULL) { + return null; + } + switch (knownType) { + case INTEGER: + expect(lookAhead, JsonToken.VALUE_NUMBER_INT); + return parser.getIntValue(); + case LONG: + expect(lookAhead, JsonToken.VALUE_NUMBER_INT); + return parser.getLongValue(); + case SHORT: + expect(lookAhead, JsonToken.VALUE_NUMBER_INT); + return parser.getShortValue(); + case BYTE: + expect(lookAhead, JsonToken.VALUE_NUMBER_INT); + return parser.getByteValue(); + case FLOAT: + expect(lookAhead, JsonToken.VALUE_NUMBER_INT, JsonToken.VALUE_NUMBER_FLOAT); + return parser.getFloatValue(); + case DOUBLE: + expect(lookAhead, JsonToken.VALUE_NUMBER_INT, JsonToken.VALUE_NUMBER_FLOAT); + return parser.getDoubleValue(); + case BIG_DECIMAL: + expect(lookAhead, JsonToken.VALUE_NUMBER_INT, JsonToken.VALUE_NUMBER_FLOAT); + return parser.getDecimalValue(); + case BOOLEAN: + expect(lookAhead, JsonToken.VALUE_FALSE, JsonToken.VALUE_TRUE); + return parser.getBooleanValue(); + case INSTANT: + return instantValueFor(field, parser, context, lookAhead); + case STRING: + // At least one protocol tests expects a floating number + // to be parsed as string, so we can't assert that: + // expect(lookAhead, JsonToken.VALUE_STRING); + return parser.getText(); + case SDK_BYTES: + if (lookAhead == JsonToken.VALUE_EMBEDDED_OBJECT) { + return SdkBytes.fromByteArray((byte[]) parser.getEmbeddedObject()); + } + expect(lookAhead, JsonToken.VALUE_STRING); + return SdkBytes.fromByteArray(BinaryUtils.fromBase64(parser.getText())); + default: + throw new JsonParseException("unexpected token, expecting token for: " + knownType + ", got: " + lookAhead); + } + } + + /** + * Consumes all the needed tokens that represent a single value, the value can be scalar or composite. If lookAhead is null a + * new token is consumed. + */ + private void skipValue(JsonParser parser, JsonToken lookAhead) throws IOException { + JsonToken current = lookAhead != null ? lookAhead : parser.nextToken(); + switch (current) { + case VALUE_STRING: + case VALUE_FALSE: + case VALUE_TRUE: + case VALUE_NULL: + case VALUE_NUMBER_FLOAT: + case VALUE_NUMBER_INT: + case VALUE_EMBEDDED_OBJECT: + return; + case START_OBJECT: + do { + // skip field name + current = parser.nextToken(); + if (current == JsonToken.END_OBJECT) { + break; + } + skipValue(parser, null); + } while (true); + return; + case START_ARRAY: + do { + current = parser.nextToken(); + if (current == JsonToken.END_ARRAY) { + break; + } + skipValue(parser, current); + } while (true); + return; + default: + throw new JsonParseException("unexpected JSON token - " + current); + } + } + + /** + * Validates that the lookAhead token is of the given type, throws a JsonParseException otherwise. + */ + private void expect(JsonToken lookAhead, JsonToken expected) throws IOException { + if (lookAhead != expected) { + throw new JsonParseException("unexpected token, expecting token: " + expected + ", got: " + lookAhead); + } + } + + /** + * Validates that the lookAhead token is of either of the given type, throws a JsonParseException otherwise. + */ + private void expect(JsonToken lookAhead, JsonToken expected0, JsonToken expected1) throws IOException { + if (lookAhead != expected0 && lookAhead != expected1) { + throw new JsonParseException("unexpected token, expecting token: " + + expected0 + ", or " + expected1 + ", got: " + lookAhead); + } + } + + /** + * Parses and returns an {@link Instant} value for a timestamp field. + */ + private Instant instantValueFor( + SdkField field, + JsonParser parser, + JsonUnmarshallerContext context, + JsonToken lookAhead + ) throws IOException { + TimestampFormatTrait.Format format = resolveTimestampFormat(field); + switch (format) { + case UNIX_TIMESTAMP: + return Instant.ofEpochMilli((long) (parser.getDoubleValue() * 1_000d)); + case UNIX_TIMESTAMP_MILLIS: + return Instant.ofEpochMilli(parser.getLongValue()); + default: + JsonUnmarshaller unmarshaller = unmarshallerRegistry.getUnmarshaller(MarshallLocation.PAYLOAD, + field.marshallingType()); + return (Instant) unmarshaller.unmarshall(context, jsonValueNodeFactory.node(parser, lookAhead), + (SdkField) field); + } + } + + /** + * Returns the timestamp format for the give field. + */ + private TimestampFormatTrait.Format resolveTimestampFormat(SdkField field) { + TimestampFormatTrait trait = field.getTrait(TimestampFormatTrait.class, TraitType.TIMESTAMP_FORMAT_TRAIT); + if (trait == null) { + return defaultFormat; + } else { + return trait.format(); + } + } + + /** + * Returns true if the marshallingType is composite, i.e., non-scalar. + */ + private boolean isCompositeType(MarshallingType marshallingType) { + return marshallingType == MarshallingType.LIST + || marshallingType == MarshallingType.MAP + || marshallingType == MarshallingType.SDK_POJO + || marshallingType == MarshallingType.DOCUMENT; + } + + /** + * Returns true if the marshallingType is scalar, i.e., non-composite. + */ + private boolean isScalarType(MarshallingType marshallingType) { + return !isCompositeType(marshallingType); + } + + /** + * Parses a {@link Document} value, either composite or scalar. + */ + private Document parseDocumentValue(JsonUnmarshallerContext c, JsonParser parser, JsonToken lookAhead) throws IOException { + JsonToken token = lookAhead != null ? lookAhead : parser.nextToken(); + switch (token) { + case VALUE_STRING: + return Document.fromString(parser.getText()); + case VALUE_NUMBER_FLOAT: + case VALUE_NUMBER_INT: + return Document.fromNumber(parser.getText()); + case VALUE_FALSE: + return Document.fromBoolean(false); + case VALUE_TRUE: + return Document.fromBoolean(true); + case VALUE_NULL: + return Document.fromNull(); + case START_ARRAY: + return parseDocumentList(c, parser); + case START_OBJECT: + return parseDocumentMap(c, parser); + default: + throw new JsonParseException("unexpected JSON token - " + token); + } + } + + /** + * Parses a document list. This method expects that the BEING_ARRAY token has been already consumed. + */ + private Document parseDocumentList(JsonUnmarshallerContext c, JsonParser parser) throws IOException { + Document.ListBuilder builder = Document.listBuilder(); + JsonToken currentToken = parser.nextToken(); + while (currentToken != JsonToken.END_ARRAY) { + builder.addDocument(parseDocumentValue(c, parser, currentToken)); + currentToken = parser.nextToken(); + } + return builder.build(); + } + + /** + * Parses a document map. This method expects that the BEING_OBJECT token has been already consumed. + */ + private Document parseDocumentMap(JsonUnmarshallerContext c, JsonParser parser) throws IOException { + Document.MapBuilder builder = Document.mapBuilder(); + JsonToken currentToken = parser.nextToken(); + while (currentToken != JsonToken.END_OBJECT) { + String key = parser.getText(); + Document value = parseDocumentValue(c, parser, null); + builder.putDocument(key, value); + currentToken = parser.nextToken(); + } + return builder.build(); + } + + /** + * A builder for configuring and creating {@link JsonUnmarshallingParser}. Created via {@link #builder()}. + */ + public static final class Builder { + private JsonFactory jsonFactory; + private JsonValueNodeFactory jsonValueNodeFactory = JsonValueNodeFactory.DEFAULT; + private JsonUnmarshallerRegistry unmarshallerRegistry; + private TimestampFormatTrait.Format defaultFormat; + + private Builder() { + } + + /** + * The {@link JsonFactory} implementation to be used when parsing the input. This allows JSON extensions like CBOR or Ion + * to be supported. + * + *

It's highly recommended us use a shared {@code JsonFactory} where possible, so they should be stored statically: + * http://wiki.fasterxml.com/JacksonBestPracticesPerformance + */ + public Builder jsonFactory(JsonFactory jsonFactory) { + this.jsonFactory = jsonFactory; + return this; + } + + /** + * Factory to create JsonNode out of JSON tokens. This allows JSON variants, such as CBOR, to produce actual values + * instead of having to parse them out of strings. + * + *

By default, this is {@link JsonValueNodeFactory#DEFAULT}. + */ + public Builder jsonValueNodeFactory(JsonValueNodeFactory jsonValueNodeFactory) { + this.jsonValueNodeFactory = jsonValueNodeFactory; + return this; + } + + /** + * Unmarshaller registry used to convert from JSON to Java values. + */ + public Builder unmarshallerRegistry(JsonUnmarshallerRegistry unmarshallerRegistry) { + this.unmarshallerRegistry = unmarshallerRegistry; + return this; + } + + /** + * Default timestamp format for payload location. + */ + public Builder defaultTimestampFormat(TimestampFormatTrait.Format defaultFormat) { + this.defaultFormat = defaultFormat; + return this; + } + + /** + * Build a {@link JsonNodeParser} based on the current configuration of this builder. + */ + public JsonUnmarshallingParser build() { + return new JsonUnmarshallingParser(this); + } + } +} diff --git a/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/SdkClientJsonProtocolAdvancedOption.java b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/SdkClientJsonProtocolAdvancedOption.java new file mode 100644 index 000000000000..0696bef13b05 --- /dev/null +++ b/core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/SdkClientJsonProtocolAdvancedOption.java @@ -0,0 +1,32 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.protocols.json.internal.unmarshall; + +import software.amazon.awssdk.annotations.SdkInternalApi; +import software.amazon.awssdk.core.client.config.ClientOption; + +@SdkInternalApi +public class SdkClientJsonProtocolAdvancedOption extends ClientOption { + /** + * Enables the fast unmarshall code path. This option is internal and subject to removal in future releases of the SDK. + */ + public static final SdkClientJsonProtocolAdvancedOption ENABLE_FAST_UNMARSHALLER = + new SdkClientJsonProtocolAdvancedOption<>(Boolean.class); + + protected SdkClientJsonProtocolAdvancedOption(Class valueClass) { + super(valueClass); + } +} diff --git a/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/ComplexStructure.java b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/ComplexStructure.java new file mode 100644 index 000000000000..f9fdd9e23a09 --- /dev/null +++ b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/ComplexStructure.java @@ -0,0 +1,787 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +package software.amazon.awssdk.protocols.json.internal.unmarshall; + +import java.io.Serializable; +import java.nio.ByteBuffer; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; +import software.amazon.awssdk.annotations.Generated; +import software.amazon.awssdk.core.SdkBytes; +import software.amazon.awssdk.core.SdkField; +import software.amazon.awssdk.core.SdkPojo; +import software.amazon.awssdk.core.protocol.MarshallLocation; +import software.amazon.awssdk.core.protocol.MarshallingType; +import software.amazon.awssdk.core.traits.ListTrait; +import software.amazon.awssdk.core.traits.LocationTrait; +import software.amazon.awssdk.core.traits.MapTrait; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap; +import software.amazon.awssdk.core.util.SdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructMap; +import software.amazon.awssdk.utils.ToString; +import software.amazon.awssdk.utils.builder.CopyableBuilder; +import software.amazon.awssdk.utils.builder.ToCopyableBuilder; + +/** + */ +@Generated("software.amazon.awssdk:codegen") +public final class ComplexStructure implements SdkPojo, Serializable, + ToCopyableBuilder { + private static final SdkField BOOLEAN_MEMBER_FIELD = SdkField. builder(MarshallingType.BOOLEAN) + .memberName("booleanMember").getter(getter(ComplexStructure::booleanMember)).setter(setter(Builder::booleanMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("booleanMember").build()).build(); + + private static final SdkField STRING_MEMBER_FIELD = SdkField. builder(MarshallingType.STRING) + .memberName("stringMember").getter(getter(ComplexStructure::stringMember)).setter(setter(Builder::stringMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stringMember").build()).build(); + + private static final SdkField INTEGER_MEMBER_FIELD = SdkField. builder(MarshallingType.INTEGER) + .memberName("integerMember").getter(getter(ComplexStructure::integerMember)).setter(setter(Builder::integerMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("integerMember").build()).build(); + + private static final SdkField LONG_MEMBER_FIELD = SdkField. builder(MarshallingType.LONG) + .memberName("longMember").getter(getter(ComplexStructure::longMember)).setter(setter(Builder::longMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("longMember").build()).build(); + + private static final SdkField FLOAT_MEMBER_FIELD = SdkField. builder(MarshallingType.FLOAT) + .memberName("floatMember").getter(getter(ComplexStructure::floatMember)).setter(setter(Builder::floatMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("floatMember").build()).build(); + + private static final SdkField DOUBLE_MEMBER_FIELD = SdkField. builder(MarshallingType.DOUBLE) + .memberName("doubleMember").getter(getter(ComplexStructure::doubleMember)).setter(setter(Builder::doubleMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("doubleMember").build()).build(); + + private static final SdkField TIMESTAMP_MEMBER_FIELD = SdkField. builder(MarshallingType.INSTANT) + .memberName("timestampMember").getter(getter(ComplexStructure::timestampMember)) + .setter(setter(Builder::timestampMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("timestampMember").build()).build(); + + private static final SdkField BLOB_MEMBER_FIELD = SdkField. builder(MarshallingType.SDK_BYTES) + .memberName("blobMember").getter(getter(ComplexStructure::blobMember)).setter(setter(Builder::blobMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("blobMember").build()).build(); + + private static final SdkField> LIST_OF_STRINGS_MEMBER_FIELD = SdkField + .> builder(MarshallingType.LIST) + .memberName("listOfStringsMember") + .getter(getter(ComplexStructure::listOfStringsMember)) + .setter(setter(Builder::listOfStringsMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("listOfStringsMember").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); + + private static final SdkField> MAP_OF_STRING_TO_STRING_MEMBER_FIELD = SdkField + .> builder(MarshallingType.MAP) + .memberName("mapOfStringToStringMember") + .getter(getter(ComplexStructure::mapOfStringToStringMember)) + .setter(setter(Builder::mapOfStringToStringMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("mapOfStringToStringMember").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); + + private static final SdkField COMPLEX_STRUCT_MEMBER_FIELD = SdkField + . builder(MarshallingType.SDK_POJO).memberName("complexStructMember") + .getter(getter(ComplexStructure::complexStructMember)).setter(setter(Builder::complexStructMember)) + .constructor(ComplexStructure::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("complexStructMember").build()) + .build(); + + private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BOOLEAN_MEMBER_FIELD, + STRING_MEMBER_FIELD, INTEGER_MEMBER_FIELD, LONG_MEMBER_FIELD, FLOAT_MEMBER_FIELD, DOUBLE_MEMBER_FIELD, + TIMESTAMP_MEMBER_FIELD, BLOB_MEMBER_FIELD, LIST_OF_STRINGS_MEMBER_FIELD, MAP_OF_STRING_TO_STRING_MEMBER_FIELD, + COMPLEX_STRUCT_MEMBER_FIELD)); + + private static final Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("booleanMember", BOOLEAN_MEMBER_FIELD); + put("stringMember", STRING_MEMBER_FIELD); + put("integerMember", INTEGER_MEMBER_FIELD); + put("longMember", LONG_MEMBER_FIELD); + put("floatMember", FLOAT_MEMBER_FIELD); + put("doubleMember", DOUBLE_MEMBER_FIELD); + put("timestampMember", TIMESTAMP_MEMBER_FIELD); + put("blobMember", BLOB_MEMBER_FIELD); + put("listOfStringsMember", LIST_OF_STRINGS_MEMBER_FIELD); + put("mapOfStringToStringMember", MAP_OF_STRING_TO_STRING_MEMBER_FIELD); + put("complexStructMember", COMPLEX_STRUCT_MEMBER_FIELD); + } + }); + + private static final long serialVersionUID = 1L; + + private final Boolean booleanMember; + + private final String stringMember; + + private final Integer integerMember; + + private final Long longMember; + + private final Float floatMember; + + private final Double doubleMember; + + private final Instant timestampMember; + + private final SdkBytes blobMember; + + private final List listOfStringsMember; + + private final Map mapOfStringToStringMember; + + private final ComplexStructure complexStructMember; + + private ComplexStructure(BuilderImpl builder) { + this.booleanMember = builder.booleanMember; + this.stringMember = builder.stringMember; + this.integerMember = builder.integerMember; + this.longMember = builder.longMember; + this.floatMember = builder.floatMember; + this.doubleMember = builder.doubleMember; + this.timestampMember = builder.timestampMember; + this.blobMember = builder.blobMember; + this.listOfStringsMember = builder.listOfStringsMember; + this.mapOfStringToStringMember = builder.mapOfStringToStringMember; + this.complexStructMember = builder.complexStructMember; + } + + /** + * Returns the value of the BooleanMember property for this object. + * + * @return The value of the BooleanMember property for this object. + */ + public final Boolean booleanMember() { + return booleanMember; + } + + /** + * Returns the value of the StringMember property for this object. + * + * @return The value of the StringMember property for this object. + */ + public final String stringMember() { + return stringMember; + } + + /** + * Returns the value of the IntegerMember property for this object. + * + * @return The value of the IntegerMember property for this object. + */ + public final Integer integerMember() { + return integerMember; + } + + /** + * Returns the value of the LongMember property for this object. + * + * @return The value of the LongMember property for this object. + */ + public final Long longMember() { + return longMember; + } + + /** + * Returns the value of the FloatMember property for this object. + * + * @return The value of the FloatMember property for this object. + */ + public final Float floatMember() { + return floatMember; + } + + /** + * Returns the value of the DoubleMember property for this object. + * + * @return The value of the DoubleMember property for this object. + */ + public final Double doubleMember() { + return doubleMember; + } + + /** + * Returns the value of the TimestampMember property for this object. + * + * @return The value of the TimestampMember property for this object. + */ + public final Instant timestampMember() { + return timestampMember; + } + + /** + * Returns the value of the BlobMember property for this object. + * + * @return The value of the BlobMember property for this object. + */ + public final SdkBytes blobMember() { + return blobMember; + } + + /** + * For responses, this returns true if the service returned a value for the ListOfStringsMember property. This DOES + * NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). + * This is useful because the SDK will never return a null collection or map, but you may need to differentiate + * between the service returning nothing (or null) and the service returning an empty collection or map. For + * requests, this returns true if a value for the property was specified in the request builder, and false if a + * value was not specified. + */ + public final boolean hasListOfStringsMember() { + return listOfStringsMember != null && !(listOfStringsMember instanceof SdkAutoConstructList); + } + + /** + * Returns the value of the ListOfStringsMember property for this object. + *

+ * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. + *

+ *

+ * This method will never return null. If you would like to know whether the service returned this field (so that + * you can differentiate between null and empty), you can use the {@link #hasListOfStringsMember} method. + *

+ * + * @return The value of the ListOfStringsMember property for this object. + */ + public final List listOfStringsMember() { + return listOfStringsMember; + } + + /** + * For responses, this returns true if the service returned a value for the MapOfStringToStringMember property. This + * DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the + * property). This is useful because the SDK will never return a null collection or map, but you may need to + * differentiate between the service returning nothing (or null) and the service returning an empty collection or + * map. For requests, this returns true if a value for the property was specified in the request builder, and false + * if a value was not specified. + */ + public final boolean hasMapOfStringToStringMember() { + return mapOfStringToStringMember != null && !(mapOfStringToStringMember instanceof SdkAutoConstructMap); + } + + /** + * Returns the value of the MapOfStringToStringMember property for this object. + *

+ * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. + *

+ *

+ * This method will never return null. If you would like to know whether the service returned this field (so that + * you can differentiate between null and empty), you can use the {@link #hasMapOfStringToStringMember} method. + *

+ * + * @return The value of the MapOfStringToStringMember property for this object. + */ + public final Map mapOfStringToStringMember() { + return mapOfStringToStringMember; + } + + /** + * Returns the value of the ComplexStructMember property for this object. + * + * @return The value of the ComplexStructMember property for this object. + */ + public final ComplexStructure complexStructMember() { + return complexStructMember; + } + + @Override + public Builder toBuilder() { + return new BuilderImpl(this); + } + + public static Builder builder() { + return new BuilderImpl(); + } + + public static Class serializableBuilderClass() { + return BuilderImpl.class; + } + + @Override + public final int hashCode() { + int hashCode = 1; + hashCode = 31 * hashCode + Objects.hashCode(booleanMember()); + hashCode = 31 * hashCode + Objects.hashCode(stringMember()); + hashCode = 31 * hashCode + Objects.hashCode(integerMember()); + hashCode = 31 * hashCode + Objects.hashCode(longMember()); + hashCode = 31 * hashCode + Objects.hashCode(floatMember()); + hashCode = 31 * hashCode + Objects.hashCode(doubleMember()); + hashCode = 31 * hashCode + Objects.hashCode(timestampMember()); + hashCode = 31 * hashCode + Objects.hashCode(blobMember()); + hashCode = 31 * hashCode + Objects.hashCode(hasListOfStringsMember() ? listOfStringsMember() : null); + hashCode = 31 * hashCode + Objects.hashCode(hasMapOfStringToStringMember() ? mapOfStringToStringMember() : null); + hashCode = 31 * hashCode + Objects.hashCode(complexStructMember()); + return hashCode; + } + + @Override + public final boolean equals(Object obj) { + return equalsBySdkFields(obj); + } + + @Override + public final boolean equalsBySdkFields(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof ComplexStructure)) { + return false; + } + ComplexStructure other = (ComplexStructure) obj; + return Objects.equals(booleanMember(), other.booleanMember()) && Objects.equals(stringMember(), other.stringMember()) + && Objects.equals(integerMember(), other.integerMember()) && Objects.equals(longMember(), other.longMember()) + && Objects.equals(floatMember(), other.floatMember()) && Objects.equals(doubleMember(), other.doubleMember()) + && Objects.equals(timestampMember(), other.timestampMember()) && Objects.equals(blobMember(), other.blobMember()) + && hasListOfStringsMember() == other.hasListOfStringsMember() + && Objects.equals(listOfStringsMember(), other.listOfStringsMember()) + && hasMapOfStringToStringMember() == other.hasMapOfStringToStringMember() + && Objects.equals(mapOfStringToStringMember(), other.mapOfStringToStringMember()) + && Objects.equals(complexStructMember(), other.complexStructMember()); + } + + /** + * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be + * redacted from this string using a placeholder value. + */ + @Override + public final String toString() { + return ToString.builder("ComplexStructure").add("BooleanMember", booleanMember()).add("StringMember", stringMember()) + .add("IntegerMember", integerMember()).add("LongMember", longMember()).add("FloatMember", floatMember()) + .add("DoubleMember", doubleMember()).add("TimestampMember", timestampMember()).add("BlobMember", blobMember()) + .add("ListOfStringsMember", hasListOfStringsMember() ? listOfStringsMember() : null) + .add("MapOfStringToStringMember", hasMapOfStringToStringMember() ? mapOfStringToStringMember() : null) + .add("ComplexStructMember", complexStructMember()).build(); + } + + public final Optional getValueForField(String fieldName, Class clazz) { + switch (fieldName) { + case "booleanMember": + return Optional.ofNullable(clazz.cast(booleanMember())); + case "stringMember": + return Optional.ofNullable(clazz.cast(stringMember())); + case "integerMember": + return Optional.ofNullable(clazz.cast(integerMember())); + case "longMember": + return Optional.ofNullable(clazz.cast(longMember())); + case "floatMember": + return Optional.ofNullable(clazz.cast(floatMember())); + case "doubleMember": + return Optional.ofNullable(clazz.cast(doubleMember())); + case "timestampMember": + return Optional.ofNullable(clazz.cast(timestampMember())); + case "blobMember": + return Optional.ofNullable(clazz.cast(blobMember())); + case "listOfStringsMember": + return Optional.ofNullable(clazz.cast(listOfStringsMember())); + case "mapOfStringToStringMember": + return Optional.ofNullable(clazz.cast(mapOfStringToStringMember())); + case "complexStructMember": + return Optional.ofNullable(clazz.cast(complexStructMember())); + default: + return Optional.empty(); + } + } + + @Override + public final List> sdkFields() { + return SDK_FIELDS; + } + + @Override + public final Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + + private static Function getter(Function g) { + return obj -> g.apply((ComplexStructure) obj); + } + + private static BiConsumer setter(BiConsumer s) { + return (obj, val) -> s.accept((Builder) obj, val); + } + + public interface Builder extends SdkPojo, CopyableBuilder { + /** + * Sets the value of the BooleanMember property for this object. + * + * @param booleanMember + * The new value for the BooleanMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder booleanMember(Boolean booleanMember); + + /** + * Sets the value of the StringMember property for this object. + * + * @param stringMember + * The new value for the StringMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder stringMember(String stringMember); + + /** + * Sets the value of the IntegerMember property for this object. + * + * @param integerMember + * The new value for the IntegerMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder integerMember(Integer integerMember); + + /** + * Sets the value of the LongMember property for this object. + * + * @param longMember + * The new value for the LongMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder longMember(Long longMember); + + /** + * Sets the value of the FloatMember property for this object. + * + * @param floatMember + * The new value for the FloatMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder floatMember(Float floatMember); + + /** + * Sets the value of the DoubleMember property for this object. + * + * @param doubleMember + * The new value for the DoubleMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder doubleMember(Double doubleMember); + + /** + * Sets the value of the TimestampMember property for this object. + * + * @param timestampMember + * The new value for the TimestampMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder timestampMember(Instant timestampMember); + + /** + * Sets the value of the BlobMember property for this object. + * + * @param blobMember + * The new value for the BlobMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder blobMember(SdkBytes blobMember); + + /** + * Sets the value of the ListOfStringsMember property for this object. + * + * @param listOfStringsMember + * The new value for the ListOfStringsMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfStringsMember(Collection listOfStringsMember); + + /** + * Sets the value of the ListOfStringsMember property for this object. + * + * @param listOfStringsMember + * The new value for the ListOfStringsMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfStringsMember(String... listOfStringsMember); + + /** + * Sets the value of the MapOfStringToStringMember property for this object. + * + * @param mapOfStringToStringMember + * The new value for the MapOfStringToStringMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToStringMember(Map mapOfStringToStringMember); + + /** + * Sets the value of the ComplexStructMember property for this object. + * + * @param complexStructMember + * The new value for the ComplexStructMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder complexStructMember(ComplexStructure complexStructMember); + + /** + * Sets the value of the ComplexStructMember property for this object. + * + * This is a convenience method that creates an instance of the {@link ComplexStructure.Builder} avoiding the + * need to create one manually via {@link ComplexStructure#builder()}. + * + *

+ * When the {@link Consumer} completes, {@link ComplexStructure.Builder#build()} is called immediately and its + * result is passed to {@link #complexStructMember(ComplexStructure)}. + * + * @param complexStructMember + * a consumer that will call methods on {@link ComplexStructure.Builder} + * @return Returns a reference to this object so that method calls can be chained together. + * @see #complexStructMember(ComplexStructure) + */ + default Builder complexStructMember(Consumer complexStructMember) { + return complexStructMember(ComplexStructure.builder().applyMutation(complexStructMember).build()); + } + } + + static final class BuilderImpl implements Builder { + private Boolean booleanMember; + + private String stringMember; + + private Integer integerMember; + + private Long longMember; + + private Float floatMember; + + private Double doubleMember; + + private Instant timestampMember; + + private SdkBytes blobMember; + + private List listOfStringsMember = DefaultSdkAutoConstructList.getInstance(); + + private Map mapOfStringToStringMember = DefaultSdkAutoConstructMap.getInstance(); + + private ComplexStructure complexStructMember; + + private BuilderImpl() { + } + + private BuilderImpl(ComplexStructure model) { + booleanMember(model.booleanMember); + stringMember(model.stringMember); + integerMember(model.integerMember); + longMember(model.longMember); + floatMember(model.floatMember); + doubleMember(model.doubleMember); + timestampMember(model.timestampMember); + blobMember(model.blobMember); + listOfStringsMember(model.listOfStringsMember); + mapOfStringToStringMember(model.mapOfStringToStringMember); + complexStructMember(model.complexStructMember); + } + + public final Boolean getBooleanMember() { + return booleanMember; + } + + public final void setBooleanMember(Boolean booleanMember) { + this.booleanMember = booleanMember; + } + + @Override + public final Builder booleanMember(Boolean booleanMember) { + this.booleanMember = booleanMember; + return this; + } + + public final String getStringMember() { + return stringMember; + } + + public final void setStringMember(String stringMember) { + this.stringMember = stringMember; + } + + @Override + public final Builder stringMember(String stringMember) { + this.stringMember = stringMember; + return this; + } + + public final Integer getIntegerMember() { + return integerMember; + } + + public final void setIntegerMember(Integer integerMember) { + this.integerMember = integerMember; + } + + @Override + public final Builder integerMember(Integer integerMember) { + this.integerMember = integerMember; + return this; + } + + public final Long getLongMember() { + return longMember; + } + + public final void setLongMember(Long longMember) { + this.longMember = longMember; + } + + @Override + public final Builder longMember(Long longMember) { + this.longMember = longMember; + return this; + } + + public final Float getFloatMember() { + return floatMember; + } + + public final void setFloatMember(Float floatMember) { + this.floatMember = floatMember; + } + + @Override + public final Builder floatMember(Float floatMember) { + this.floatMember = floatMember; + return this; + } + + public final Double getDoubleMember() { + return doubleMember; + } + + public final void setDoubleMember(Double doubleMember) { + this.doubleMember = doubleMember; + } + + @Override + public final Builder doubleMember(Double doubleMember) { + this.doubleMember = doubleMember; + return this; + } + + public final Instant getTimestampMember() { + return timestampMember; + } + + public final void setTimestampMember(Instant timestampMember) { + this.timestampMember = timestampMember; + } + + @Override + public final Builder timestampMember(Instant timestampMember) { + this.timestampMember = timestampMember; + return this; + } + + public final ByteBuffer getBlobMember() { + return blobMember == null ? null : blobMember.asByteBuffer(); + } + + public final void setBlobMember(ByteBuffer blobMember) { + blobMember(blobMember == null ? null : SdkBytes.fromByteBuffer(blobMember)); + } + + @Override + public final Builder blobMember(SdkBytes blobMember) { + this.blobMember = blobMember; + return this; + } + + public final Collection getListOfStringsMember() { + if (listOfStringsMember instanceof SdkAutoConstructList) { + return null; + } + return listOfStringsMember; + } + + public final void setListOfStringsMember(Collection listOfStringsMember) { + this.listOfStringsMember = ListOfStringsCopier.copy(listOfStringsMember); + } + + @Override + public final Builder listOfStringsMember(Collection listOfStringsMember) { + this.listOfStringsMember = ListOfStringsCopier.copy(listOfStringsMember); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfStringsMember(String... listOfStringsMember) { + listOfStringsMember(Arrays.asList(listOfStringsMember)); + return this; + } + + public final Map getMapOfStringToStringMember() { + if (mapOfStringToStringMember instanceof SdkAutoConstructMap) { + return null; + } + return mapOfStringToStringMember; + } + + public final void setMapOfStringToStringMember(Map mapOfStringToStringMember) { + this.mapOfStringToStringMember = MapOfStringToStringCopier.copy(mapOfStringToStringMember); + } + + @Override + public final Builder mapOfStringToStringMember(Map mapOfStringToStringMember) { + this.mapOfStringToStringMember = MapOfStringToStringCopier.copy(mapOfStringToStringMember); + return this; + } + + public final Builder getComplexStructMember() { + return complexStructMember != null ? complexStructMember.toBuilder() : null; + } + + public final void setComplexStructMember(BuilderImpl complexStructMember) { + this.complexStructMember = complexStructMember != null ? complexStructMember.build() : null; + } + + @Override + public final Builder complexStructMember(ComplexStructure complexStructMember) { + this.complexStructMember = complexStructMember; + return this; + } + + @Override + public ComplexStructure build() { + return new ComplexStructure(this); + } + + @Override + public List> sdkFields() { + return SDK_FIELDS; + } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + } +} diff --git a/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonUnmarshallingParserTest.java b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonUnmarshallingParserTest.java new file mode 100644 index 000000000000..ad65f00634b9 --- /dev/null +++ b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonUnmarshallingParserTest.java @@ -0,0 +1,119 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.protocols.json.internal.unmarshall; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Test; +import software.amazon.awssdk.core.document.Document; +import software.amazon.awssdk.core.protocol.MarshallLocation; +import software.amazon.awssdk.thirdparty.jackson.core.JsonParseException; + +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class JsonUnmarshallingParserTest { + + @Test + public void parsingPojoFieldThrowsOnNumberFoundInstead() { + JsonUnmarshallingParser parser = parser(); + UncheckedIOException e = assertThrows(UncheckedIOException.class, () -> { + parser.parse(TestRequest.builder(), from("{\"complexStructMember\": 123}")); + }); + assertNotNull(e.getCause()); + assertInstanceOf(JsonParseException.class, e.getCause()); + } + + @Test + public void parsingAMapFieldThrowsOnNumberFoundInstead() { + JsonUnmarshallingParser parser = parser(); + UncheckedIOException e = assertThrows(UncheckedIOException.class, () -> { + parser.parse(TestRequest.builder(), from("{\"mapOfStringToStringMember\": 123}")); + }); + assertNotNull(e.getCause()); + assertInstanceOf(JsonParseException.class, e.getCause()); + } + + @Test + public void parsingAListFieldThrowsOnNumberFoundInstead() { + JsonUnmarshallingParser parser = parser(); + UncheckedIOException e = assertThrows(UncheckedIOException.class, () -> { + parser.parse(TestRequest.builder(), from("{\"listOfStringsMember\": 123}")); + }); + assertNotNull(e.getCause()); + assertInstanceOf(JsonParseException.class, e.getCause()); + } + + @Test + public void parseOnJsonUnexpectedNonObjectStartThrows() { + // The input is a SdkPojo, it has to start with {, for any other + // valid JSON value the parser should throw. + JsonUnmarshallingParser parser = parser(); + UncheckedIOException e = assertThrows(UncheckedIOException.class, () -> { + parser.parse(TestRequest.builder(), from("123.456")); + }); + assertNotNull(e.getCause()); + assertInstanceOf(JsonParseException.class, e.getCause()); + } + + @Test + public void parseOnEmptyInputReturnsAValidPojo() { + JsonUnmarshallingParser parser = parser(); + TestRequest req = (TestRequest) parser.parse(TestRequest.builder(), from("")); + assertNotNull(req); + } + + @Test + public void parseOnJsonNullLiteralReturnsNull() { + JsonUnmarshallingParser parser = parser(); + TestRequest req = (TestRequest) parser.parse(TestRequest.builder(), from("null")); + assertNull(req); + } + + @Test + public void parsingDocumentFieldWithBooleanValue() { + JsonUnmarshallingParser parser = parser(); + TestRequest req = (TestRequest) parser.parse(TestRequest.builder(), from("{\"documentMember\": true}")); + assertNotNull(req); + Document doc = req.documentField(); + assertNotNull(doc); + assertTrue(doc.isBoolean()); + assertTrue(doc.asBoolean()); + } + + static JsonUnmarshallingParser parser() { + ProtocolUnmarshallDependencies dependencies = JsonProtocolUnmarshaller.defaultProtocolUnmarshallDependencies(); + JsonUnmarshallingParser parser = JsonUnmarshallingParser + .builder() + .jsonFactory(dependencies.jsonFactory()) + .unmarshallerRegistry(dependencies.jsonUnmarshallerRegistry()) + .defaultTimestampFormat(dependencies.timestampFormats() + .get(MarshallLocation.PAYLOAD)) + .build(); + return parser; + } + + static InputStream from(String source) { + return new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8)); + } + + +} \ No newline at end of file diff --git a/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/ListOfStringsCopier.java b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/ListOfStringsCopier.java new file mode 100644 index 000000000000..d120cbc7f0b2 --- /dev/null +++ b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/ListOfStringsCopier.java @@ -0,0 +1,36 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +package software.amazon.awssdk.protocols.json.internal.unmarshall; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import software.amazon.awssdk.annotations.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; + +@Generated("software.amazon.awssdk:codegen") +final class ListOfStringsCopier { + static List copy(Collection listOfStringsParam) { + List list; + if (listOfStringsParam == null || listOfStringsParam instanceof SdkAutoConstructList) { + list = DefaultSdkAutoConstructList.getInstance(); + } else { + List modifiableList = new ArrayList<>(listOfStringsParam); + list = Collections.unmodifiableList(modifiableList); + } + return list; + } +} diff --git a/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/MapOfStringToStringCopier.java b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/MapOfStringToStringCopier.java new file mode 100644 index 000000000000..2ec722a29b6c --- /dev/null +++ b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/MapOfStringToStringCopier.java @@ -0,0 +1,38 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +package software.amazon.awssdk.protocols.json.internal.unmarshall; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import software.amazon.awssdk.annotations.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap; +import software.amazon.awssdk.core.util.SdkAutoConstructMap; + +@Generated("software.amazon.awssdk:codegen") +final class MapOfStringToStringCopier { + static Map copy(Map mapOfStringToStringParam) { + Map map; + if (mapOfStringToStringParam == null || mapOfStringToStringParam instanceof SdkAutoConstructMap) { + map = DefaultSdkAutoConstructMap.getInstance(); + } else { + Map modifiableMap = new LinkedHashMap<>(mapOfStringToStringParam.size()); + mapOfStringToStringParam.forEach((key, value) -> { + modifiableMap.put(key, value); + }); + map = Collections.unmodifiableMap(modifiableMap); + } + return map; + } +} diff --git a/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/TestRequest.java b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/TestRequest.java new file mode 100644 index 000000000000..7b6c653ac9e1 --- /dev/null +++ b/core/protocols/aws-json-protocol/src/test/java/software/amazon/awssdk/protocols/json/internal/unmarshall/TestRequest.java @@ -0,0 +1,822 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +package software.amazon.awssdk.protocols.json.internal.unmarshall; + +import java.nio.ByteBuffer; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; +import software.amazon.awssdk.annotations.Generated; +import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; +import software.amazon.awssdk.core.SdkBytes; +import software.amazon.awssdk.core.SdkField; +import software.amazon.awssdk.core.SdkPojo; +import software.amazon.awssdk.core.document.Document; +import software.amazon.awssdk.core.protocol.MarshallLocation; +import software.amazon.awssdk.core.protocol.MarshallingType; +import software.amazon.awssdk.core.traits.ListTrait; +import software.amazon.awssdk.core.traits.LocationTrait; +import software.amazon.awssdk.core.traits.MapTrait; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap; +import software.amazon.awssdk.core.util.SdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructMap; +import software.amazon.awssdk.utils.ToString; +import software.amazon.awssdk.utils.builder.CopyableBuilder; +import software.amazon.awssdk.utils.builder.ToCopyableBuilder; + +/** + */ +@Generated("software.amazon.awssdk:codegen") +public class TestRequest implements SdkPojo, + ToCopyableBuilder { + private static SdkField BOOLEAN_MEMBER_FIELD = SdkField. builder(MarshallingType.BOOLEAN) + .memberName("booleanMember").getter(getter(TestRequest::booleanMember)) + .setter(setter(Builder::booleanMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("booleanMember").build()).build(); + + private static SdkField STRING_MEMBER_FIELD = SdkField. builder(MarshallingType.STRING) + .memberName("stringMember").getter(getter(TestRequest::stringMember)).setter(setter(Builder::stringMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stringMember").build()).build(); + + private static SdkField INTEGER_MEMBER_FIELD = SdkField. builder(MarshallingType.INTEGER) + .memberName("integerMember").getter(getter(TestRequest::integerMember)) + .setter(setter(Builder::integerMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("integerMember").build()).build(); + + private static SdkField LONG_MEMBER_FIELD = SdkField. builder(MarshallingType.LONG) + .memberName("longMember").getter(getter(TestRequest::longMember)).setter(setter(Builder::longMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("longMember").build()).build(); + + private static SdkField FLOAT_MEMBER_FIELD = SdkField. builder(MarshallingType.FLOAT) + .memberName("floatMember").getter(getter(TestRequest::floatMember)).setter(setter(Builder::floatMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("floatMember").build()).build(); + + private static SdkField DOUBLE_MEMBER_FIELD = SdkField. builder(MarshallingType.DOUBLE) + .memberName("doubleMember").getter(getter(TestRequest::doubleMember)).setter(setter(Builder::doubleMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("doubleMember").build()).build(); + + private static SdkField TIMESTAMP_MEMBER_FIELD = SdkField. builder(MarshallingType.INSTANT) + .memberName("timestampMember").getter(getter(TestRequest::timestampMember)) + .setter(setter(Builder::timestampMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("timestampMember").build()).build(); + + private static SdkField BLOB_MEMBER_FIELD = SdkField. builder(MarshallingType.SDK_BYTES) + .memberName("blobMember").getter(getter(TestRequest::blobMember)).setter(setter(Builder::blobMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("blobMember").build()).build(); + + private static SdkField> LIST_OF_STRINGS_MEMBER_FIELD = SdkField + .> builder(MarshallingType.LIST) + .memberName("listOfStringsMember") + .getter(getter(TestRequest::listOfStringsMember)) + .setter(setter(Builder::listOfStringsMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("listOfStringsMember").build(), + ListTrait + .builder() + .memberLocationName(null) + .memberFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("member").build()).build()).build()).build(); + + private static SdkField> MAP_OF_STRING_TO_STRING_MEMBER_FIELD = SdkField + .> builder(MarshallingType.MAP) + .memberName("mapOfStringToStringMember") + .getter(getter(TestRequest::mapOfStringToStringMember)) + .setter(setter(Builder::mapOfStringToStringMember)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("mapOfStringToStringMember").build(), + MapTrait.builder() + .keyLocationName("key") + .valueLocationName("value") + .valueFieldInfo( + SdkField. builder(MarshallingType.STRING) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) + .locationName("value").build()).build()).build()).build(); + + private static SdkField COMPLEX_STRUCT_MEMBER_FIELD = SdkField + . builder(MarshallingType.SDK_POJO).memberName("complexStructMember") + .getter(getter(TestRequest::complexStructMember)).setter(setter(Builder::complexStructMember)) + .constructor(ComplexStructure::builder) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("complexStructMember").build()) + .build(); + + private static final SdkField DOCUMENT_MEMBER_FIELD = SdkField + .builder(MarshallingType.DOCUMENT) + .memberName("documentMember").getter(getter(TestRequest::documentField)).setter(setter(Builder::documentField)) + .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("documentMember").build()).build(); + + private static List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BOOLEAN_MEMBER_FIELD, + STRING_MEMBER_FIELD, INTEGER_MEMBER_FIELD, LONG_MEMBER_FIELD, FLOAT_MEMBER_FIELD, DOUBLE_MEMBER_FIELD, + TIMESTAMP_MEMBER_FIELD, BLOB_MEMBER_FIELD, LIST_OF_STRINGS_MEMBER_FIELD, MAP_OF_STRING_TO_STRING_MEMBER_FIELD, + COMPLEX_STRUCT_MEMBER_FIELD, DOCUMENT_MEMBER_FIELD)); + + private static Map> SDK_NAME_TO_FIELD = Collections + .unmodifiableMap(new HashMap>() { + { + put("booleanMember", BOOLEAN_MEMBER_FIELD); + put("stringMember", STRING_MEMBER_FIELD); + put("integerMember", INTEGER_MEMBER_FIELD); + put("longMember", LONG_MEMBER_FIELD); + put("floatMember", FLOAT_MEMBER_FIELD); + put("doubleMember", DOUBLE_MEMBER_FIELD); + put("timestampMember", TIMESTAMP_MEMBER_FIELD); + put("blobMember", BLOB_MEMBER_FIELD); + put("listOfStringsMember", LIST_OF_STRINGS_MEMBER_FIELD); + put("mapOfStringToStringMember", MAP_OF_STRING_TO_STRING_MEMBER_FIELD); + put("complexStructMember", COMPLEX_STRUCT_MEMBER_FIELD); + put("documentMember", DOCUMENT_MEMBER_FIELD); + } + }); + + private final Boolean booleanMember; + + private final String stringMember; + + private final Integer integerMember; + + private final Long longMember; + + private final Float floatMember; + + private final Double doubleMember; + + private final Instant timestampMember; + + private final SdkBytes blobMember; + + private final List listOfStringsMember; + + private final Map mapOfStringToStringMember; + + private final ComplexStructure complexStructMember; + private final Document documentField; + + private TestRequest(BuilderImpl builder) { + this.booleanMember = builder.booleanMember; + this.stringMember = builder.stringMember; + this.integerMember = builder.integerMember; + this.longMember = builder.longMember; + this.floatMember = builder.floatMember; + this.doubleMember = builder.doubleMember; + this.timestampMember = builder.timestampMember; + this.blobMember = builder.blobMember; + this.listOfStringsMember = builder.listOfStringsMember; + this.mapOfStringToStringMember = builder.mapOfStringToStringMember; + this.complexStructMember = builder.complexStructMember; + this.documentField = builder.documentField; + } + + /** + * Returns the value of the BooleanMember property for this object. + * + * @return The value of the BooleanMember property for this object. + */ + public Boolean booleanMember() { + return booleanMember; + } + + /** + * Returns the value of the StringMember property for this object. + * + * @return The value of the StringMember property for this object. + */ + public String stringMember() { + return stringMember; + } + + /** + * Returns the value of the IntegerMember property for this object. + * + * @return The value of the IntegerMember property for this object. + */ + public Integer integerMember() { + return integerMember; + } + + /** + * Returns the value of the LongMember property for this object. + * + * @return The value of the LongMember property for this object. + */ + public Long longMember() { + return longMember; + } + + /** + * Returns the value of the FloatMember property for this object. + * + * @return The value of the FloatMember property for this object. + */ + public Float floatMember() { + return floatMember; + } + + /** + * Returns the value of the DoubleMember property for this object. + * + * @return The value of the DoubleMember property for this object. + */ + public Double doubleMember() { + return doubleMember; + } + + /** + * Returns the value of the TimestampMember property for this object. + * + * @return The value of the TimestampMember property for this object. + */ + public Instant timestampMember() { + return timestampMember; + } + + /** + * Returns the value of the BlobMember property for this object. + * + * @return The value of the BlobMember property for this object. + */ + public SdkBytes blobMember() { + return blobMember; + } + + /** + * For responses, this returns true if the service returned a value for the ListOfStringsMember property. This DOES + * NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). + * This is useful because the SDK will never return a null collection or map, but you may need to differentiate + * between the service returning nothing (or null) and the service returning an empty collection or map. For + * requests, this returns true if a value for the property was specified in the request builder, and false if a + * value was not specified. + */ + public boolean hasListOfStringsMember() { + return listOfStringsMember != null && !(listOfStringsMember instanceof SdkAutoConstructList); + } + + /** + * Returns the value of the ListOfStringsMember property for this object. + *

+ * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. + *

+ *

+ * This method will never return null. If you would like to know whether the service returned this field (so that + * you can differentiate between null and empty), you can use the {@link #hasListOfStringsMember} method. + *

+ * + * @return The value of the ListOfStringsMember property for this object. + */ + public List listOfStringsMember() { + return listOfStringsMember; + } + + /** + * For responses, this returns true if the service returned a value for the MapOfStringToStringMember property. This + * DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the + * property). This is useful because the SDK will never return a null collection or map, but you may need to + * differentiate between the service returning nothing (or null) and the service returning an empty collection or + * map. For requests, this returns true if a value for the property was specified in the request builder, and false + * if a value was not specified. + */ + public boolean hasMapOfStringToStringMember() { + return mapOfStringToStringMember != null && !(mapOfStringToStringMember instanceof SdkAutoConstructMap); + } + + /** + * Returns the value of the MapOfStringToStringMember property for this object. + *

+ * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. + *

+ *

+ * This method will never return null. If you would like to know whether the service returned this field (so that + * you can differentiate between null and empty), you can use the {@link #hasMapOfStringToStringMember} method. + *

+ * + * @return The value of the MapOfStringToStringMember property for this object. + */ + public Map mapOfStringToStringMember() { + return mapOfStringToStringMember; + } + + /** + * Returns the value of the ComplexStructMember property for this object. + * + * @return The value of the ComplexStructMember property for this object. + */ + public ComplexStructure complexStructMember() { + return complexStructMember; + } + + /** + * Returns the value of the MyDocument property for this object. + * + * @return The value of the MyDocument property for this object. + */ + public final Document documentField() { + return documentField; + } + + @Override + public Builder toBuilder() { + return new BuilderImpl(this); + } + + public static Builder builder() { + return new BuilderImpl(); + } + + public static Class serializableBuilderClass() { + return BuilderImpl.class; + } + + @Override + public int hashCode() { + int hashCode = 1; + hashCode = 31 * hashCode + super.hashCode(); + hashCode = 31 * hashCode + Objects.hashCode(booleanMember()); + hashCode = 31 * hashCode + Objects.hashCode(stringMember()); + hashCode = 31 * hashCode + Objects.hashCode(integerMember()); + hashCode = 31 * hashCode + Objects.hashCode(longMember()); + hashCode = 31 * hashCode + Objects.hashCode(floatMember()); + hashCode = 31 * hashCode + Objects.hashCode(doubleMember()); + hashCode = 31 * hashCode + Objects.hashCode(timestampMember()); + hashCode = 31 * hashCode + Objects.hashCode(blobMember()); + hashCode = 31 * hashCode + Objects.hashCode(hasListOfStringsMember() ? listOfStringsMember() : null); + hashCode = 31 * hashCode + Objects.hashCode(hasMapOfStringToStringMember() ? mapOfStringToStringMember() : null); + hashCode = 31 * hashCode + Objects.hashCode(complexStructMember()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + return super.equals(obj) && equalsBySdkFields(obj); + } + + public boolean equalsBySdkFields(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof TestRequest)) { + return false; + } + TestRequest other = (TestRequest) obj; + return Objects.equals(booleanMember(), other.booleanMember()) && Objects.equals(stringMember(), other.stringMember()) + && Objects.equals(integerMember(), other.integerMember()) && Objects.equals(longMember(), other.longMember()) + && Objects.equals(floatMember(), other.floatMember()) && Objects.equals(doubleMember(), other.doubleMember()) + && Objects.equals(timestampMember(), other.timestampMember()) && Objects.equals(blobMember(), other.blobMember()) + && hasListOfStringsMember() == other.hasListOfStringsMember() + && Objects.equals(listOfStringsMember(), other.listOfStringsMember()) + && hasMapOfStringToStringMember() == other.hasMapOfStringToStringMember() + && Objects.equals(mapOfStringToStringMember(), other.mapOfStringToStringMember()) + && Objects.equals(complexStructMember(), other.complexStructMember()); + } + + /** + * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be + * redacted from this string using a placeholder value. + */ + @Override + public String toString() { + return ToString.builder("EchoOperationRequest").add("BooleanMember", booleanMember()).add("StringMember", stringMember()) + .add("IntegerMember", integerMember()).add("LongMember", longMember()).add("FloatMember", floatMember()) + .add("DoubleMember", doubleMember()).add("TimestampMember", timestampMember()).add("BlobMember", blobMember()) + .add("ListOfStringsMember", hasListOfStringsMember() ? listOfStringsMember() : null) + .add("MapOfStringToStringMember", hasMapOfStringToStringMember() ? mapOfStringToStringMember() : null) + .add("ComplexStructMember", complexStructMember()).build(); + } + + public Optional getValueForField(String fieldName, Class clazz) { + switch (fieldName) { + case "booleanMember": + return Optional.ofNullable(clazz.cast(booleanMember())); + case "stringMember": + return Optional.ofNullable(clazz.cast(stringMember())); + case "integerMember": + return Optional.ofNullable(clazz.cast(integerMember())); + case "longMember": + return Optional.ofNullable(clazz.cast(longMember())); + case "floatMember": + return Optional.ofNullable(clazz.cast(floatMember())); + case "doubleMember": + return Optional.ofNullable(clazz.cast(doubleMember())); + case "timestampMember": + return Optional.ofNullable(clazz.cast(timestampMember())); + case "blobMember": + return Optional.ofNullable(clazz.cast(blobMember())); + case "listOfStringsMember": + return Optional.ofNullable(clazz.cast(listOfStringsMember())); + case "mapOfStringToStringMember": + return Optional.ofNullable(clazz.cast(mapOfStringToStringMember())); + case "complexStructMember": + return Optional.ofNullable(clazz.cast(complexStructMember())); + default: + return Optional.empty(); + } + } + + @Override + public List> sdkFields() { + return SDK_FIELDS; + } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + + private static Function getter(Function g) { + return obj -> g.apply((TestRequest) obj); + } + + private static BiConsumer setter(BiConsumer s) { + return (obj, val) -> s.accept((Builder) obj, val); + } + + public interface Builder extends SdkPojo, CopyableBuilder { + /** + * Sets the value of the BooleanMember property for this object. + * + * @param booleanMember + * The new value for the BooleanMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder booleanMember(Boolean booleanMember); + + /** + * Sets the value of the StringMember property for this object. + * + * @param stringMember + * The new value for the StringMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder stringMember(String stringMember); + + /** + * Sets the value of the IntegerMember property for this object. + * + * @param integerMember + * The new value for the IntegerMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder integerMember(Integer integerMember); + + /** + * Sets the value of the LongMember property for this object. + * + * @param longMember + * The new value for the LongMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder longMember(Long longMember); + + /** + * Sets the value of the FloatMember property for this object. + * + * @param floatMember + * The new value for the FloatMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder floatMember(Float floatMember); + + /** + * Sets the value of the DoubleMember property for this object. + * + * @param doubleMember + * The new value for the DoubleMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder doubleMember(Double doubleMember); + + /** + * Sets the value of the TimestampMember property for this object. + * + * @param timestampMember + * The new value for the TimestampMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder timestampMember(Instant timestampMember); + + /** + * Sets the value of the BlobMember property for this object. + * + * @param blobMember + * The new value for the BlobMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder blobMember(SdkBytes blobMember); + + /** + * Sets the value of the ListOfStringsMember property for this object. + * + * @param listOfStringsMember + * The new value for the ListOfStringsMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfStringsMember(Collection listOfStringsMember); + + /** + * Sets the value of the ListOfStringsMember property for this object. + * + * @param listOfStringsMember + * The new value for the ListOfStringsMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfStringsMember(String... listOfStringsMember); + + /** + * Sets the value of the MapOfStringToStringMember property for this object. + * + * @param mapOfStringToStringMember + * The new value for the MapOfStringToStringMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToStringMember(Map mapOfStringToStringMember); + + /** + * Sets the value of the ComplexStructMember property for this object. + * + * @param complexStructMember + * The new value for the ComplexStructMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder complexStructMember(ComplexStructure complexStructMember); + + /** + * Sets the value of the MyDocument property for this object. + * + * @param documentField + * The new value for the MyDocument property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder documentField(Document documentField); + + /** + * Sets the value of the ComplexStructMember property for this object. + * + * This is a convenience method that creates an instance of the {@link ComplexStructure.Builder} avoiding the + * need to create one manually via {@link ComplexStructure#builder()}. + * + *

+ * When the {@link Consumer} completes, {@link ComplexStructure.Builder#build()} is called immediately and its + * result is passed to {@link #complexStructMember(ComplexStructure)}. + * + * @param complexStructMember + * a consumer that will call methods on {@link ComplexStructure.Builder} + * @return Returns a reference to this object so that method calls can be chained together. + * @see #complexStructMember(ComplexStructure) + */ + default Builder complexStructMember(Consumer complexStructMember) { + return complexStructMember(ComplexStructure.builder().applyMutation(complexStructMember).build()); + } + } + + static class BuilderImpl implements Builder { + private Boolean booleanMember; + + private String stringMember; + + private Integer integerMember; + + private Long longMember; + + private Float floatMember; + + private Double doubleMember; + + private Instant timestampMember; + + private SdkBytes blobMember; + + private List listOfStringsMember = DefaultSdkAutoConstructList.getInstance(); + + private Map mapOfStringToStringMember = DefaultSdkAutoConstructMap.getInstance(); + + private ComplexStructure complexStructMember; + private Document documentField; + + private BuilderImpl() { + } + + private BuilderImpl(TestRequest model) { + booleanMember(model.booleanMember); + stringMember(model.stringMember); + integerMember(model.integerMember); + longMember(model.longMember); + floatMember(model.floatMember); + doubleMember(model.doubleMember); + timestampMember(model.timestampMember); + blobMember(model.blobMember); + listOfStringsMember(model.listOfStringsMember); + mapOfStringToStringMember(model.mapOfStringToStringMember); + complexStructMember(model.complexStructMember); + documentField(model.documentField); + } + + public Boolean getBooleanMember() { + return booleanMember; + } + + public void setBooleanMember(Boolean booleanMember) { + this.booleanMember = booleanMember; + } + + @Override + public Builder booleanMember(Boolean booleanMember) { + this.booleanMember = booleanMember; + return this; + } + + public String getStringMember() { + return stringMember; + } + + public void setStringMember(String stringMember) { + this.stringMember = stringMember; + } + + @Override + public Builder stringMember(String stringMember) { + this.stringMember = stringMember; + return this; + } + + public Integer getIntegerMember() { + return integerMember; + } + + public void setIntegerMember(Integer integerMember) { + this.integerMember = integerMember; + } + + @Override + public Builder integerMember(Integer integerMember) { + this.integerMember = integerMember; + return this; + } + + public Long getLongMember() { + return longMember; + } + + public void setLongMember(Long longMember) { + this.longMember = longMember; + } + + @Override + public Builder longMember(Long longMember) { + this.longMember = longMember; + return this; + } + + public Float getFloatMember() { + return floatMember; + } + + public void setFloatMember(Float floatMember) { + this.floatMember = floatMember; + } + + @Override + public Builder floatMember(Float floatMember) { + this.floatMember = floatMember; + return this; + } + + public Double getDoubleMember() { + return doubleMember; + } + + public void setDoubleMember(Double doubleMember) { + this.doubleMember = doubleMember; + } + + @Override + public Builder doubleMember(Double doubleMember) { + this.doubleMember = doubleMember; + return this; + } + + public Instant getTimestampMember() { + return timestampMember; + } + + public void setTimestampMember(Instant timestampMember) { + this.timestampMember = timestampMember; + } + + @Override + public Builder timestampMember(Instant timestampMember) { + this.timestampMember = timestampMember; + return this; + } + + public ByteBuffer getBlobMember() { + return blobMember == null ? null : blobMember.asByteBuffer(); + } + + public void setBlobMember(ByteBuffer blobMember) { + blobMember(blobMember == null ? null : SdkBytes.fromByteBuffer(blobMember)); + } + + @Override + public Builder blobMember(SdkBytes blobMember) { + this.blobMember = blobMember; + return this; + } + + public Collection getListOfStringsMember() { + if (listOfStringsMember instanceof SdkAutoConstructList) { + return null; + } + return listOfStringsMember; + } + + public void setListOfStringsMember(Collection listOfStringsMember) { + this.listOfStringsMember = ListOfStringsCopier.copy(listOfStringsMember); + } + + @Override + public Builder listOfStringsMember(Collection listOfStringsMember) { + this.listOfStringsMember = ListOfStringsCopier.copy(listOfStringsMember); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfStringsMember(String... listOfStringsMember) { + listOfStringsMember(Arrays.asList(listOfStringsMember)); + return this; + } + + public Map getMapOfStringToStringMember() { + if (mapOfStringToStringMember instanceof SdkAutoConstructMap) { + return null; + } + return mapOfStringToStringMember; + } + + public void setMapOfStringToStringMember(Map mapOfStringToStringMember) { + this.mapOfStringToStringMember = MapOfStringToStringCopier.copy(mapOfStringToStringMember); + } + + @Override + public Builder mapOfStringToStringMember(Map mapOfStringToStringMember) { + this.mapOfStringToStringMember = MapOfStringToStringCopier.copy(mapOfStringToStringMember); + return this; + } + + public ComplexStructure.Builder getComplexStructMember() { + return complexStructMember != null ? complexStructMember.toBuilder() : null; + } + + public void setComplexStructMember(ComplexStructure.BuilderImpl complexStructMember) { + this.complexStructMember = complexStructMember != null ? complexStructMember.build() : null; + } + + @Override + public Builder complexStructMember(ComplexStructure complexStructMember) { + this.complexStructMember = complexStructMember; + return this; + } + + @Override + public Builder documentField(Document documentField) { + this.documentField = documentField; + return this; + } + + @Override + public TestRequest build() { + return new TestRequest(this); + } + + @Override + public List> sdkFields() { + return SDK_FIELDS; + } + + @Override + public Map> sdkFieldNameToField() { + return SDK_NAME_TO_FIELD; + } + } +} diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkNumber.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkNumber.java index 99ce53564d79..5f5bbf61c440 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkNumber.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkNumber.java @@ -227,9 +227,13 @@ public static SdkNumber fromString(String stringValue) { */ @Override public int intValue() { - return numberValue instanceof Integer ? numberValue.intValue() : - stringValue != null ? new BigDecimal(stringValue).intValue() - : valueOf(numberValue).intValue(); + if (numberValue instanceof Integer) { + return numberValue.intValue(); + } + if (stringValue != null) { + return new BigDecimal(stringValue).intValue(); + } + return valueOf(numberValue).intValue(); } /** @@ -244,8 +248,13 @@ public int intValue() { */ @Override public long longValue() { - return numberValue instanceof Long ? numberValue.longValue() : - stringValue != null ? new BigDecimal(stringValue).longValue() : valueOf(numberValue).longValue(); + if (numberValue instanceof Long) { + return numberValue.longValue(); + } + if (stringValue != null) { + return new BigDecimal(stringValue).longValue(); + } + return valueOf(numberValue).longValue(); } /** @@ -260,8 +269,13 @@ public long longValue() { */ @Override public float floatValue() { - return numberValue instanceof Float ? numberValue.floatValue() : - numberValue != null ? valueOf(numberValue).floatValue() : new BigDecimal(stringValue).floatValue(); + if (numberValue instanceof Float) { + return numberValue.floatValue(); + } + if (numberValue != null) { + return valueOf(numberValue).floatValue(); + } + return new BigDecimal(stringValue).floatValue(); } /** @@ -275,9 +289,13 @@ public float floatValue() { */ @Override public double doubleValue() { - return numberValue instanceof Double ? numberValue.doubleValue() : - numberValue != null ? valueOf(numberValue).doubleValue() : - new BigDecimal(stringValue).doubleValue(); + if (numberValue instanceof Double) { + return numberValue.doubleValue(); + } + if (numberValue != null) { + return valueOf(numberValue).doubleValue(); + } + return new BigDecimal(stringValue).doubleValue(); } /** diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkPojo.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkPojo.java index 918c6898f1b2..d917530cf207 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkPojo.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkPojo.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.core; import java.util.List; +import java.util.Map; import software.amazon.awssdk.annotations.SdkProtectedApi; /** @@ -46,4 +47,11 @@ public interface SdkPojo { default boolean equalsBySdkFields(Object other) { throw new UnsupportedOperationException(); } + + /** + * @return The mapping between the field name and its corresponding field. + */ + default Map> sdkFieldNameToField() { + throw new UnsupportedOperationException(); + } } diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/document/Document.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/document/Document.java index 31d74446047d..28c7bbf5bace 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/document/Document.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/document/Document.java @@ -46,7 +46,17 @@ @SdkPublicApi @Immutable public interface Document extends Serializable { - + /** + * Null document constant. Null values are invariant, no need to create a new one + * everytime we find a null value, instead we use this static constant. + */ + NullDocument NULL_DOCUMENT = new NullDocument(); + /** + * Boolean document constants. Boolean values are invariant, no need to create a new + * one everytime we find a boolean value, instead we use either constant. + */ + BooleanDocument TRUE_DOCUMENT = new BooleanDocument(true); + BooleanDocument FALSE_DOCUMENT = new BooleanDocument(false); /** * Create {@link Document} from a string, using the provided String. @@ -63,7 +73,10 @@ static Document fromString(String string) { * @return Implementation of Document that stores a Boolean. */ static Document fromBoolean(boolean booleanValue) { - return new BooleanDocument(booleanValue); + if (booleanValue) { + return TRUE_DOCUMENT; + } + return FALSE_DOCUMENT; } /** @@ -183,7 +196,7 @@ static ListBuilder listBuilder() { * @return Implementation of a Null Document. */ static Document fromNull() { - return new NullDocument(); + return NULL_DOCUMENT; } /** diff --git a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/rest-json-output.json b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/rest-json-output.json index 5a6197b2c625..d660230cf715 100644 --- a/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/rest-json-output.json +++ b/test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/rest-json-output.json @@ -140,6 +140,30 @@ } } }, + { + "description": "Mixed location response with status code and header is unmarshalled correctly", + "given": { + "response": { + "status_code": 201, + "body": "{\"StringMember\": \"string member value\",\"IntegerMember\":123}", + "headers": { + "x-amz-string": "header member value" + } + } + }, + "when": { + "action": "unmarshall", + "operation": "MixedLocationOperation" + }, + "then": { + "deserializedAs": { + "StatusCodeMember": 201, + "StringMember": "string member value", + "IntegerMember": 123, + "StringHeaderMember": "header member value" + } + } + }, { "description": "Members declared to be in the query parameters or path on response are unmarshalled from the payload", "given": { @@ -190,4 +214,4 @@ } } } -] \ No newline at end of file +] diff --git a/test/protocol-tests/src/main/resources/codegen-resources/restjson/service-2.json b/test/protocol-tests/src/main/resources/codegen-resources/restjson/service-2.json index 1ddadd6f392e..c0348f5b1ca6 100644 --- a/test/protocol-tests/src/main/resources/codegen-resources/restjson/service-2.json +++ b/test/protocol-tests/src/main/resources/codegen-resources/restjson/service-2.json @@ -188,6 +188,15 @@ }, "output":{"shape":"StatusCodeInOutputStructure"} }, + "MixedLocationOperation":{ + "name":"MixedLocationOperation", + "http":{ + "method":"GET", + "requestUri":"/2016-03-11/mixedLocationOperation" + }, + "output":{"shape":"MixedLocationOperationOutput"}, + "input":{"shape":"MixedLocationOperationInput"} + }, "StreamingInputOperation":{ "name":"StreamingInputOperation", "http":{ @@ -782,6 +791,37 @@ } } }, + "MixedLocationOperationInput":{ + "type":"structure", + "members":{ + "StringMember":{ + "shape":"String" + }, + "IntegerMember":{ + "shape":"Integer" + } + } + }, + "MixedLocationOperationOutput":{ + "type":"structure", + "members":{ + "StringMember":{ + "shape":"String" + }, + "IntegerMember":{ + "shape":"Integer" + }, + "StatusCodeMember":{ + "shape":"Integer", + "location":"statusCode" + }, + "StringHeaderMember":{ + "shape":"String", + "location":"header", + "locationName":"x-amz-string" + } + } + }, "StreamType":{ "type":"blob", "streaming":true, diff --git a/test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/apicall/protocol/JsonCodec.java b/test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/apicall/protocol/JsonCodec.java index 4eff341379ba..7d85997d59b7 100644 --- a/test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/apicall/protocol/JsonCodec.java +++ b/test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/apicall/protocol/JsonCodec.java @@ -56,7 +56,6 @@ public final class JsonCodec { .httpMethod(SdkHttpMethod.POST) .hasImplicitPayloadMembers(true) .build(); - private static final Map TIMESTAMP_FORMATS = timestampFormats(); /** @@ -68,6 +67,7 @@ public SdkPojo unmarshall(AwsJsonProtocol protocol, SdkPojo pojo, byte[] bytes) JsonProtocolUnmarshaller unmarshaller = JsonProtocolUnmarshaller .builder() + .enableFastUnmarshalling(true) .protocolUnmarshallDependencies(behavior.protocolUnmarshallDependencies()) .build(); SdkHttpFullResponse response = SdkHttpFullResponse diff --git a/test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/marshaller/dynamodb/V2DynamoDbAttributeValue.java b/test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/marshaller/dynamodb/V2DynamoDbAttributeValue.java index 0b770c8d1d08..71826708417c 100755 --- a/test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/marshaller/dynamodb/V2DynamoDbAttributeValue.java +++ b/test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/marshaller/dynamodb/V2DynamoDbAttributeValue.java @@ -43,6 +43,7 @@ import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; +import software.amazon.awssdk.protocols.json.internal.unmarshall.SdkClientJsonProtocolAdvancedOption; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; import software.amazon.awssdk.services.dynamodb.model.BackupInUseException; import software.amazon.awssdk.services.dynamodb.model.BackupNotFoundException; @@ -79,6 +80,7 @@ public class V2DynamoDbAttributeValue { .clientConfiguration(SdkClientConfiguration .builder() .option(SdkClientOption.ENDPOINT, URI.create("https://localhost")) + .option(SdkClientJsonProtocolAdvancedOption.ENABLE_FAST_UNMARSHALLER, true) .build()) .defaultServiceExceptionSupplier(DynamoDbException::builder) .protocol(AwsJsonProtocol.AWS_JSON)