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 6ab4b8f89ecd..a2006e40e9a9 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 @@ -129,6 +129,8 @@ public class CustomizationConfig { private Map modelMarshallerDefaultValueSupplier; + private boolean useAutoConstructList = true; + private CustomizationConfig() { } @@ -336,4 +338,12 @@ public Map getModelMarshallerDefaultValueSupplier() { public void setModelMarshallerDefaultValueSupplier(Map modelMarshallerDefaultValueSupplier) { this.modelMarshallerDefaultValueSupplier = modelMarshallerDefaultValueSupplier; } + + public boolean isUseAutoConstructList() { + return useAutoConstructList; + } + + public void setUseAutoConstructList(boolean useAutoConstructList) { + this.useAutoConstructList = useAutoConstructList; + } } diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/BeanGetterHelper.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/BeanGetterHelper.java index a4e276d159e2..06bfd2db0daf 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/BeanGetterHelper.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/BeanGetterHelper.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.codegen.poet.model; import com.squareup.javapoet.ClassName; +import com.squareup.javapoet.CodeBlock; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; @@ -49,15 +50,16 @@ public MethodSpec beanStyleGetter(MemberModel memberModel) { private MethodSpec regularGetter(MemberModel memberModel) { return basicGetter(memberModel, typeProvider.parameterType(memberModel), - "return $N", - memberModel.getVariable().getVariableName()); + CodeBlock.builder().add("return $N", memberModel.getVariable().getVariableName()) + .build()); } private MethodSpec builderGetter(MemberModel memberModel) { return basicGetter(memberModel, poetExtensions.getModelClass(memberModel.getC2jShape()).nestedClass("Builder"), - "return $1N != null ? $1N.toBuilder() : null", - memberModel.getVariable().getVariableName()); + CodeBlock.builder().add("return $1N != null ? $1N.toBuilder() : null", + memberModel.getVariable().getVariableName()) + .build()); } private MethodSpec mapOfBuildersGetter(MemberModel memberModel) { @@ -68,10 +70,11 @@ private MethodSpec mapOfBuildersGetter(MemberModel memberModel) { return basicGetter(memberModel, returnType, - "return $1N != null ? $2T.mapValues($1N, $3T::toBuilder) : null", - memberModel.getVariable().getVariableName(), - CollectionUtils.class, - valueType); + CodeBlock.builder().add("return $1N != null ? $2T.mapValues($1N, $3T::toBuilder) : null", + memberModel.getVariable().getVariableName(), + CollectionUtils.class, + valueType) + .build()); } private MethodSpec listOfBuildersGetter(MemberModel memberModel) { @@ -80,17 +83,19 @@ private MethodSpec listOfBuildersGetter(MemberModel memberModel) { return basicGetter(memberModel, returnType, - "return $1N != null ? $1N.stream().map($2T::toBuilder).collect($3T.toList()) : null", - memberModel.getVariable().getVariableName(), - memberType, - Collectors.class); + CodeBlock.builder().add( + "return $1N != null ? $1N.stream().map($2T::toBuilder).collect($3T.toList()) : null", + memberModel.getVariable().getVariableName(), + memberType, + Collectors.class) + .build()); } - private MethodSpec basicGetter(MemberModel memberModel, TypeName returnType, String statementCode, Object...statementArgs) { + private MethodSpec basicGetter(MemberModel memberModel, TypeName returnType, CodeBlock statement) { return MethodSpec.methodBuilder(memberModel.getBeanStyleGetterMethodName()) .addModifiers(Modifier.PUBLIC, Modifier.FINAL) .returns(returnType) - .addStatement(statementCode, statementArgs) + .addStatement(statement) .build(); } } diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/MemberCopierSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/MemberCopierSpec.java index 4339f71b7a72..75ba2dd7401f 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/MemberCopierSpec.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/MemberCopierSpec.java @@ -36,6 +36,8 @@ import software.amazon.awssdk.codegen.poet.PoetUtils; import software.amazon.awssdk.codegen.poet.StaticImport; import software.amazon.awssdk.core.runtime.StandardMemberCopier; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; class MemberCopierSpec implements ClassSpec { private final MemberModel memberModel; @@ -99,15 +101,15 @@ private MethodSpec.Builder copyMethodProto() { private MethodSpec builderCopyMethod() { if (memberModel.isList()) { - return builderCopyMethodForMap(); + return builderCopyMethodForList(); } if (memberModel.isMap()) { - return builderCopyMethodForList(); + return builderCopyMethodForMap(); } throw new UnsupportedOperationException(); } - private MethodSpec builderCopyMethodForList() { + private MethodSpec builderCopyMethodForMap() { TypeName keyType = typeProvider.getTypeNameForSimpleType(memberModel.getMapModel().getKeyModel() .getVariable().getVariableType()); ClassName valueParameter = poetExtensions.getModelClass(memberModel.getMapModel().getValueModel().getC2jShape()); @@ -134,7 +136,7 @@ private MethodSpec builderCopyMethodForList() { .build(); } - private MethodSpec builderCopyMethodForMap() { + private MethodSpec builderCopyMethodForList() { ClassName listParameter = poetExtensions.getModelClass(memberModel.getListModel().getListMemberModel().getC2jShape()); ClassName builderForParameter = listParameter.nestedClass("Builder"); @@ -176,18 +178,42 @@ private CodeBlock listCopyBody() { String paramName = memberParamName(); MemberModel listMember = memberModel.getListModel().getListMemberModel(); String copyName = paramName + "Copy"; - CodeBlock.Builder builder = CodeBlock.builder() - .beginControlFlow("if ($N == null)", memberParamName()) - .addStatement("return null") - .endControlFlow() - .add("$T $N = $N.stream()", typeProvider.fieldType(memberModel), copyName, paramName); - serviceModelCopiers.copierClassFor(listMember) - .ifPresent(copyClass -> builder.add(".map($T::$N)", copyClass, serviceModelCopiers.copyMethodName())); + CodeBlock.Builder builder = CodeBlock.builder(); - builder.add(".collect(toList());"); + if (typeProvider.useAutoConstructLists()) { + builder.beginControlFlow("if ($1N == null || $1N instanceof $2T)", memberParamName(), SdkAutoConstructList.class) + .addStatement("return $T.getInstance()", DefaultSdkAutoConstructList.class) + .endControlFlow(); + + } else { + builder.beginControlFlow("if ($N == null)", memberParamName()) + .addStatement("return null") + .endControlFlow(); + } - return builder.addStatement("return $T.unmodifiableList($N)", Collections.class, copyName).build(); + Optional elementCopier = serviceModelCopiers.copierClassFor(listMember); + + // Just use constructor copy if there's no copier for the element + if (!elementCopier.isPresent()) { + builder.addStatement("$T $N = new $T<>($N)", + typeProvider.fieldType(memberModel), + copyName, + typeProvider.listImplClassName(), + paramName); + } else { + ClassName copier = elementCopier.get(); + builder.addStatement("$T $N = $N.stream().map($T::$N).collect(toList())", + typeProvider.fieldType(memberModel), + copyName, + paramName, + copier, + serviceModelCopiers.copyMethodName()); + } + + builder.addStatement("return $T.unmodifiableList($N)", Collections.class, copyName); + + return builder.build(); } private CodeBlock mapCopyBody() { 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 fa0734f6f37b..5596ab5fbdf7 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 @@ -24,12 +24,14 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; import javax.lang.model.element.Modifier; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.intermediate.ShapeModel; import software.amazon.awssdk.codegen.model.intermediate.ShapeType; import software.amazon.awssdk.codegen.poet.PoetExtensions; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; import software.amazon.awssdk.utils.builder.CopyableBuilder; /** @@ -130,10 +132,20 @@ private TypeName builderImplSuperClass() { } private List fields() { - List fields = new ArrayList<>(shapeModelSpec.fields(Modifier.PRIVATE)); + List fields = shapeModel.getNonStreamingMembers().stream() + .map(m -> { + FieldSpec fieldSpec = typeProvider.asField(m, Modifier.PRIVATE); + if (m.isList() && typeProvider.useAutoConstructLists()) { + fieldSpec = fieldSpec.toBuilder() + .initializer("$T.getInstance()", DefaultSdkAutoConstructList.class) + .build(); + } + return fieldSpec; + }).collect(Collectors.toList()); // Inject a message member for the isException message if (isException()) { + fields = new ArrayList<>(fields); fields.add(FieldSpec.builder(String.class, "message", Modifier.PRIVATE).build()); } 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 c1f6a09b04a6..62a6783f2f13 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 @@ -20,7 +20,6 @@ import java.util.List; import java.util.stream.Collectors; import javax.lang.model.element.Modifier; -import software.amazon.awssdk.codegen.model.intermediate.MemberModel; import software.amazon.awssdk.codegen.model.intermediate.ShapeModel; import software.amazon.awssdk.codegen.poet.PoetExtensions; @@ -48,19 +47,7 @@ public List fields() { public List fields(Modifier... modifiers) { return shapeModel.getNonStreamingMembers().stream() - .map(m -> asField(m, modifiers)) + .map(m -> typeProvider.asField(m, modifiers)) .collect(Collectors.toList()); } - - public FieldSpec asField(MemberModel memberModel, Modifier... modifiers) { - FieldSpec.Builder builder = FieldSpec.builder(typeProvider.fieldType(memberModel), - memberModel.getVariable().getVariableName()); - - if (modifiers != null) { - builder.addModifiers(modifiers); - } - - return builder.build(); - } - } diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/TypeProvider.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/TypeProvider.java index 8fbeccdc3fe0..eac9b3d833a3 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/TypeProvider.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/TypeProvider.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.codegen.poet.model; import com.squareup.javapoet.ClassName; +import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.WildcardTypeName; @@ -30,6 +31,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Stream; +import javax.lang.model.element.Modifier; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.intermediate.ListModel; import software.amazon.awssdk.codegen.model.intermediate.MapModel; @@ -40,16 +42,22 @@ * Helper class for resolving Poet {@link TypeName}s for use in model classes. */ public class TypeProvider { + private final IntermediateModel intermediateModel; private final PoetExtensions poetExtensions; public TypeProvider(IntermediateModel intermediateModel) { - this.poetExtensions = new PoetExtensions(intermediateModel); + this.intermediateModel = intermediateModel; + this.poetExtensions = new PoetExtensions(this.intermediateModel); } public ClassName listImplClassName() { return ClassName.get(ArrayList.class); } + public boolean useAutoConstructLists() { + return intermediateModel.getCustomizationConfig().isUseAutoConstructList(); + } + public ClassName mapImplClassName() { return ClassName.get(HashMap.class); } @@ -160,4 +168,15 @@ public TypeName getTypeNameForSimpleType(String simpleType) { .findFirst() .orElseThrow(() -> new RuntimeException("Unsupported simple fieldType " + simpleType)); } + + public FieldSpec asField(MemberModel memberModel, Modifier... modifiers) { + FieldSpec.Builder builder = FieldSpec.builder(fieldType(memberModel), + memberModel.getVariable().getVariableName()); + + if (modifiers != null) { + builder.addModifiers(modifiers); + } + + return builder.build(); + } } diff --git a/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsModelSpecTest.java b/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsModelSpecTest.java index 11bf6ea20292..98f3bbfc0b80 100644 --- a/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsModelSpecTest.java +++ b/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsModelSpecTest.java @@ -38,6 +38,7 @@ @RunWith(Parameterized.class) public class AwsModelSpecTest { private static IntermediateModel intermediateModel; + private final ShapeModel shapeModel; @Parameterized.Parameters(name = "{0}") @@ -64,11 +65,13 @@ private static void setUp() throws IOException { File customizationConfigFile = new File(AwsModelSpecTest.class .getResource("customization.config") .getFile()); + ServiceModel serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile); + CustomizationConfig basicConfig = ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile); intermediateModel = new IntermediateModelBuilder( C2jModels.builder() - .serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile)) - .customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile)) + .serviceModel(serviceModel) + .customizationConfig(basicConfig) .build()) .build(); } diff --git a/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsModelSpecWithoutAutoConstructContainersTest.java b/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsModelSpecWithoutAutoConstructContainersTest.java new file mode 100644 index 000000000000..fcd326682610 --- /dev/null +++ b/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/AwsModelSpecWithoutAutoConstructContainersTest.java @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2018 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.codegen.poet.model; + +import static java.util.stream.Collectors.toList; +import static org.hamcrest.MatcherAssert.assertThat; +import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo; +import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Locale; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import software.amazon.awssdk.codegen.C2jModels; +import software.amazon.awssdk.codegen.IntermediateModelBuilder; +import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig; +import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; +import software.amazon.awssdk.codegen.model.intermediate.ShapeModel; +import software.amazon.awssdk.codegen.model.service.ServiceModel; +import software.amazon.awssdk.codegen.utils.ModelLoaderUtils; + +/** + * Similar to {@link AwsModelSpecTest} but tests correct generation when auto construct containers are disabled. + */ +@RunWith(Parameterized.class) +public class AwsModelSpecWithoutAutoConstructContainersTest { + private static IntermediateModel intermediateModel; + + private final ShapeModel shapeModel; + + @Parameterized.Parameters(name = "{0}") + public static Collection data() { + invokeSafely(AwsModelSpecWithoutAutoConstructContainersTest::setUp); + return intermediateModel.getShapes().values().stream().map(shape -> new Object[] { shape }).collect(toList()); + } + + public AwsModelSpecWithoutAutoConstructContainersTest(ShapeModel shapeModel) { + this.shapeModel = shapeModel; + } + + @Test + public void generationWithAutoConstructList() { + assertThat(new AwsServiceModel(intermediateModel, shapeModel), generatesTo(referenceFileForShape())); + } + + private String referenceFileForShape() { + String name = shapeModel.getShapeName().toLowerCase(Locale.ENGLISH) + ".java"; + String autoConstructVariant = "./nonautoconstructcontainers/" + name; + if (getClass().getResource(autoConstructVariant) != null) { + return autoConstructVariant; + } + return name; + } + + private static void setUp() throws IOException { + File serviceModelFile = new File(AwsModelSpecWithoutAutoConstructContainersTest.class.getResource("service-2.json").getFile()); + File customizationConfigFile = new File(AwsModelSpecWithoutAutoConstructContainersTest.class + .getResource("customization.config") + .getFile()); + ServiceModel serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile); + CustomizationConfig autoConstructListConfig = ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile); + autoConstructListConfig.setUseAutoConstructList(false); + + intermediateModel = new IntermediateModelBuilder( + C2jModels.builder() + .serviceModel(serviceModel) + .customizationConfig(autoConstructListConfig) + .build()) + .build(); + + } +} diff --git a/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/ModelCopierSpecWithoutAutoConstructContainersTest.java b/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/ModelCopierSpecWithoutAutoConstructContainersTest.java new file mode 100644 index 000000000000..7ee7a46ff822 --- /dev/null +++ b/codegen/src/test/java/software/amazon/awssdk/codegen/poet/model/ModelCopierSpecWithoutAutoConstructContainersTest.java @@ -0,0 +1,96 @@ +/* + * Copyright 2010-2018 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.codegen.poet.model; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import software.amazon.awssdk.codegen.C2jModels; +import software.amazon.awssdk.codegen.IntermediateModelBuilder; +import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig; +import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; +import software.amazon.awssdk.codegen.model.service.ServiceModel; +import software.amazon.awssdk.codegen.poet.ClassSpec; +import software.amazon.awssdk.codegen.utils.ModelLoaderUtils; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Collection; +import java.util.Locale; + +import static java.util.stream.Collectors.toList; +import static org.hamcrest.MatcherAssert.assertThat; +import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo; +import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely; + +/** + * Similar to {@link ModelCopierSpecTest} but tests correct generation when auto construct containers are disabled. + */ +@RunWith(Parameterized.class) +public class ModelCopierSpecWithoutAutoConstructContainersTest { + private static File serviceModelFile; + private static IntermediateModel intermediateModel; + private final ClassSpec spec; + private final String specName; + + private static void setUp() throws URISyntaxException, IOException { + serviceModelFile = new File(AwsModelSpecTest.class + .getResource("service-2.json") + .getFile()); + + File customizationConfigFile = new File(AwsModelSpecTest.class + .getResource("customization.config") + .getFile()); + + CustomizationConfig customizationConfig = ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile); + customizationConfig.setUseAutoConstructList(false); + + intermediateModel = new IntermediateModelBuilder( + C2jModels.builder() + .serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile)) + .customizationConfig(customizationConfig) + .build()) + .build(); + } + + @Parameterized.Parameters(name = "{1}") + public static Collection data() { + invokeSafely(ModelCopierSpecWithoutAutoConstructContainersTest::setUp); + return new ServiceModelCopiers(intermediateModel).copierSpecs().stream() + .map(spec -> new Object[] { spec, spec.className().simpleName().toLowerCase(Locale.ENGLISH) }) + .collect(toList()); + } + + public ModelCopierSpecWithoutAutoConstructContainersTest(ClassSpec spec, String specName) { + this.spec = spec; + this.specName = specName; + } + + @Test + public void basicGeneration() { + assertThat(spec, generatesTo(expectedFile())); + } + + private String expectedFile() { + String name = specName + ".java"; + String autoConstructVariant = "./nonautoconstructcontainers/" + name; + if (getClass().getResource(autoConstructVariant) != null) { + return autoConstructVariant; + } + return name; + } +} 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 33a0c4f1793b..688f53b08f84 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 @@ -17,6 +17,7 @@ import software.amazon.awssdk.core.runtime.StandardMemberCopier; import software.amazon.awssdk.core.runtime.TypeConverter; import software.amazon.awssdk.core.runtime.adapters.types.StringToByteBufferAdapter; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.ToString; import software.amazon.awssdk.utils.builder.CopyableBuilder; @@ -26,7 +27,7 @@ */ @Generated("software.amazon.awssdk:codegen") public final class AllTypesRequest extends JsonProtocolTestsRequest implements - ToCopyableBuilder { + ToCopyableBuilder { private final String stringMember; private final Integer integerMember; @@ -272,7 +273,7 @@ public Map mapOfStringToSimpleStruct() { */ public Map mapOfEnumToEnum() { return TypeConverter.convert(mapOfEnumToEnum, EnumType::fromValue, EnumType::fromValue, - (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); } /** @@ -297,7 +298,7 @@ public Map mapOfEnumToEnumAsStrings() { */ public Map mapOfEnumToString() { return TypeConverter.convert(mapOfEnumToString, EnumType::fromValue, Function.identity(), - (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); } /** @@ -346,7 +347,7 @@ public Map mapOfStringToEnumAsStrings() { */ public Map mapOfEnumToSimpleStruct() { return TypeConverter.convert(mapOfEnumToSimpleStruct, EnumType::fromValue, Function.identity(), - (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); } /** @@ -540,104 +541,104 @@ public boolean equals(Object obj) { } AllTypesRequest other = (AllTypesRequest) 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(simpleList(), other.simpleList()) - && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) - && Objects.equals(listOfMaps(), other.listOfMaps()) && Objects.equals(listOfStructs(), other.listOfStructs()) - && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) - && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) - && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) - && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) - && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) - && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) - && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) - && Objects.equals(timestampMember(), other.timestampMember()) - && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) - && Objects.equals(blobArg(), other.blobArg()) - && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) - && Objects.equals(blobMap(), other.blobMap()) && 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(booleanMember(), other.booleanMember()) && Objects.equals(floatMember(), other.floatMember()) + && Objects.equals(doubleMember(), other.doubleMember()) && Objects.equals(longMember(), other.longMember()) + && Objects.equals(simpleList(), other.simpleList()) + && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) + && Objects.equals(listOfMaps(), other.listOfMaps()) && Objects.equals(listOfStructs(), other.listOfStructs()) + && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) + && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) + && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) + && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) + && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) + && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) + && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) + && Objects.equals(timestampMember(), other.timestampMember()) + && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) + && Objects.equals(blobArg(), other.blobArg()) + && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) + && Objects.equals(blobMap(), other.blobMap()) && 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()); } @Override public String toString() { return ToString.builder("AllTypesRequest").add("StringMember", stringMember()).add("IntegerMember", integerMember()) - .add("BooleanMember", booleanMember()).add("FloatMember", floatMember()).add("DoubleMember", doubleMember()) - .add("LongMember", longMember()).add("SimpleList", simpleList()).add("ListOfEnums", listOfEnumsAsStrings()) - .add("ListOfMaps", listOfMaps()).add("ListOfStructs", listOfStructs()) - .add("MapOfStringToIntegerList", mapOfStringToIntegerList()).add("MapOfStringToString", mapOfStringToString()) - .add("MapOfStringToSimpleStruct", mapOfStringToSimpleStruct()).add("MapOfEnumToEnum", mapOfEnumToEnumAsStrings()) - .add("MapOfEnumToString", mapOfEnumToStringAsStrings()).add("MapOfStringToEnum", mapOfStringToEnumAsStrings()) - .add("MapOfEnumToSimpleStruct", mapOfEnumToSimpleStructAsStrings()).add("TimestampMember", timestampMember()) - .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) - .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", blobMap()).add("ListOfBlobs", listOfBlobs()) - .add("RecursiveStruct", recursiveStruct()).add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) - .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) - .build(); + .add("BooleanMember", booleanMember()).add("FloatMember", floatMember()).add("DoubleMember", doubleMember()) + .add("LongMember", longMember()).add("SimpleList", simpleList()).add("ListOfEnums", listOfEnumsAsStrings()) + .add("ListOfMaps", listOfMaps()).add("ListOfStructs", listOfStructs()) + .add("MapOfStringToIntegerList", mapOfStringToIntegerList()).add("MapOfStringToString", mapOfStringToString()) + .add("MapOfStringToSimpleStruct", mapOfStringToSimpleStruct()).add("MapOfEnumToEnum", mapOfEnumToEnumAsStrings()) + .add("MapOfEnumToString", mapOfEnumToStringAsStrings()).add("MapOfStringToEnum", mapOfStringToEnumAsStrings()) + .add("MapOfEnumToSimpleStruct", mapOfEnumToSimpleStructAsStrings()).add("TimestampMember", timestampMember()) + .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) + .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", blobMap()).add("ListOfBlobs", listOfBlobs()) + .add("RecursiveStruct", recursiveStruct()).add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) + .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) + .build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "StringMember": - return Optional.of(clazz.cast(stringMember())); - case "IntegerMember": - return Optional.of(clazz.cast(integerMember())); - case "BooleanMember": - return Optional.of(clazz.cast(booleanMember())); - case "FloatMember": - return Optional.of(clazz.cast(floatMember())); - case "DoubleMember": - return Optional.of(clazz.cast(doubleMember())); - case "LongMember": - return Optional.of(clazz.cast(longMember())); - case "SimpleList": - return Optional.of(clazz.cast(simpleList())); - case "ListOfEnums": - return Optional.of(clazz.cast(listOfEnumsAsStrings())); - case "ListOfMaps": - return Optional.of(clazz.cast(listOfMaps())); - case "ListOfStructs": - return Optional.of(clazz.cast(listOfStructs())); - case "MapOfStringToIntegerList": - return Optional.of(clazz.cast(mapOfStringToIntegerList())); - case "MapOfStringToString": - return Optional.of(clazz.cast(mapOfStringToString())); - case "MapOfStringToSimpleStruct": - return Optional.of(clazz.cast(mapOfStringToSimpleStruct())); - case "MapOfEnumToEnum": - return Optional.of(clazz.cast(mapOfEnumToEnumAsStrings())); - case "MapOfEnumToString": - return Optional.of(clazz.cast(mapOfEnumToStringAsStrings())); - case "MapOfStringToEnum": - return Optional.of(clazz.cast(mapOfStringToEnumAsStrings())); - case "MapOfEnumToSimpleStruct": - return Optional.of(clazz.cast(mapOfEnumToSimpleStructAsStrings())); - case "TimestampMember": - return Optional.of(clazz.cast(timestampMember())); - case "StructWithNestedTimestampMember": - return Optional.of(clazz.cast(structWithNestedTimestampMember())); - case "BlobArg": - return Optional.of(clazz.cast(blobArg())); - case "StructWithNestedBlob": - return Optional.of(clazz.cast(structWithNestedBlob())); - case "BlobMap": - return Optional.of(clazz.cast(blobMap())); - case "ListOfBlobs": - return Optional.of(clazz.cast(listOfBlobs())); - case "RecursiveStruct": - return Optional.of(clazz.cast(recursiveStruct())); - case "PolymorphicTypeWithSubTypes": - return Optional.of(clazz.cast(polymorphicTypeWithSubTypes())); - case "PolymorphicTypeWithoutSubTypes": - return Optional.of(clazz.cast(polymorphicTypeWithoutSubTypes())); - case "EnumType": - return Optional.of(clazz.cast(enumTypeAsString())); - default: - return Optional.empty(); + case "StringMember": + return Optional.of(clazz.cast(stringMember())); + case "IntegerMember": + return Optional.of(clazz.cast(integerMember())); + case "BooleanMember": + return Optional.of(clazz.cast(booleanMember())); + case "FloatMember": + return Optional.of(clazz.cast(floatMember())); + case "DoubleMember": + return Optional.of(clazz.cast(doubleMember())); + case "LongMember": + return Optional.of(clazz.cast(longMember())); + case "SimpleList": + return Optional.of(clazz.cast(simpleList())); + case "ListOfEnums": + return Optional.of(clazz.cast(listOfEnumsAsStrings())); + case "ListOfMaps": + return Optional.of(clazz.cast(listOfMaps())); + case "ListOfStructs": + return Optional.of(clazz.cast(listOfStructs())); + case "MapOfStringToIntegerList": + return Optional.of(clazz.cast(mapOfStringToIntegerList())); + case "MapOfStringToString": + return Optional.of(clazz.cast(mapOfStringToString())); + case "MapOfStringToSimpleStruct": + return Optional.of(clazz.cast(mapOfStringToSimpleStruct())); + case "MapOfEnumToEnum": + return Optional.of(clazz.cast(mapOfEnumToEnumAsStrings())); + case "MapOfEnumToString": + return Optional.of(clazz.cast(mapOfEnumToStringAsStrings())); + case "MapOfStringToEnum": + return Optional.of(clazz.cast(mapOfStringToEnumAsStrings())); + case "MapOfEnumToSimpleStruct": + return Optional.of(clazz.cast(mapOfEnumToSimpleStructAsStrings())); + case "TimestampMember": + return Optional.of(clazz.cast(timestampMember())); + case "StructWithNestedTimestampMember": + return Optional.of(clazz.cast(structWithNestedTimestampMember())); + case "BlobArg": + return Optional.of(clazz.cast(blobArg())); + case "StructWithNestedBlob": + return Optional.of(clazz.cast(structWithNestedBlob())); + case "BlobMap": + return Optional.of(clazz.cast(blobMap())); + case "ListOfBlobs": + return Optional.of(clazz.cast(listOfBlobs())); + case "RecursiveStruct": + return Optional.of(clazz.cast(recursiveStruct())); + case "PolymorphicTypeWithSubTypes": + return Optional.of(clazz.cast(polymorphicTypeWithSubTypes())); + case "PolymorphicTypeWithoutSubTypes": + return Optional.of(clazz.cast(polymorphicTypeWithoutSubTypes())); + case "EnumType": + return Optional.of(clazz.cast(enumTypeAsString())); + default: + return Optional.empty(); } } @@ -1075,13 +1076,13 @@ static final class BuilderImpl extends JsonProtocolTestsRequest.BuilderImpl impl private Long longMember; - private List simpleList; + private List simpleList = DefaultSdkAutoConstructList.getInstance(); - private List listOfEnums; + private List listOfEnums = DefaultSdkAutoConstructList.getInstance(); - private List> listOfMaps; + private List> listOfMaps = DefaultSdkAutoConstructList.getInstance(); - private List listOfStructs; + private List listOfStructs = DefaultSdkAutoConstructList.getInstance(); private Map> mapOfStringToIntegerList; @@ -1107,7 +1108,7 @@ static final class BuilderImpl extends JsonProtocolTestsRequest.BuilderImpl impl private Map blobMap; - private List listOfBlobs; + private List listOfBlobs = DefaultSdkAutoConstructList.getInstance(); private RecursiveStructType recursiveStruct; @@ -1300,7 +1301,7 @@ public final void setListOfMaps(Collection> listOfMaps) { public final Collection getListOfStructs() { return listOfStructs != null ? listOfStructs.stream().map(SimpleStruct::toBuilder).collect(Collectors.toList()) - : null; + : null; } @Override @@ -1357,7 +1358,7 @@ public final void setMapOfStringToString(Map mapOfStringToString public final Map getMapOfStringToSimpleStruct() { return mapOfStringToSimpleStruct != null ? CollectionUtils.mapValues(mapOfStringToSimpleStruct, - SimpleStruct::toBuilder) : null; + SimpleStruct::toBuilder) : null; } @Override @@ -1414,7 +1415,7 @@ public final void setMapOfStringToEnum(Map mapOfStringToEnum) { public final Map getMapOfEnumToSimpleStruct() { return mapOfEnumToSimpleStruct != null ? CollectionUtils.mapValues(mapOfEnumToSimpleStruct, SimpleStruct::toBuilder) - : null; + : null; } @Override @@ -1568,7 +1569,7 @@ public final Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWi public final void setPolymorphicTypeWithoutSubTypes(SubTypeOne.BuilderImpl polymorphicTypeWithoutSubTypes) { this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.build() - : null; + : null; } public final String getEnumType() { 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 a04ad3842af2..9fa79dff9b06 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 @@ -16,6 +16,7 @@ import software.amazon.awssdk.core.runtime.StandardMemberCopier; import software.amazon.awssdk.core.runtime.TypeConverter; import software.amazon.awssdk.core.runtime.adapters.types.StringToByteBufferAdapter; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.ToString; import software.amazon.awssdk.utils.builder.CopyableBuilder; @@ -25,7 +26,7 @@ */ @Generated("software.amazon.awssdk:codegen") public final class AllTypesResponse extends JsonProtocolTestsResponse implements - ToCopyableBuilder { + ToCopyableBuilder { private final String stringMember; private final Integer integerMember; @@ -271,7 +272,7 @@ public Map mapOfStringToSimpleStruct() { */ public Map mapOfEnumToEnum() { return TypeConverter.convert(mapOfEnumToEnum, EnumType::fromValue, EnumType::fromValue, - (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); } /** @@ -296,7 +297,7 @@ public Map mapOfEnumToEnumAsStrings() { */ public Map mapOfEnumToString() { return TypeConverter.convert(mapOfEnumToString, EnumType::fromValue, Function.identity(), - (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); } /** @@ -345,7 +346,7 @@ public Map mapOfStringToEnumAsStrings() { */ public Map mapOfEnumToSimpleStruct() { return TypeConverter.convert(mapOfEnumToSimpleStruct, EnumType::fromValue, Function.identity(), - (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); } /** @@ -539,104 +540,104 @@ public boolean equals(Object obj) { } AllTypesResponse other = (AllTypesResponse) 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(simpleList(), other.simpleList()) - && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) - && Objects.equals(listOfMaps(), other.listOfMaps()) && Objects.equals(listOfStructs(), other.listOfStructs()) - && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) - && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) - && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) - && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) - && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) - && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) - && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) - && Objects.equals(timestampMember(), other.timestampMember()) - && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) - && Objects.equals(blobArg(), other.blobArg()) - && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) - && Objects.equals(blobMap(), other.blobMap()) && 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(booleanMember(), other.booleanMember()) && Objects.equals(floatMember(), other.floatMember()) + && Objects.equals(doubleMember(), other.doubleMember()) && Objects.equals(longMember(), other.longMember()) + && Objects.equals(simpleList(), other.simpleList()) + && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) + && Objects.equals(listOfMaps(), other.listOfMaps()) && Objects.equals(listOfStructs(), other.listOfStructs()) + && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) + && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) + && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) + && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) + && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) + && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) + && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) + && Objects.equals(timestampMember(), other.timestampMember()) + && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) + && Objects.equals(blobArg(), other.blobArg()) + && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) + && Objects.equals(blobMap(), other.blobMap()) && 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()); } @Override public String toString() { return ToString.builder("AllTypesResponse").add("StringMember", stringMember()).add("IntegerMember", integerMember()) - .add("BooleanMember", booleanMember()).add("FloatMember", floatMember()).add("DoubleMember", doubleMember()) - .add("LongMember", longMember()).add("SimpleList", simpleList()).add("ListOfEnums", listOfEnumsAsStrings()) - .add("ListOfMaps", listOfMaps()).add("ListOfStructs", listOfStructs()) - .add("MapOfStringToIntegerList", mapOfStringToIntegerList()).add("MapOfStringToString", mapOfStringToString()) - .add("MapOfStringToSimpleStruct", mapOfStringToSimpleStruct()).add("MapOfEnumToEnum", mapOfEnumToEnumAsStrings()) - .add("MapOfEnumToString", mapOfEnumToStringAsStrings()).add("MapOfStringToEnum", mapOfStringToEnumAsStrings()) - .add("MapOfEnumToSimpleStruct", mapOfEnumToSimpleStructAsStrings()).add("TimestampMember", timestampMember()) - .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) - .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", blobMap()).add("ListOfBlobs", listOfBlobs()) - .add("RecursiveStruct", recursiveStruct()).add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) - .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) - .build(); + .add("BooleanMember", booleanMember()).add("FloatMember", floatMember()).add("DoubleMember", doubleMember()) + .add("LongMember", longMember()).add("SimpleList", simpleList()).add("ListOfEnums", listOfEnumsAsStrings()) + .add("ListOfMaps", listOfMaps()).add("ListOfStructs", listOfStructs()) + .add("MapOfStringToIntegerList", mapOfStringToIntegerList()).add("MapOfStringToString", mapOfStringToString()) + .add("MapOfStringToSimpleStruct", mapOfStringToSimpleStruct()).add("MapOfEnumToEnum", mapOfEnumToEnumAsStrings()) + .add("MapOfEnumToString", mapOfEnumToStringAsStrings()).add("MapOfStringToEnum", mapOfStringToEnumAsStrings()) + .add("MapOfEnumToSimpleStruct", mapOfEnumToSimpleStructAsStrings()).add("TimestampMember", timestampMember()) + .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) + .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", blobMap()).add("ListOfBlobs", listOfBlobs()) + .add("RecursiveStruct", recursiveStruct()).add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) + .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) + .build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "StringMember": - return Optional.of(clazz.cast(stringMember())); - case "IntegerMember": - return Optional.of(clazz.cast(integerMember())); - case "BooleanMember": - return Optional.of(clazz.cast(booleanMember())); - case "FloatMember": - return Optional.of(clazz.cast(floatMember())); - case "DoubleMember": - return Optional.of(clazz.cast(doubleMember())); - case "LongMember": - return Optional.of(clazz.cast(longMember())); - case "SimpleList": - return Optional.of(clazz.cast(simpleList())); - case "ListOfEnums": - return Optional.of(clazz.cast(listOfEnumsAsStrings())); - case "ListOfMaps": - return Optional.of(clazz.cast(listOfMaps())); - case "ListOfStructs": - return Optional.of(clazz.cast(listOfStructs())); - case "MapOfStringToIntegerList": - return Optional.of(clazz.cast(mapOfStringToIntegerList())); - case "MapOfStringToString": - return Optional.of(clazz.cast(mapOfStringToString())); - case "MapOfStringToSimpleStruct": - return Optional.of(clazz.cast(mapOfStringToSimpleStruct())); - case "MapOfEnumToEnum": - return Optional.of(clazz.cast(mapOfEnumToEnumAsStrings())); - case "MapOfEnumToString": - return Optional.of(clazz.cast(mapOfEnumToStringAsStrings())); - case "MapOfStringToEnum": - return Optional.of(clazz.cast(mapOfStringToEnumAsStrings())); - case "MapOfEnumToSimpleStruct": - return Optional.of(clazz.cast(mapOfEnumToSimpleStructAsStrings())); - case "TimestampMember": - return Optional.of(clazz.cast(timestampMember())); - case "StructWithNestedTimestampMember": - return Optional.of(clazz.cast(structWithNestedTimestampMember())); - case "BlobArg": - return Optional.of(clazz.cast(blobArg())); - case "StructWithNestedBlob": - return Optional.of(clazz.cast(structWithNestedBlob())); - case "BlobMap": - return Optional.of(clazz.cast(blobMap())); - case "ListOfBlobs": - return Optional.of(clazz.cast(listOfBlobs())); - case "RecursiveStruct": - return Optional.of(clazz.cast(recursiveStruct())); - case "PolymorphicTypeWithSubTypes": - return Optional.of(clazz.cast(polymorphicTypeWithSubTypes())); - case "PolymorphicTypeWithoutSubTypes": - return Optional.of(clazz.cast(polymorphicTypeWithoutSubTypes())); - case "EnumType": - return Optional.of(clazz.cast(enumTypeAsString())); - default: - return Optional.empty(); + case "StringMember": + return Optional.of(clazz.cast(stringMember())); + case "IntegerMember": + return Optional.of(clazz.cast(integerMember())); + case "BooleanMember": + return Optional.of(clazz.cast(booleanMember())); + case "FloatMember": + return Optional.of(clazz.cast(floatMember())); + case "DoubleMember": + return Optional.of(clazz.cast(doubleMember())); + case "LongMember": + return Optional.of(clazz.cast(longMember())); + case "SimpleList": + return Optional.of(clazz.cast(simpleList())); + case "ListOfEnums": + return Optional.of(clazz.cast(listOfEnumsAsStrings())); + case "ListOfMaps": + return Optional.of(clazz.cast(listOfMaps())); + case "ListOfStructs": + return Optional.of(clazz.cast(listOfStructs())); + case "MapOfStringToIntegerList": + return Optional.of(clazz.cast(mapOfStringToIntegerList())); + case "MapOfStringToString": + return Optional.of(clazz.cast(mapOfStringToString())); + case "MapOfStringToSimpleStruct": + return Optional.of(clazz.cast(mapOfStringToSimpleStruct())); + case "MapOfEnumToEnum": + return Optional.of(clazz.cast(mapOfEnumToEnumAsStrings())); + case "MapOfEnumToString": + return Optional.of(clazz.cast(mapOfEnumToStringAsStrings())); + case "MapOfStringToEnum": + return Optional.of(clazz.cast(mapOfStringToEnumAsStrings())); + case "MapOfEnumToSimpleStruct": + return Optional.of(clazz.cast(mapOfEnumToSimpleStructAsStrings())); + case "TimestampMember": + return Optional.of(clazz.cast(timestampMember())); + case "StructWithNestedTimestampMember": + return Optional.of(clazz.cast(structWithNestedTimestampMember())); + case "BlobArg": + return Optional.of(clazz.cast(blobArg())); + case "StructWithNestedBlob": + return Optional.of(clazz.cast(structWithNestedBlob())); + case "BlobMap": + return Optional.of(clazz.cast(blobMap())); + case "ListOfBlobs": + return Optional.of(clazz.cast(listOfBlobs())); + case "RecursiveStruct": + return Optional.of(clazz.cast(recursiveStruct())); + case "PolymorphicTypeWithSubTypes": + return Optional.of(clazz.cast(polymorphicTypeWithSubTypes())); + case "PolymorphicTypeWithoutSubTypes": + return Optional.of(clazz.cast(polymorphicTypeWithoutSubTypes())); + case "EnumType": + return Optional.of(clazz.cast(enumTypeAsString())); + default: + return Optional.empty(); } } @@ -1068,13 +1069,13 @@ static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl imp private Long longMember; - private List simpleList; + private List simpleList = DefaultSdkAutoConstructList.getInstance(); - private List listOfEnums; + private List listOfEnums = DefaultSdkAutoConstructList.getInstance(); - private List> listOfMaps; + private List> listOfMaps = DefaultSdkAutoConstructList.getInstance(); - private List listOfStructs; + private List listOfStructs = DefaultSdkAutoConstructList.getInstance(); private Map> mapOfStringToIntegerList; @@ -1100,7 +1101,7 @@ static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl imp private Map blobMap; - private List listOfBlobs; + private List listOfBlobs = DefaultSdkAutoConstructList.getInstance(); private RecursiveStructType recursiveStruct; @@ -1293,7 +1294,7 @@ public final void setListOfMaps(Collection> listOfMaps) { public final Collection getListOfStructs() { return listOfStructs != null ? listOfStructs.stream().map(SimpleStruct::toBuilder).collect(Collectors.toList()) - : null; + : null; } @Override @@ -1350,7 +1351,7 @@ public final void setMapOfStringToString(Map mapOfStringToString public final Map getMapOfStringToSimpleStruct() { return mapOfStringToSimpleStruct != null ? CollectionUtils.mapValues(mapOfStringToSimpleStruct, - SimpleStruct::toBuilder) : null; + SimpleStruct::toBuilder) : null; } @Override @@ -1407,7 +1408,7 @@ public final void setMapOfStringToEnum(Map mapOfStringToEnum) { public final Map getMapOfEnumToSimpleStruct() { return mapOfEnumToSimpleStruct != null ? CollectionUtils.mapValues(mapOfEnumToSimpleStruct, SimpleStruct::toBuilder) - : null; + : null; } @Override @@ -1561,7 +1562,7 @@ public final Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWi public final void setPolymorphicTypeWithoutSubTypes(SubTypeOne.BuilderImpl polymorphicTypeWithoutSubTypes) { this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.build() - : null; + : null; } public final String getEnumType() { diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofblobstypecopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofblobstypecopier.java index 240fbce30fbf..ff34192cf18f 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofblobstypecopier.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofblobstypecopier.java @@ -8,15 +8,17 @@ import java.util.List; import javax.annotation.Generated; import software.amazon.awssdk.core.runtime.StandardMemberCopier; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; @Generated("software.amazon.awssdk:codegen") final class ListOfBlobsTypeCopier { static List copy(Collection listOfBlobsTypeParam) { - if (listOfBlobsTypeParam == null) { - return null; + if (listOfBlobsTypeParam == null || listOfBlobsTypeParam instanceof SdkAutoConstructList) { + return DefaultSdkAutoConstructList.getInstance(); } List listOfBlobsTypeParamCopy = listOfBlobsTypeParam.stream().map(StandardMemberCopier::copy) - .collect(toList()); + .collect(toList()); return Collections.unmodifiableList(listOfBlobsTypeParamCopy); } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofenumscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofenumscopier.java index b86df20c1baf..afb59df2e668 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofenumscopier.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofenumscopier.java @@ -2,18 +2,21 @@ import static java.util.stream.Collectors.toList; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import javax.annotation.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; @Generated("software.amazon.awssdk:codegen") final class ListOfEnumsCopier { static List copy(Collection listOfEnumsParam) { - if (listOfEnumsParam == null) { - return null; + if (listOfEnumsParam == null || listOfEnumsParam instanceof SdkAutoConstructList) { + return DefaultSdkAutoConstructList.getInstance(); } - List listOfEnumsParamCopy = listOfEnumsParam.stream().collect(toList()); + List listOfEnumsParamCopy = new ArrayList<>(listOfEnumsParam); return Collections.unmodifiableList(listOfEnumsParamCopy); } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofintegerscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofintegerscopier.java index 099c775facbf..a0a3d4431b90 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofintegerscopier.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofintegerscopier.java @@ -2,18 +2,21 @@ import static java.util.stream.Collectors.toList; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import javax.annotation.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; @Generated("software.amazon.awssdk:codegen") final class ListOfIntegersCopier { static List copy(Collection listOfIntegersParam) { - if (listOfIntegersParam == null) { - return null; + if (listOfIntegersParam == null || listOfIntegersParam instanceof SdkAutoConstructList) { + return DefaultSdkAutoConstructList.getInstance(); } - List listOfIntegersParamCopy = listOfIntegersParam.stream().collect(toList()); + List listOfIntegersParamCopy = new ArrayList<>(listOfIntegersParam); return Collections.unmodifiableList(listOfIntegersParamCopy); } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listoflistoflistofstringscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listoflistoflistofstringscopier.java index dab8076f0652..cf0fb7568b32 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listoflistoflistofstringscopier.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listoflistoflistofstringscopier.java @@ -6,18 +6,18 @@ import java.util.Collections; import java.util.List; import javax.annotation.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; @Generated("software.amazon.awssdk:codegen") final class ListOfListOfListOfStringsCopier { static List>> copy( Collection>> listOfListOfListOfStringsParam) { - if (listOfListOfListOfStringsParam == null) { - return null; + if (listOfListOfListOfStringsParam == null || listOfListOfListOfStringsParam instanceof SdkAutoConstructList) { + return DefaultSdkAutoConstructList.getInstance(); } List>> listOfListOfListOfStringsParamCopy = listOfListOfListOfStringsParam.stream() - .map(ListOfListOfStringsCopier::copy) - .collect(toList()); + .map(ListOfListOfStringsCopier::copy).collect(toList()); return Collections.unmodifiableList(listOfListOfListOfStringsParamCopy); } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listoflistofstringscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listoflistofstringscopier.java index 985248e4f1fa..dab6c69d1ef9 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listoflistofstringscopier.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listoflistofstringscopier.java @@ -6,17 +6,17 @@ import java.util.Collections; import java.util.List; import javax.annotation.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; @Generated("software.amazon.awssdk:codegen") final class ListOfListOfStringsCopier { static List> copy(Collection> listOfListOfStringsParam) { - if (listOfListOfStringsParam == null) { - return null; + if (listOfListOfStringsParam == null || listOfListOfStringsParam instanceof SdkAutoConstructList) { + return DefaultSdkAutoConstructList.getInstance(); } - List> listOfListOfStringsParamCopy = listOfListOfStringsParam.stream() - .map(ListOfStringsCopier::copy) - .collect(toList()); + List> listOfListOfStringsParamCopy = listOfListOfStringsParam.stream().map(ListOfStringsCopier::copy) + .collect(toList()); return Collections.unmodifiableList(listOfListOfStringsParamCopy); } } - diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofmapstringtostringcopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofmapstringtostringcopier.java index 3abe41d599ff..3a3eaffc3806 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofmapstringtostringcopier.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofmapstringtostringcopier.java @@ -7,15 +7,17 @@ import java.util.List; import java.util.Map; import javax.annotation.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; @Generated("software.amazon.awssdk:codegen") final class ListOfMapStringToStringCopier { static List> copy(Collection> listOfMapStringToStringParam) { - if (listOfMapStringToStringParam == null) { - return null; + if (listOfMapStringToStringParam == null || listOfMapStringToStringParam instanceof SdkAutoConstructList) { + return DefaultSdkAutoConstructList.getInstance(); } List> listOfMapStringToStringParamCopy = listOfMapStringToStringParam.stream() - .map(MapOfStringToStringCopier::copy).collect(toList()); + .map(MapOfStringToStringCopier::copy).collect(toList()); return Collections.unmodifiableList(listOfMapStringToStringParamCopy); } } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofsimplestructscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofsimplestructscopier.java index 15aa5501f8f0..71f356ce913f 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofsimplestructscopier.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/listofsimplestructscopier.java @@ -2,18 +2,21 @@ import static java.util.stream.Collectors.toList; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import javax.annotation.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; @Generated("software.amazon.awssdk:codegen") final class ListOfSimpleStructsCopier { static List copy(Collection listOfSimpleStructsParam) { - if (listOfSimpleStructsParam == null) { - return null; + if (listOfSimpleStructsParam == null || listOfSimpleStructsParam instanceof SdkAutoConstructList) { + return DefaultSdkAutoConstructList.getInstance(); } - List listOfSimpleStructsParamCopy = listOfSimpleStructsParam.stream().collect(toList()); + List listOfSimpleStructsParamCopy = new ArrayList<>(listOfSimpleStructsParam); return Collections.unmodifiableList(listOfSimpleStructsParamCopy); } @@ -24,4 +27,3 @@ static List copyFromBuilder(Collection copy(Collection listOfStringsParam) { - if (listOfStringsParam == null) { - return null; + if (listOfStringsParam == null || listOfStringsParam instanceof SdkAutoConstructList) { + return DefaultSdkAutoConstructList.getInstance(); } - List listOfStringsParamCopy = listOfStringsParam.stream().collect(toList()); + List listOfStringsParamCopy = new ArrayList<>(listOfStringsParam); return Collections.unmodifiableList(listOfStringsParamCopy); } } 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 feb1f5cfac28..2fc5c447c9cd 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 @@ -9,6 +9,7 @@ import java.util.function.Consumer; import javax.annotation.Generated; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; import software.amazon.awssdk.utils.ToString; import software.amazon.awssdk.utils.builder.CopyableBuilder; import software.amazon.awssdk.utils.builder.ToCopyableBuilder; @@ -17,7 +18,7 @@ */ @Generated("software.amazon.awssdk:codegen") public final class NestedContainersRequest extends JsonProtocolTestsRequest implements - ToCopyableBuilder { + ToCopyableBuilder { private final List> listOfListOfStrings; private final List>> listOfListOfListOfStrings; @@ -102,27 +103,27 @@ public boolean equals(Object obj) { } NestedContainersRequest other = (NestedContainersRequest) obj; return Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) - && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) - && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); + && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) + && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); } @Override public String toString() { return ToString.builder("NestedContainersRequest").add("ListOfListOfStrings", listOfListOfStrings()) - .add("ListOfListOfListOfStrings", listOfListOfListOfStrings()) - .add("MapOfStringToListOfListOfStrings", mapOfStringToListOfListOfStrings()).build(); + .add("ListOfListOfListOfStrings", listOfListOfListOfStrings()) + .add("MapOfStringToListOfListOfStrings", mapOfStringToListOfListOfStrings()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "ListOfListOfStrings": - return Optional.of(clazz.cast(listOfListOfStrings())); - case "ListOfListOfListOfStrings": - return Optional.of(clazz.cast(listOfListOfListOfStrings())); - case "MapOfStringToListOfListOfStrings": - return Optional.of(clazz.cast(mapOfStringToListOfListOfStrings())); - default: - return Optional.empty(); + case "ListOfListOfStrings": + return Optional.of(clazz.cast(listOfListOfStrings())); + case "ListOfListOfListOfStrings": + return Optional.of(clazz.cast(listOfListOfListOfStrings())); + case "MapOfStringToListOfListOfStrings": + return Optional.of(clazz.cast(mapOfStringToListOfListOfStrings())); + default: + return Optional.empty(); } } @@ -181,9 +182,9 @@ Builder mapOfStringToListOfListOfStrings( } static final class BuilderImpl extends JsonProtocolTestsRequest.BuilderImpl implements Builder { - private List> listOfListOfStrings; + private List> listOfListOfStrings = DefaultSdkAutoConstructList.getInstance(); - private List>> listOfListOfListOfStrings; + private List>> listOfListOfListOfStrings = DefaultSdkAutoConstructList.getInstance(); private Map>> mapOfStringToListOfListOfStrings; 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 f59b38c02d66..5b8dd7ae4ed5 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 @@ -7,6 +7,7 @@ import java.util.Objects; import java.util.Optional; import javax.annotation.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; import software.amazon.awssdk.utils.ToString; import software.amazon.awssdk.utils.builder.CopyableBuilder; import software.amazon.awssdk.utils.builder.ToCopyableBuilder; @@ -15,7 +16,7 @@ */ @Generated("software.amazon.awssdk:codegen") public final class NestedContainersResponse extends JsonProtocolTestsResponse implements - ToCopyableBuilder { + ToCopyableBuilder { private final List> listOfListOfStrings; private final List>> listOfListOfListOfStrings; @@ -100,27 +101,27 @@ public boolean equals(Object obj) { } NestedContainersResponse other = (NestedContainersResponse) obj; return Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) - && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) - && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); + && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) + && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); } @Override public String toString() { return ToString.builder("NestedContainersResponse").add("ListOfListOfStrings", listOfListOfStrings()) - .add("ListOfListOfListOfStrings", listOfListOfListOfStrings()) - .add("MapOfStringToListOfListOfStrings", mapOfStringToListOfListOfStrings()).build(); + .add("ListOfListOfListOfStrings", listOfListOfListOfStrings()) + .add("MapOfStringToListOfListOfStrings", mapOfStringToListOfListOfStrings()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "ListOfListOfStrings": - return Optional.of(clazz.cast(listOfListOfStrings())); - case "ListOfListOfListOfStrings": - return Optional.of(clazz.cast(listOfListOfListOfStrings())); - case "MapOfStringToListOfListOfStrings": - return Optional.of(clazz.cast(mapOfStringToListOfListOfStrings())); - default: - return Optional.empty(); + case "ListOfListOfStrings": + return Optional.of(clazz.cast(listOfListOfStrings())); + case "ListOfListOfListOfStrings": + return Optional.of(clazz.cast(listOfListOfListOfStrings())); + case "MapOfStringToListOfListOfStrings": + return Optional.of(clazz.cast(mapOfStringToListOfListOfStrings())); + default: + return Optional.empty(); } } @@ -169,13 +170,13 @@ public interface Builder extends JsonProtocolTestsResponse.Builder, CopyableBuil * @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 { - private List> listOfListOfStrings; + private List> listOfListOfStrings = DefaultSdkAutoConstructList.getInstance(); - private List>> listOfListOfListOfStrings; + private List>> listOfListOfListOfStrings = DefaultSdkAutoConstructList.getInstance(); private Map>> mapOfStringToListOfListOfStrings; @@ -216,7 +217,7 @@ public final Collection>> getL @Override public final Builder listOfListOfListOfStrings( - Collection>> listOfListOfListOfStrings) { + Collection>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); return this; } @@ -229,7 +230,7 @@ public final Builder listOfListOfListOfStrings(Collection>> listOfListOfListOfStrings) { + Collection>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); } @@ -239,13 +240,13 @@ public final void setListOfListOfListOfStrings( @Override public final Builder mapOfStringToListOfListOfStrings( - Map>> mapOfStringToListOfListOfStrings) { + Map>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); return this; } public final void setMapOfStringToListOfListOfStrings( - Map>> mapOfStringToListOfListOfStrings) { + Map>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); } diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/alltypesrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/alltypesrequest.java new file mode 100644 index 000000000000..343f229fbabb --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/alltypesrequest.java @@ -0,0 +1,1611 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import java.nio.ByteBuffer; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.annotation.Generated; +import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; +import software.amazon.awssdk.core.runtime.StandardMemberCopier; +import software.amazon.awssdk.core.runtime.TypeConverter; +import software.amazon.awssdk.core.runtime.adapters.types.StringToByteBufferAdapter; +import software.amazon.awssdk.utils.CollectionUtils; +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 AllTypesRequest extends JsonProtocolTestsRequest implements + ToCopyableBuilder { + private final String stringMember; + + private final Integer integerMember; + + private final Boolean booleanMember; + + private final Float floatMember; + + private final Double doubleMember; + + private final Long longMember; + + private final List simpleList; + + private final List listOfEnums; + + private final List> listOfMaps; + + private final List listOfStructs; + + private final Map> mapOfStringToIntegerList; + + private final Map mapOfStringToString; + + private final Map mapOfStringToSimpleStruct; + + private final Map mapOfEnumToEnum; + + private final Map mapOfEnumToString; + + private final Map mapOfStringToEnum; + + private final Map mapOfEnumToSimpleStruct; + + private final Instant timestampMember; + + private final StructWithTimestamp structWithNestedTimestampMember; + + private final ByteBuffer blobArg; + + private final StructWithNestedBlobType structWithNestedBlob; + + private final Map blobMap; + + private final List listOfBlobs; + + private final RecursiveStructType recursiveStruct; + + private final BaseType polymorphicTypeWithSubTypes; + + private final SubTypeOne polymorphicTypeWithoutSubTypes; + + private final String enumType; + + private AllTypesRequest(BuilderImpl builder) { + super(builder); + this.stringMember = builder.stringMember; + this.integerMember = builder.integerMember; + this.booleanMember = builder.booleanMember; + this.floatMember = builder.floatMember; + this.doubleMember = builder.doubleMember; + this.longMember = builder.longMember; + this.simpleList = builder.simpleList; + this.listOfEnums = builder.listOfEnums; + this.listOfMaps = builder.listOfMaps; + this.listOfStructs = builder.listOfStructs; + this.mapOfStringToIntegerList = builder.mapOfStringToIntegerList; + this.mapOfStringToString = builder.mapOfStringToString; + this.mapOfStringToSimpleStruct = builder.mapOfStringToSimpleStruct; + this.mapOfEnumToEnum = builder.mapOfEnumToEnum; + this.mapOfEnumToString = builder.mapOfEnumToString; + this.mapOfStringToEnum = builder.mapOfStringToEnum; + this.mapOfEnumToSimpleStruct = builder.mapOfEnumToSimpleStruct; + this.timestampMember = builder.timestampMember; + this.structWithNestedTimestampMember = builder.structWithNestedTimestampMember; + this.blobArg = builder.blobArg; + this.structWithNestedBlob = builder.structWithNestedBlob; + this.blobMap = builder.blobMap; + this.listOfBlobs = builder.listOfBlobs; + this.recursiveStruct = builder.recursiveStruct; + this.polymorphicTypeWithSubTypes = builder.polymorphicTypeWithSubTypes; + this.polymorphicTypeWithoutSubTypes = builder.polymorphicTypeWithoutSubTypes; + this.enumType = builder.enumType; + } + + /** + * 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 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 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 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 SimpleList property for this object. + *

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

+ * + * @return The value of the SimpleList property for this object. + */ + public List simpleList() { + return simpleList; + } + + /** + * Returns the value of the ListOfEnums property for this object. + *

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

+ * + * @return The value of the ListOfEnums property for this object. + */ + public List listOfEnums() { + return TypeConverter.convert(listOfEnums, EnumType::fromValue); + } + + /** + * Returns the value of the ListOfEnums property for this object. + *

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

+ * + * @return The value of the ListOfEnums property for this object. + */ + public List listOfEnumsAsStrings() { + return listOfEnums; + } + + /** + * Returns the value of the ListOfMaps property for this object. + *

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

+ * + * @return The value of the ListOfMaps property for this object. + */ + public List> listOfMaps() { + return listOfMaps; + } + + /** + * Returns the value of the ListOfStructs property for this object. + *

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

+ * + * @return The value of the ListOfStructs property for this object. + */ + public List listOfStructs() { + return listOfStructs; + } + + /** + * Returns the value of the MapOfStringToIntegerList property for this object. + *

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

+ * + * @return The value of the MapOfStringToIntegerList property for this object. + */ + public Map> mapOfStringToIntegerList() { + return mapOfStringToIntegerList; + } + + /** + * Returns the value of the MapOfStringToString property for this object. + *

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

+ * + * @return The value of the MapOfStringToString property for this object. + */ + public Map mapOfStringToString() { + return mapOfStringToString; + } + + /** + * Returns the value of the MapOfStringToSimpleStruct property for this object. + *

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

+ * + * @return The value of the MapOfStringToSimpleStruct property for this object. + */ + public Map mapOfStringToSimpleStruct() { + return mapOfStringToSimpleStruct; + } + + /** + * Returns the value of the MapOfEnumToEnum property for this object. + *

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

+ * + * @return The value of the MapOfEnumToEnum property for this object. + */ + public Map mapOfEnumToEnum() { + return TypeConverter.convert(mapOfEnumToEnum, EnumType::fromValue, EnumType::fromValue, + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + } + + /** + * Returns the value of the MapOfEnumToEnum property for this object. + *

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

+ * + * @return The value of the MapOfEnumToEnum property for this object. + */ + public Map mapOfEnumToEnumAsStrings() { + return mapOfEnumToEnum; + } + + /** + * Returns the value of the MapOfEnumToString property for this object. + *

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

+ * + * @return The value of the MapOfEnumToString property for this object. + */ + public Map mapOfEnumToString() { + return TypeConverter.convert(mapOfEnumToString, EnumType::fromValue, Function.identity(), + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + } + + /** + * Returns the value of the MapOfEnumToString property for this object. + *

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

+ * + * @return The value of the MapOfEnumToString property for this object. + */ + public Map mapOfEnumToStringAsStrings() { + return mapOfEnumToString; + } + + /** + * Returns the value of the MapOfStringToEnum property for this object. + *

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

+ * + * @return The value of the MapOfStringToEnum property for this object. + */ + public Map mapOfStringToEnum() { + return TypeConverter.convert(mapOfStringToEnum, Function.identity(), EnumType::fromValue, (k, v) -> true); + } + + /** + * Returns the value of the MapOfStringToEnum property for this object. + *

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

+ * + * @return The value of the MapOfStringToEnum property for this object. + */ + public Map mapOfStringToEnumAsStrings() { + return mapOfStringToEnum; + } + + /** + * Returns the value of the MapOfEnumToSimpleStruct property for this object. + *

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

+ * + * @return The value of the MapOfEnumToSimpleStruct property for this object. + */ + public Map mapOfEnumToSimpleStruct() { + return TypeConverter.convert(mapOfEnumToSimpleStruct, EnumType::fromValue, Function.identity(), + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + } + + /** + * Returns the value of the MapOfEnumToSimpleStruct property for this object. + *

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

+ * + * @return The value of the MapOfEnumToSimpleStruct property for this object. + */ + public Map mapOfEnumToSimpleStructAsStrings() { + return mapOfEnumToSimpleStruct; + } + + /** + * 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 StructWithNestedTimestampMember property for this object. + * + * @return The value of the StructWithNestedTimestampMember property for this object. + */ + public StructWithTimestamp structWithNestedTimestampMember() { + return structWithNestedTimestampMember; + } + + /** + * Returns the value of the BlobArg property for this object. + *

+ * This method will return a new read-only {@code ByteBuffer} each time it is invoked. + *

+ * + * @return The value of the BlobArg property for this object. + */ + public ByteBuffer blobArg() { + return blobArg == null ? null : blobArg.asReadOnlyBuffer(); + } + + /** + * Returns the value of the StructWithNestedBlob property for this object. + * + * @return The value of the StructWithNestedBlob property for this object. + */ + public StructWithNestedBlobType structWithNestedBlob() { + return structWithNestedBlob; + } + + /** + * Returns the value of the BlobMap property for this object. + *

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

+ * + * @return The value of the BlobMap property for this object. + */ + public Map blobMap() { + return blobMap; + } + + /** + * Returns the value of the ListOfBlobs property for this object. + *

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

+ * + * @return The value of the ListOfBlobs property for this object. + */ + public List listOfBlobs() { + return listOfBlobs; + } + + /** + * Returns the value of the RecursiveStruct property for this object. + * + * @return The value of the RecursiveStruct property for this object. + */ + public RecursiveStructType recursiveStruct() { + return recursiveStruct; + } + + /** + * Returns the value of the PolymorphicTypeWithSubTypes property for this object. + * + * @return The value of the PolymorphicTypeWithSubTypes property for this object. + */ + public BaseType polymorphicTypeWithSubTypes() { + return polymorphicTypeWithSubTypes; + } + + /** + * Returns the value of the PolymorphicTypeWithoutSubTypes property for this object. + * + * @return The value of the PolymorphicTypeWithoutSubTypes property for this object. + */ + public SubTypeOne polymorphicTypeWithoutSubTypes() { + return polymorphicTypeWithoutSubTypes; + } + + /** + * Returns the value of the EnumType property for this object. + *

+ * If the service returns an enum value that is not available in the current SDK version, {@link #enumType} will + * 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 + */ + public EnumType enumType() { + return EnumType.fromValue(enumType); + } + + /** + * Returns the value of the EnumType property for this object. + *

+ * If the service returns an enum value that is not available in the current SDK version, {@link #enumType} will + * 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 + */ + public String enumTypeAsString() { + return enumType; + } + + @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 + Objects.hashCode(stringMember()); + hashCode = 31 * hashCode + Objects.hashCode(integerMember()); + hashCode = 31 * hashCode + Objects.hashCode(booleanMember()); + hashCode = 31 * hashCode + Objects.hashCode(floatMember()); + hashCode = 31 * hashCode + Objects.hashCode(doubleMember()); + hashCode = 31 * hashCode + Objects.hashCode(longMember()); + hashCode = 31 * hashCode + Objects.hashCode(simpleList()); + hashCode = 31 * hashCode + Objects.hashCode(listOfEnumsAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(listOfMaps()); + hashCode = 31 * hashCode + Objects.hashCode(listOfStructs()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToIntegerList()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToString()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToSimpleStruct()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToEnumAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToStringAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToEnumAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToSimpleStructAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(timestampMember()); + hashCode = 31 * hashCode + Objects.hashCode(structWithNestedTimestampMember()); + hashCode = 31 * hashCode + Objects.hashCode(blobArg()); + hashCode = 31 * hashCode + Objects.hashCode(structWithNestedBlob()); + hashCode = 31 * hashCode + Objects.hashCode(blobMap()); + hashCode = 31 * hashCode + Objects.hashCode(listOfBlobs()); + hashCode = 31 * hashCode + Objects.hashCode(recursiveStruct()); + hashCode = 31 * hashCode + Objects.hashCode(polymorphicTypeWithSubTypes()); + hashCode = 31 * hashCode + Objects.hashCode(polymorphicTypeWithoutSubTypes()); + hashCode = 31 * hashCode + Objects.hashCode(enumTypeAsString()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof AllTypesRequest)) { + return false; + } + AllTypesRequest other = (AllTypesRequest) 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(simpleList(), other.simpleList()) + && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) + && Objects.equals(listOfMaps(), other.listOfMaps()) && Objects.equals(listOfStructs(), other.listOfStructs()) + && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) + && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) + && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) + && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) + && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) + && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) + && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) + && Objects.equals(timestampMember(), other.timestampMember()) + && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) + && Objects.equals(blobArg(), other.blobArg()) + && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) + && Objects.equals(blobMap(), other.blobMap()) && 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()); + } + + @Override + public String toString() { + return ToString.builder("AllTypesRequest").add("StringMember", stringMember()).add("IntegerMember", integerMember()) + .add("BooleanMember", booleanMember()).add("FloatMember", floatMember()).add("DoubleMember", doubleMember()) + .add("LongMember", longMember()).add("SimpleList", simpleList()).add("ListOfEnums", listOfEnumsAsStrings()) + .add("ListOfMaps", listOfMaps()).add("ListOfStructs", listOfStructs()) + .add("MapOfStringToIntegerList", mapOfStringToIntegerList()).add("MapOfStringToString", mapOfStringToString()) + .add("MapOfStringToSimpleStruct", mapOfStringToSimpleStruct()).add("MapOfEnumToEnum", mapOfEnumToEnumAsStrings()) + .add("MapOfEnumToString", mapOfEnumToStringAsStrings()).add("MapOfStringToEnum", mapOfStringToEnumAsStrings()) + .add("MapOfEnumToSimpleStruct", mapOfEnumToSimpleStructAsStrings()).add("TimestampMember", timestampMember()) + .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) + .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", blobMap()).add("ListOfBlobs", listOfBlobs()) + .add("RecursiveStruct", recursiveStruct()).add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) + .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) + .build(); + } + + public Optional getValueForField(String fieldName, Class clazz) { + switch (fieldName) { + case "StringMember": + return Optional.of(clazz.cast(stringMember())); + case "IntegerMember": + return Optional.of(clazz.cast(integerMember())); + case "BooleanMember": + return Optional.of(clazz.cast(booleanMember())); + case "FloatMember": + return Optional.of(clazz.cast(floatMember())); + case "DoubleMember": + return Optional.of(clazz.cast(doubleMember())); + case "LongMember": + return Optional.of(clazz.cast(longMember())); + case "SimpleList": + return Optional.of(clazz.cast(simpleList())); + case "ListOfEnums": + return Optional.of(clazz.cast(listOfEnumsAsStrings())); + case "ListOfMaps": + return Optional.of(clazz.cast(listOfMaps())); + case "ListOfStructs": + return Optional.of(clazz.cast(listOfStructs())); + case "MapOfStringToIntegerList": + return Optional.of(clazz.cast(mapOfStringToIntegerList())); + case "MapOfStringToString": + return Optional.of(clazz.cast(mapOfStringToString())); + case "MapOfStringToSimpleStruct": + return Optional.of(clazz.cast(mapOfStringToSimpleStruct())); + case "MapOfEnumToEnum": + return Optional.of(clazz.cast(mapOfEnumToEnumAsStrings())); + case "MapOfEnumToString": + return Optional.of(clazz.cast(mapOfEnumToStringAsStrings())); + case "MapOfStringToEnum": + return Optional.of(clazz.cast(mapOfStringToEnumAsStrings())); + case "MapOfEnumToSimpleStruct": + return Optional.of(clazz.cast(mapOfEnumToSimpleStructAsStrings())); + case "TimestampMember": + return Optional.of(clazz.cast(timestampMember())); + case "StructWithNestedTimestampMember": + return Optional.of(clazz.cast(structWithNestedTimestampMember())); + case "BlobArg": + return Optional.of(clazz.cast(blobArg())); + case "StructWithNestedBlob": + return Optional.of(clazz.cast(structWithNestedBlob())); + case "BlobMap": + return Optional.of(clazz.cast(blobMap())); + case "ListOfBlobs": + return Optional.of(clazz.cast(listOfBlobs())); + case "RecursiveStruct": + return Optional.of(clazz.cast(recursiveStruct())); + case "PolymorphicTypeWithSubTypes": + return Optional.of(clazz.cast(polymorphicTypeWithSubTypes())); + case "PolymorphicTypeWithoutSubTypes": + return Optional.of(clazz.cast(polymorphicTypeWithoutSubTypes())); + case "EnumType": + return Optional.of(clazz.cast(enumTypeAsString())); + default: + return Optional.empty(); + } + } + + public interface Builder extends JsonProtocolTestsRequest.Builder, CopyableBuilder { + /** + * 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 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 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 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 SimpleList property for this object. + * + * @param simpleList + * The new value for the SimpleList property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder simpleList(Collection simpleList); + + /** + * Sets the value of the SimpleList property for this object. + * + * @param simpleList + * The new value for the SimpleList property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder simpleList(String... simpleList); + + /** + * Sets the value of the ListOfEnums property for this object. + * + * @param listOfEnums + * The new value for the ListOfEnums property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfEnums(Collection listOfEnums); + + /** + * Sets the value of the ListOfEnums property for this object. + * + * @param listOfEnums + * The new value for the ListOfEnums property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfEnums(String... listOfEnums); + + /** + * Sets the value of the ListOfMaps property for this object. + * + * @param listOfMaps + * The new value for the ListOfMaps property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfMaps(Collection> listOfMaps); + + /** + * Sets the value of the ListOfMaps property for this object. + * + * @param listOfMaps + * The new value for the ListOfMaps property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfMaps(Map... listOfMaps); + + /** + * Sets the value of the ListOfStructs property for this object. + * + * @param listOfStructs + * The new value for the ListOfStructs property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfStructs(Collection listOfStructs); + + /** + * Sets the value of the ListOfStructs property for this object. + * + * @param listOfStructs + * The new value for the ListOfStructs property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfStructs(SimpleStruct... listOfStructs); + + /** + * Sets the value of the ListOfStructs property for this object. + * + * This is a convenience that creates an instance of the {@link List.Builder} avoiding the need to + * create one manually via {@link List#builder()}. + * + * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and its + * result is passed to {@link #listOfStructs(List)}. + * + * @param listOfStructs + * a consumer that will call methods on {@link List.Builder} + * @return Returns a reference to this object so that method calls can be chained together. + * @see #listOfStructs(List) + */ + Builder listOfStructs(Consumer... listOfStructs); + + /** + * Sets the value of the MapOfStringToIntegerList property for this object. + * + * @param mapOfStringToIntegerList + * The new value for the MapOfStringToIntegerList property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToIntegerList(Map> mapOfStringToIntegerList); + + /** + * Sets the value of the MapOfStringToString property for this object. + * + * @param mapOfStringToString + * The new value for the MapOfStringToString property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToString(Map mapOfStringToString); + + /** + * Sets the value of the MapOfStringToSimpleStruct property for this object. + * + * @param mapOfStringToSimpleStruct + * The new value for the MapOfStringToSimpleStruct property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToSimpleStruct(Map mapOfStringToSimpleStruct); + + /** + * Sets the value of the MapOfEnumToEnum property for this object. + * + * @param mapOfEnumToEnum + * The new value for the MapOfEnumToEnum property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfEnumToEnum(Map mapOfEnumToEnum); + + /** + * Sets the value of the MapOfEnumToString property for this object. + * + * @param mapOfEnumToString + * The new value for the MapOfEnumToString property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfEnumToString(Map mapOfEnumToString); + + /** + * Sets the value of the MapOfStringToEnum property for this object. + * + * @param mapOfStringToEnum + * The new value for the MapOfStringToEnum property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToEnum(Map mapOfStringToEnum); + + /** + * Sets the value of the MapOfEnumToSimpleStruct property for this object. + * + * @param mapOfEnumToSimpleStruct + * The new value for the MapOfEnumToSimpleStruct property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfEnumToSimpleStruct(Map mapOfEnumToSimpleStruct); + + /** + * 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 StructWithNestedTimestampMember property for this object. + * + * @param structWithNestedTimestampMember + * The new value for the StructWithNestedTimestampMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder structWithNestedTimestampMember(StructWithTimestamp structWithNestedTimestampMember); + + /** + * Sets the value of the StructWithNestedTimestampMember property for this object. + * + * This is a convenience that creates an instance of the {@link StructWithTimestamp.Builder} avoiding the need + * to create one manually via {@link StructWithTimestamp#builder()}. + * + * 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. + * @see #structWithNestedTimestampMember(StructWithTimestamp) + */ + default Builder structWithNestedTimestampMember(Consumer structWithNestedTimestampMember) { + return structWithNestedTimestampMember(StructWithTimestamp.builder().apply(structWithNestedTimestampMember).build()); + } + + /** + * Sets the value of the BlobArg property for this object. + *

+ * To preserve immutability, the remaining bytes in the provided buffer will be copied into a new buffer when + * set. + *

+ * + * @param blobArg + * The new value for the BlobArg property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder blobArg(ByteBuffer blobArg); + + Builder blobArg(String blobArg); + + /** + * Sets the value of the StructWithNestedBlob property for this object. + * + * @param structWithNestedBlob + * The new value for the StructWithNestedBlob property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder structWithNestedBlob(StructWithNestedBlobType structWithNestedBlob); + + /** + * Sets the value of the StructWithNestedBlob property for this object. + * + * This is a convenience that creates an instance of the {@link StructWithNestedBlobType.Builder} avoiding the + * need to create one manually via {@link StructWithNestedBlobType#builder()}. + * + * 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. + * @see #structWithNestedBlob(StructWithNestedBlobType) + */ + default Builder structWithNestedBlob(Consumer structWithNestedBlob) { + return structWithNestedBlob(StructWithNestedBlobType.builder().apply(structWithNestedBlob).build()); + } + + /** + * Sets the value of the BlobMap property for this object. + * + * @param blobMap + * The new value for the BlobMap property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder blobMap(Map blobMap); + + /** + * Sets the value of the ListOfBlobs property for this object. + * + * @param listOfBlobs + * The new value for the ListOfBlobs property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfBlobs(Collection listOfBlobs); + + /** + * Sets the value of the ListOfBlobs property for this object. + * + * @param listOfBlobs + * The new value for the ListOfBlobs property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfBlobs(ByteBuffer... listOfBlobs); + + /** + * Sets the value of the RecursiveStruct property for this object. + * + * @param recursiveStruct + * The new value for the RecursiveStruct property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder recursiveStruct(RecursiveStructType recursiveStruct); + + /** + * Sets the value of the RecursiveStruct property for this object. + * + * This is a convenience that creates an instance of the {@link RecursiveStructType.Builder} avoiding the need + * to create one manually via {@link RecursiveStructType#builder()}. + * + * 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. + * @see #recursiveStruct(RecursiveStructType) + */ + default Builder recursiveStruct(Consumer recursiveStruct) { + return recursiveStruct(RecursiveStructType.builder().apply(recursiveStruct).build()); + } + + /** + * Sets the value of the PolymorphicTypeWithSubTypes property for this object. + * + * @param polymorphicTypeWithSubTypes + * The new value for the PolymorphicTypeWithSubTypes property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder polymorphicTypeWithSubTypes(BaseType polymorphicTypeWithSubTypes); + + /** + * Sets the value of the PolymorphicTypeWithSubTypes property for this object. + * + * This is a convenience that creates an instance of the {@link BaseType.Builder} avoiding the need to create + * one manually via {@link BaseType#builder()}. + * + * 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. + * @see #polymorphicTypeWithSubTypes(BaseType) + */ + default Builder polymorphicTypeWithSubTypes(Consumer polymorphicTypeWithSubTypes) { + return polymorphicTypeWithSubTypes(BaseType.builder().apply(polymorphicTypeWithSubTypes).build()); + } + + /** + * Sets the value of the PolymorphicTypeWithoutSubTypes property for this object. + * + * @param polymorphicTypeWithoutSubTypes + * The new value for the PolymorphicTypeWithoutSubTypes property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWithoutSubTypes); + + /** + * Sets the value of the PolymorphicTypeWithoutSubTypes property for this object. + * + * This is a convenience that creates an instance of the {@link SubTypeOne.Builder} avoiding the need to create + * one manually via {@link SubTypeOne#builder()}. + * + * 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. + * @see #polymorphicTypeWithoutSubTypes(SubTypeOne) + */ + default Builder polymorphicTypeWithoutSubTypes(Consumer polymorphicTypeWithoutSubTypes) { + return polymorphicTypeWithoutSubTypes(SubTypeOne.builder().apply(polymorphicTypeWithoutSubTypes).build()); + } + + /** + * Sets the value of the EnumType property for this object. + * + * @param enumType + * The new value for the EnumType property for this object. + * @see EnumType + * @return Returns a reference to this object so that method calls can be chained together. + * @see EnumType + */ + Builder enumType(String enumType); + + /** + * Sets the value of the EnumType property for this object. + * + * @param enumType + * The new value for the EnumType property for this object. + * @see EnumType + * @return Returns a reference to this object so that method calls can be chained together. + * @see EnumType + */ + Builder enumType(EnumType enumType); + + @Override + Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); + + @Override + Builder overrideConfiguration(Consumer builderConsumer); + } + + static final class BuilderImpl extends JsonProtocolTestsRequest.BuilderImpl implements Builder { + private String stringMember; + + private Integer integerMember; + + private Boolean booleanMember; + + private Float floatMember; + + private Double doubleMember; + + private Long longMember; + + private List simpleList; + + private List listOfEnums; + + private List> listOfMaps; + + private List listOfStructs; + + private Map> mapOfStringToIntegerList; + + private Map mapOfStringToString; + + private Map mapOfStringToSimpleStruct; + + private Map mapOfEnumToEnum; + + private Map mapOfEnumToString; + + private Map mapOfStringToEnum; + + private Map mapOfEnumToSimpleStruct; + + private Instant timestampMember; + + private StructWithTimestamp structWithNestedTimestampMember; + + private ByteBuffer blobArg; + + private StructWithNestedBlobType structWithNestedBlob; + + private Map blobMap; + + private List listOfBlobs; + + private RecursiveStructType recursiveStruct; + + private BaseType polymorphicTypeWithSubTypes; + + private SubTypeOne polymorphicTypeWithoutSubTypes; + + private String enumType; + + private BuilderImpl() { + } + + private BuilderImpl(AllTypesRequest model) { + super(model); + stringMember(model.stringMember); + integerMember(model.integerMember); + booleanMember(model.booleanMember); + floatMember(model.floatMember); + doubleMember(model.doubleMember); + longMember(model.longMember); + simpleList(model.simpleList); + listOfEnums(model.listOfEnums); + listOfMaps(model.listOfMaps); + listOfStructs(model.listOfStructs); + mapOfStringToIntegerList(model.mapOfStringToIntegerList); + mapOfStringToString(model.mapOfStringToString); + mapOfStringToSimpleStruct(model.mapOfStringToSimpleStruct); + mapOfEnumToEnum(model.mapOfEnumToEnum); + mapOfEnumToString(model.mapOfEnumToString); + mapOfStringToEnum(model.mapOfStringToEnum); + mapOfEnumToSimpleStruct(model.mapOfEnumToSimpleStruct); + timestampMember(model.timestampMember); + structWithNestedTimestampMember(model.structWithNestedTimestampMember); + blobArg(model.blobArg); + structWithNestedBlob(model.structWithNestedBlob); + blobMap(model.blobMap); + listOfBlobs(model.listOfBlobs); + recursiveStruct(model.recursiveStruct); + polymorphicTypeWithSubTypes(model.polymorphicTypeWithSubTypes); + polymorphicTypeWithoutSubTypes(model.polymorphicTypeWithoutSubTypes); + enumType(model.enumType); + } + + public final String getStringMember() { + return stringMember; + } + + @Override + public final Builder stringMember(String stringMember) { + this.stringMember = stringMember; + return this; + } + + public final void setStringMember(String stringMember) { + this.stringMember = stringMember; + } + + public final Integer getIntegerMember() { + return integerMember; + } + + @Override + public final Builder integerMember(Integer integerMember) { + this.integerMember = integerMember; + return this; + } + + public final void setIntegerMember(Integer integerMember) { + this.integerMember = integerMember; + } + + public final Boolean getBooleanMember() { + return booleanMember; + } + + @Override + public final Builder booleanMember(Boolean booleanMember) { + this.booleanMember = booleanMember; + return this; + } + + public final void setBooleanMember(Boolean booleanMember) { + this.booleanMember = booleanMember; + } + + public final Float getFloatMember() { + return floatMember; + } + + @Override + public final Builder floatMember(Float floatMember) { + this.floatMember = floatMember; + return this; + } + + public final void setFloatMember(Float floatMember) { + this.floatMember = floatMember; + } + + public final Double getDoubleMember() { + return doubleMember; + } + + @Override + public final Builder doubleMember(Double doubleMember) { + this.doubleMember = doubleMember; + return this; + } + + public final void setDoubleMember(Double doubleMember) { + this.doubleMember = doubleMember; + } + + public final Long getLongMember() { + return longMember; + } + + @Override + public final Builder longMember(Long longMember) { + this.longMember = longMember; + return this; + } + + public final void setLongMember(Long longMember) { + this.longMember = longMember; + } + + public final Collection getSimpleList() { + return simpleList; + } + + @Override + public final Builder simpleList(Collection simpleList) { + this.simpleList = ListOfStringsCopier.copy(simpleList); + return this; + } + + @Override + @SafeVarargs + public final Builder simpleList(String... simpleList) { + simpleList(Arrays.asList(simpleList)); + return this; + } + + public final void setSimpleList(Collection simpleList) { + this.simpleList = ListOfStringsCopier.copy(simpleList); + } + + public final Collection getListOfEnums() { + return listOfEnums; + } + + @Override + public final Builder listOfEnums(Collection listOfEnums) { + this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfEnums(String... listOfEnums) { + listOfEnums(Arrays.asList(listOfEnums)); + return this; + } + + public final void setListOfEnums(Collection listOfEnums) { + this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums); + } + + public final Collection> getListOfMaps() { + return listOfMaps; + } + + @Override + public final Builder listOfMaps(Collection> listOfMaps) { + this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfMaps(Map... listOfMaps) { + listOfMaps(Arrays.asList(listOfMaps)); + return this; + } + + public final void setListOfMaps(Collection> listOfMaps) { + this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps); + } + + public final Collection getListOfStructs() { + return listOfStructs != null ? listOfStructs.stream().map(SimpleStruct::toBuilder).collect(Collectors.toList()) + : null; + } + + @Override + public final Builder listOfStructs(Collection listOfStructs) { + this.listOfStructs = ListOfSimpleStructsCopier.copy(listOfStructs); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfStructs(SimpleStruct... listOfStructs) { + listOfStructs(Arrays.asList(listOfStructs)); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfStructs(Consumer... listOfStructs) { + listOfStructs(Stream.of(listOfStructs).map(c -> SimpleStruct.builder().apply(c).build()).collect(Collectors.toList())); + return this; + } + + public final void setListOfStructs(Collection listOfStructs) { + this.listOfStructs = ListOfSimpleStructsCopier.copyFromBuilder(listOfStructs); + } + + public final Map> getMapOfStringToIntegerList() { + return mapOfStringToIntegerList; + } + + @Override + public final Builder mapOfStringToIntegerList(Map> mapOfStringToIntegerList) { + this.mapOfStringToIntegerList = MapOfStringToIntegerListCopier.copy(mapOfStringToIntegerList); + return this; + } + + public final void setMapOfStringToIntegerList(Map> mapOfStringToIntegerList) { + this.mapOfStringToIntegerList = MapOfStringToIntegerListCopier.copy(mapOfStringToIntegerList); + } + + public final Map getMapOfStringToString() { + return mapOfStringToString; + } + + @Override + public final Builder mapOfStringToString(Map mapOfStringToString) { + this.mapOfStringToString = MapOfStringToStringCopier.copy(mapOfStringToString); + return this; + } + + public final void setMapOfStringToString(Map mapOfStringToString) { + this.mapOfStringToString = MapOfStringToStringCopier.copy(mapOfStringToString); + } + + public final Map getMapOfStringToSimpleStruct() { + return mapOfStringToSimpleStruct != null ? CollectionUtils.mapValues(mapOfStringToSimpleStruct, + SimpleStruct::toBuilder) : null; + } + + @Override + public final Builder mapOfStringToSimpleStruct(Map mapOfStringToSimpleStruct) { + this.mapOfStringToSimpleStruct = MapOfStringToSimpleStructCopier.copy(mapOfStringToSimpleStruct); + return this; + } + + public final void setMapOfStringToSimpleStruct(Map mapOfStringToSimpleStruct) { + this.mapOfStringToSimpleStruct = MapOfStringToSimpleStructCopier.copyFromBuilder(mapOfStringToSimpleStruct); + } + + public final Map getMapOfEnumToEnum() { + return mapOfEnumToEnum; + } + + @Override + public final Builder mapOfEnumToEnum(Map mapOfEnumToEnum) { + this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copy(mapOfEnumToEnum); + return this; + } + + public final void setMapOfEnumToEnum(Map mapOfEnumToEnum) { + this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copy(mapOfEnumToEnum); + } + + public final Map getMapOfEnumToString() { + return mapOfEnumToString; + } + + @Override + public final Builder mapOfEnumToString(Map mapOfEnumToString) { + this.mapOfEnumToString = MapOfEnumToStringCopier.copy(mapOfEnumToString); + return this; + } + + public final void setMapOfEnumToString(Map mapOfEnumToString) { + this.mapOfEnumToString = MapOfEnumToStringCopier.copy(mapOfEnumToString); + } + + public final Map getMapOfStringToEnum() { + return mapOfStringToEnum; + } + + @Override + public final Builder mapOfStringToEnum(Map mapOfStringToEnum) { + this.mapOfStringToEnum = MapOfStringToEnumCopier.copy(mapOfStringToEnum); + return this; + } + + public final void setMapOfStringToEnum(Map mapOfStringToEnum) { + this.mapOfStringToEnum = MapOfStringToEnumCopier.copy(mapOfStringToEnum); + } + + public final Map getMapOfEnumToSimpleStruct() { + return mapOfEnumToSimpleStruct != null ? CollectionUtils.mapValues(mapOfEnumToSimpleStruct, SimpleStruct::toBuilder) + : null; + } + + @Override + public final Builder mapOfEnumToSimpleStruct(Map mapOfEnumToSimpleStruct) { + this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copy(mapOfEnumToSimpleStruct); + return this; + } + + public final void setMapOfEnumToSimpleStruct(Map mapOfEnumToSimpleStruct) { + this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copyFromBuilder(mapOfEnumToSimpleStruct); + } + + public final Instant getTimestampMember() { + return timestampMember; + } + + @Override + public final Builder timestampMember(Instant timestampMember) { + this.timestampMember = timestampMember; + return this; + } + + public final void setTimestampMember(Instant timestampMember) { + this.timestampMember = timestampMember; + } + + public final StructWithTimestamp.Builder getStructWithNestedTimestampMember() { + return structWithNestedTimestampMember != null ? structWithNestedTimestampMember.toBuilder() : null; + } + + @Override + public final Builder structWithNestedTimestampMember(StructWithTimestamp structWithNestedTimestampMember) { + this.structWithNestedTimestampMember = structWithNestedTimestampMember; + return this; + } + + public final void setStructWithNestedTimestampMember(StructWithTimestamp.BuilderImpl structWithNestedTimestampMember) { + this.structWithNestedTimestampMember = structWithNestedTimestampMember != null ? structWithNestedTimestampMember + .build() : null; + } + + public final ByteBuffer getBlobArg() { + return blobArg; + } + + @Override + public final Builder blobArg(ByteBuffer blobArg) { + this.blobArg = StandardMemberCopier.copy(blobArg); + return this; + } + + public final void setBlobArg(ByteBuffer blobArg) { + this.blobArg = StandardMemberCopier.copy(blobArg); + } + + public Builder blobArg(String blobArg) { + blobArg(new StringToByteBufferAdapter().adapt(blobArg)); + return this; + } + + public void setBlobArg(String blobArg) { + this.blobArg = new StringToByteBufferAdapter().adapt(blobArg); + } + + public final StructWithNestedBlobType.Builder getStructWithNestedBlob() { + return structWithNestedBlob != null ? structWithNestedBlob.toBuilder() : null; + } + + @Override + public final Builder structWithNestedBlob(StructWithNestedBlobType structWithNestedBlob) { + this.structWithNestedBlob = structWithNestedBlob; + return this; + } + + public final void setStructWithNestedBlob(StructWithNestedBlobType.BuilderImpl structWithNestedBlob) { + this.structWithNestedBlob = structWithNestedBlob != null ? structWithNestedBlob.build() : null; + } + + public final Map getBlobMap() { + return blobMap; + } + + @Override + public final Builder blobMap(Map blobMap) { + this.blobMap = BlobMapTypeCopier.copy(blobMap); + return this; + } + + public final void setBlobMap(Map blobMap) { + this.blobMap = BlobMapTypeCopier.copy(blobMap); + } + + public final Collection getListOfBlobs() { + return listOfBlobs; + } + + @Override + public final Builder listOfBlobs(Collection listOfBlobs) { + this.listOfBlobs = ListOfBlobsTypeCopier.copy(listOfBlobs); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfBlobs(ByteBuffer... listOfBlobs) { + listOfBlobs(Arrays.asList(listOfBlobs)); + return this; + } + + public final void setListOfBlobs(Collection listOfBlobs) { + this.listOfBlobs = ListOfBlobsTypeCopier.copy(listOfBlobs); + } + + public final RecursiveStructType.Builder getRecursiveStruct() { + return recursiveStruct != null ? recursiveStruct.toBuilder() : null; + } + + @Override + public final Builder recursiveStruct(RecursiveStructType recursiveStruct) { + this.recursiveStruct = recursiveStruct; + return this; + } + + public final void setRecursiveStruct(RecursiveStructType.BuilderImpl recursiveStruct) { + this.recursiveStruct = recursiveStruct != null ? recursiveStruct.build() : null; + } + + public final BaseType.Builder getPolymorphicTypeWithSubTypes() { + return polymorphicTypeWithSubTypes != null ? polymorphicTypeWithSubTypes.toBuilder() : null; + } + + @Override + public final Builder polymorphicTypeWithSubTypes(BaseType polymorphicTypeWithSubTypes) { + this.polymorphicTypeWithSubTypes = polymorphicTypeWithSubTypes; + return this; + } + + public final void setPolymorphicTypeWithSubTypes(BaseType.BuilderImpl polymorphicTypeWithSubTypes) { + this.polymorphicTypeWithSubTypes = polymorphicTypeWithSubTypes != null ? polymorphicTypeWithSubTypes.build() : null; + } + + public final SubTypeOne.Builder getPolymorphicTypeWithoutSubTypes() { + return polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.toBuilder() : null; + } + + @Override + public final Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWithoutSubTypes) { + this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes; + return this; + } + + public final void setPolymorphicTypeWithoutSubTypes(SubTypeOne.BuilderImpl polymorphicTypeWithoutSubTypes) { + this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.build() + : null; + } + + public final String getEnumType() { + return enumType; + } + + @Override + public final Builder enumType(String enumType) { + this.enumType = enumType; + return this; + } + + @Override + public final Builder enumType(EnumType enumType) { + this.enumType(enumType.toString()); + return this; + } + + public final void setEnumType(String enumType) { + this.enumType = enumType; + } + + @Override + public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { + super.overrideConfiguration(overrideConfiguration); + return this; + } + + @Override + public Builder overrideConfiguration(Consumer builderConsumer) { + super.overrideConfiguration(builderConsumer); + return this; + } + + @Override + public AllTypesRequest build() { + return new AllTypesRequest(this); + } + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/alltypesresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/alltypesresponse.java new file mode 100644 index 000000000000..59369b81cf2e --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/alltypesresponse.java @@ -0,0 +1,1592 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import java.nio.ByteBuffer; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.annotation.Generated; +import software.amazon.awssdk.core.runtime.StandardMemberCopier; +import software.amazon.awssdk.core.runtime.TypeConverter; +import software.amazon.awssdk.core.runtime.adapters.types.StringToByteBufferAdapter; +import software.amazon.awssdk.utils.CollectionUtils; +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 AllTypesResponse extends JsonProtocolTestsResponse implements + ToCopyableBuilder { + private final String stringMember; + + private final Integer integerMember; + + private final Boolean booleanMember; + + private final Float floatMember; + + private final Double doubleMember; + + private final Long longMember; + + private final List simpleList; + + private final List listOfEnums; + + private final List> listOfMaps; + + private final List listOfStructs; + + private final Map> mapOfStringToIntegerList; + + private final Map mapOfStringToString; + + private final Map mapOfStringToSimpleStruct; + + private final Map mapOfEnumToEnum; + + private final Map mapOfEnumToString; + + private final Map mapOfStringToEnum; + + private final Map mapOfEnumToSimpleStruct; + + private final Instant timestampMember; + + private final StructWithTimestamp structWithNestedTimestampMember; + + private final ByteBuffer blobArg; + + private final StructWithNestedBlobType structWithNestedBlob; + + private final Map blobMap; + + private final List listOfBlobs; + + private final RecursiveStructType recursiveStruct; + + private final BaseType polymorphicTypeWithSubTypes; + + private final SubTypeOne polymorphicTypeWithoutSubTypes; + + private final String enumType; + + private AllTypesResponse(BuilderImpl builder) { + super(builder); + this.stringMember = builder.stringMember; + this.integerMember = builder.integerMember; + this.booleanMember = builder.booleanMember; + this.floatMember = builder.floatMember; + this.doubleMember = builder.doubleMember; + this.longMember = builder.longMember; + this.simpleList = builder.simpleList; + this.listOfEnums = builder.listOfEnums; + this.listOfMaps = builder.listOfMaps; + this.listOfStructs = builder.listOfStructs; + this.mapOfStringToIntegerList = builder.mapOfStringToIntegerList; + this.mapOfStringToString = builder.mapOfStringToString; + this.mapOfStringToSimpleStruct = builder.mapOfStringToSimpleStruct; + this.mapOfEnumToEnum = builder.mapOfEnumToEnum; + this.mapOfEnumToString = builder.mapOfEnumToString; + this.mapOfStringToEnum = builder.mapOfStringToEnum; + this.mapOfEnumToSimpleStruct = builder.mapOfEnumToSimpleStruct; + this.timestampMember = builder.timestampMember; + this.structWithNestedTimestampMember = builder.structWithNestedTimestampMember; + this.blobArg = builder.blobArg; + this.structWithNestedBlob = builder.structWithNestedBlob; + this.blobMap = builder.blobMap; + this.listOfBlobs = builder.listOfBlobs; + this.recursiveStruct = builder.recursiveStruct; + this.polymorphicTypeWithSubTypes = builder.polymorphicTypeWithSubTypes; + this.polymorphicTypeWithoutSubTypes = builder.polymorphicTypeWithoutSubTypes; + this.enumType = builder.enumType; + } + + /** + * 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 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 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 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 SimpleList property for this object. + *

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

+ * + * @return The value of the SimpleList property for this object. + */ + public List simpleList() { + return simpleList; + } + + /** + * Returns the value of the ListOfEnums property for this object. + *

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

+ * + * @return The value of the ListOfEnums property for this object. + */ + public List listOfEnums() { + return TypeConverter.convert(listOfEnums, EnumType::fromValue); + } + + /** + * Returns the value of the ListOfEnums property for this object. + *

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

+ * + * @return The value of the ListOfEnums property for this object. + */ + public List listOfEnumsAsStrings() { + return listOfEnums; + } + + /** + * Returns the value of the ListOfMaps property for this object. + *

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

+ * + * @return The value of the ListOfMaps property for this object. + */ + public List> listOfMaps() { + return listOfMaps; + } + + /** + * Returns the value of the ListOfStructs property for this object. + *

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

+ * + * @return The value of the ListOfStructs property for this object. + */ + public List listOfStructs() { + return listOfStructs; + } + + /** + * Returns the value of the MapOfStringToIntegerList property for this object. + *

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

+ * + * @return The value of the MapOfStringToIntegerList property for this object. + */ + public Map> mapOfStringToIntegerList() { + return mapOfStringToIntegerList; + } + + /** + * Returns the value of the MapOfStringToString property for this object. + *

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

+ * + * @return The value of the MapOfStringToString property for this object. + */ + public Map mapOfStringToString() { + return mapOfStringToString; + } + + /** + * Returns the value of the MapOfStringToSimpleStruct property for this object. + *

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

+ * + * @return The value of the MapOfStringToSimpleStruct property for this object. + */ + public Map mapOfStringToSimpleStruct() { + return mapOfStringToSimpleStruct; + } + + /** + * Returns the value of the MapOfEnumToEnum property for this object. + *

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

+ * + * @return The value of the MapOfEnumToEnum property for this object. + */ + public Map mapOfEnumToEnum() { + return TypeConverter.convert(mapOfEnumToEnum, EnumType::fromValue, EnumType::fromValue, + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + } + + /** + * Returns the value of the MapOfEnumToEnum property for this object. + *

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

+ * + * @return The value of the MapOfEnumToEnum property for this object. + */ + public Map mapOfEnumToEnumAsStrings() { + return mapOfEnumToEnum; + } + + /** + * Returns the value of the MapOfEnumToString property for this object. + *

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

+ * + * @return The value of the MapOfEnumToString property for this object. + */ + public Map mapOfEnumToString() { + return TypeConverter.convert(mapOfEnumToString, EnumType::fromValue, Function.identity(), + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + } + + /** + * Returns the value of the MapOfEnumToString property for this object. + *

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

+ * + * @return The value of the MapOfEnumToString property for this object. + */ + public Map mapOfEnumToStringAsStrings() { + return mapOfEnumToString; + } + + /** + * Returns the value of the MapOfStringToEnum property for this object. + *

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

+ * + * @return The value of the MapOfStringToEnum property for this object. + */ + public Map mapOfStringToEnum() { + return TypeConverter.convert(mapOfStringToEnum, Function.identity(), EnumType::fromValue, (k, v) -> true); + } + + /** + * Returns the value of the MapOfStringToEnum property for this object. + *

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

+ * + * @return The value of the MapOfStringToEnum property for this object. + */ + public Map mapOfStringToEnumAsStrings() { + return mapOfStringToEnum; + } + + /** + * Returns the value of the MapOfEnumToSimpleStruct property for this object. + *

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

+ * + * @return The value of the MapOfEnumToSimpleStruct property for this object. + */ + public Map mapOfEnumToSimpleStruct() { + return TypeConverter.convert(mapOfEnumToSimpleStruct, EnumType::fromValue, Function.identity(), + (k, v) -> !Objects.equals(k, EnumType.UNKNOWN_TO_SDK_VERSION)); + } + + /** + * Returns the value of the MapOfEnumToSimpleStruct property for this object. + *

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

+ * + * @return The value of the MapOfEnumToSimpleStruct property for this object. + */ + public Map mapOfEnumToSimpleStructAsStrings() { + return mapOfEnumToSimpleStruct; + } + + /** + * 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 StructWithNestedTimestampMember property for this object. + * + * @return The value of the StructWithNestedTimestampMember property for this object. + */ + public StructWithTimestamp structWithNestedTimestampMember() { + return structWithNestedTimestampMember; + } + + /** + * Returns the value of the BlobArg property for this object. + *

+ * This method will return a new read-only {@code ByteBuffer} each time it is invoked. + *

+ * + * @return The value of the BlobArg property for this object. + */ + public ByteBuffer blobArg() { + return blobArg == null ? null : blobArg.asReadOnlyBuffer(); + } + + /** + * Returns the value of the StructWithNestedBlob property for this object. + * + * @return The value of the StructWithNestedBlob property for this object. + */ + public StructWithNestedBlobType structWithNestedBlob() { + return structWithNestedBlob; + } + + /** + * Returns the value of the BlobMap property for this object. + *

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

+ * + * @return The value of the BlobMap property for this object. + */ + public Map blobMap() { + return blobMap; + } + + /** + * Returns the value of the ListOfBlobs property for this object. + *

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

+ * + * @return The value of the ListOfBlobs property for this object. + */ + public List listOfBlobs() { + return listOfBlobs; + } + + /** + * Returns the value of the RecursiveStruct property for this object. + * + * @return The value of the RecursiveStruct property for this object. + */ + public RecursiveStructType recursiveStruct() { + return recursiveStruct; + } + + /** + * Returns the value of the PolymorphicTypeWithSubTypes property for this object. + * + * @return The value of the PolymorphicTypeWithSubTypes property for this object. + */ + public BaseType polymorphicTypeWithSubTypes() { + return polymorphicTypeWithSubTypes; + } + + /** + * Returns the value of the PolymorphicTypeWithoutSubTypes property for this object. + * + * @return The value of the PolymorphicTypeWithoutSubTypes property for this object. + */ + public SubTypeOne polymorphicTypeWithoutSubTypes() { + return polymorphicTypeWithoutSubTypes; + } + + /** + * Returns the value of the EnumType property for this object. + *

+ * If the service returns an enum value that is not available in the current SDK version, {@link #enumType} will + * 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 + */ + public EnumType enumType() { + return EnumType.fromValue(enumType); + } + + /** + * Returns the value of the EnumType property for this object. + *

+ * If the service returns an enum value that is not available in the current SDK version, {@link #enumType} will + * 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 + */ + public String enumTypeAsString() { + return enumType; + } + + @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 + Objects.hashCode(stringMember()); + hashCode = 31 * hashCode + Objects.hashCode(integerMember()); + hashCode = 31 * hashCode + Objects.hashCode(booleanMember()); + hashCode = 31 * hashCode + Objects.hashCode(floatMember()); + hashCode = 31 * hashCode + Objects.hashCode(doubleMember()); + hashCode = 31 * hashCode + Objects.hashCode(longMember()); + hashCode = 31 * hashCode + Objects.hashCode(simpleList()); + hashCode = 31 * hashCode + Objects.hashCode(listOfEnumsAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(listOfMaps()); + hashCode = 31 * hashCode + Objects.hashCode(listOfStructs()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToIntegerList()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToString()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToSimpleStruct()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToEnumAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToStringAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToEnumAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToSimpleStructAsStrings()); + hashCode = 31 * hashCode + Objects.hashCode(timestampMember()); + hashCode = 31 * hashCode + Objects.hashCode(structWithNestedTimestampMember()); + hashCode = 31 * hashCode + Objects.hashCode(blobArg()); + hashCode = 31 * hashCode + Objects.hashCode(structWithNestedBlob()); + hashCode = 31 * hashCode + Objects.hashCode(blobMap()); + hashCode = 31 * hashCode + Objects.hashCode(listOfBlobs()); + hashCode = 31 * hashCode + Objects.hashCode(recursiveStruct()); + hashCode = 31 * hashCode + Objects.hashCode(polymorphicTypeWithSubTypes()); + hashCode = 31 * hashCode + Objects.hashCode(polymorphicTypeWithoutSubTypes()); + hashCode = 31 * hashCode + Objects.hashCode(enumTypeAsString()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof AllTypesResponse)) { + return false; + } + AllTypesResponse other = (AllTypesResponse) 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(simpleList(), other.simpleList()) + && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) + && Objects.equals(listOfMaps(), other.listOfMaps()) && Objects.equals(listOfStructs(), other.listOfStructs()) + && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) + && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) + && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) + && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) + && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) + && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) + && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) + && Objects.equals(timestampMember(), other.timestampMember()) + && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) + && Objects.equals(blobArg(), other.blobArg()) + && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) + && Objects.equals(blobMap(), other.blobMap()) && 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()); + } + + @Override + public String toString() { + return ToString.builder("AllTypesResponse").add("StringMember", stringMember()).add("IntegerMember", integerMember()) + .add("BooleanMember", booleanMember()).add("FloatMember", floatMember()).add("DoubleMember", doubleMember()) + .add("LongMember", longMember()).add("SimpleList", simpleList()).add("ListOfEnums", listOfEnumsAsStrings()) + .add("ListOfMaps", listOfMaps()).add("ListOfStructs", listOfStructs()) + .add("MapOfStringToIntegerList", mapOfStringToIntegerList()).add("MapOfStringToString", mapOfStringToString()) + .add("MapOfStringToSimpleStruct", mapOfStringToSimpleStruct()).add("MapOfEnumToEnum", mapOfEnumToEnumAsStrings()) + .add("MapOfEnumToString", mapOfEnumToStringAsStrings()).add("MapOfStringToEnum", mapOfStringToEnumAsStrings()) + .add("MapOfEnumToSimpleStruct", mapOfEnumToSimpleStructAsStrings()).add("TimestampMember", timestampMember()) + .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) + .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", blobMap()).add("ListOfBlobs", listOfBlobs()) + .add("RecursiveStruct", recursiveStruct()).add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) + .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) + .build(); + } + + public Optional getValueForField(String fieldName, Class clazz) { + switch (fieldName) { + case "StringMember": + return Optional.of(clazz.cast(stringMember())); + case "IntegerMember": + return Optional.of(clazz.cast(integerMember())); + case "BooleanMember": + return Optional.of(clazz.cast(booleanMember())); + case "FloatMember": + return Optional.of(clazz.cast(floatMember())); + case "DoubleMember": + return Optional.of(clazz.cast(doubleMember())); + case "LongMember": + return Optional.of(clazz.cast(longMember())); + case "SimpleList": + return Optional.of(clazz.cast(simpleList())); + case "ListOfEnums": + return Optional.of(clazz.cast(listOfEnumsAsStrings())); + case "ListOfMaps": + return Optional.of(clazz.cast(listOfMaps())); + case "ListOfStructs": + return Optional.of(clazz.cast(listOfStructs())); + case "MapOfStringToIntegerList": + return Optional.of(clazz.cast(mapOfStringToIntegerList())); + case "MapOfStringToString": + return Optional.of(clazz.cast(mapOfStringToString())); + case "MapOfStringToSimpleStruct": + return Optional.of(clazz.cast(mapOfStringToSimpleStruct())); + case "MapOfEnumToEnum": + return Optional.of(clazz.cast(mapOfEnumToEnumAsStrings())); + case "MapOfEnumToString": + return Optional.of(clazz.cast(mapOfEnumToStringAsStrings())); + case "MapOfStringToEnum": + return Optional.of(clazz.cast(mapOfStringToEnumAsStrings())); + case "MapOfEnumToSimpleStruct": + return Optional.of(clazz.cast(mapOfEnumToSimpleStructAsStrings())); + case "TimestampMember": + return Optional.of(clazz.cast(timestampMember())); + case "StructWithNestedTimestampMember": + return Optional.of(clazz.cast(structWithNestedTimestampMember())); + case "BlobArg": + return Optional.of(clazz.cast(blobArg())); + case "StructWithNestedBlob": + return Optional.of(clazz.cast(structWithNestedBlob())); + case "BlobMap": + return Optional.of(clazz.cast(blobMap())); + case "ListOfBlobs": + return Optional.of(clazz.cast(listOfBlobs())); + case "RecursiveStruct": + return Optional.of(clazz.cast(recursiveStruct())); + case "PolymorphicTypeWithSubTypes": + return Optional.of(clazz.cast(polymorphicTypeWithSubTypes())); + case "PolymorphicTypeWithoutSubTypes": + return Optional.of(clazz.cast(polymorphicTypeWithoutSubTypes())); + case "EnumType": + return Optional.of(clazz.cast(enumTypeAsString())); + default: + return Optional.empty(); + } + } + + public interface Builder extends JsonProtocolTestsResponse.Builder, CopyableBuilder { + /** + * 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 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 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 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 SimpleList property for this object. + * + * @param simpleList + * The new value for the SimpleList property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder simpleList(Collection simpleList); + + /** + * Sets the value of the SimpleList property for this object. + * + * @param simpleList + * The new value for the SimpleList property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder simpleList(String... simpleList); + + /** + * Sets the value of the ListOfEnums property for this object. + * + * @param listOfEnums + * The new value for the ListOfEnums property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfEnums(Collection listOfEnums); + + /** + * Sets the value of the ListOfEnums property for this object. + * + * @param listOfEnums + * The new value for the ListOfEnums property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfEnums(String... listOfEnums); + + /** + * Sets the value of the ListOfMaps property for this object. + * + * @param listOfMaps + * The new value for the ListOfMaps property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfMaps(Collection> listOfMaps); + + /** + * Sets the value of the ListOfMaps property for this object. + * + * @param listOfMaps + * The new value for the ListOfMaps property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfMaps(Map... listOfMaps); + + /** + * Sets the value of the ListOfStructs property for this object. + * + * @param listOfStructs + * The new value for the ListOfStructs property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfStructs(Collection listOfStructs); + + /** + * Sets the value of the ListOfStructs property for this object. + * + * @param listOfStructs + * The new value for the ListOfStructs property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfStructs(SimpleStruct... listOfStructs); + + /** + * Sets the value of the ListOfStructs property for this object. + * + * This is a convenience that creates an instance of the {@link List.Builder} avoiding the need to + * create one manually via {@link List#builder()}. + * + * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and its + * result is passed to {@link #listOfStructs(List)}. + * + * @param listOfStructs + * a consumer that will call methods on {@link List.Builder} + * @return Returns a reference to this object so that method calls can be chained together. + * @see #listOfStructs(List) + */ + Builder listOfStructs(Consumer... listOfStructs); + + /** + * Sets the value of the MapOfStringToIntegerList property for this object. + * + * @param mapOfStringToIntegerList + * The new value for the MapOfStringToIntegerList property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToIntegerList(Map> mapOfStringToIntegerList); + + /** + * Sets the value of the MapOfStringToString property for this object. + * + * @param mapOfStringToString + * The new value for the MapOfStringToString property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToString(Map mapOfStringToString); + + /** + * Sets the value of the MapOfStringToSimpleStruct property for this object. + * + * @param mapOfStringToSimpleStruct + * The new value for the MapOfStringToSimpleStruct property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToSimpleStruct(Map mapOfStringToSimpleStruct); + + /** + * Sets the value of the MapOfEnumToEnum property for this object. + * + * @param mapOfEnumToEnum + * The new value for the MapOfEnumToEnum property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfEnumToEnum(Map mapOfEnumToEnum); + + /** + * Sets the value of the MapOfEnumToString property for this object. + * + * @param mapOfEnumToString + * The new value for the MapOfEnumToString property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfEnumToString(Map mapOfEnumToString); + + /** + * Sets the value of the MapOfStringToEnum property for this object. + * + * @param mapOfStringToEnum + * The new value for the MapOfStringToEnum property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToEnum(Map mapOfStringToEnum); + + /** + * Sets the value of the MapOfEnumToSimpleStruct property for this object. + * + * @param mapOfEnumToSimpleStruct + * The new value for the MapOfEnumToSimpleStruct property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfEnumToSimpleStruct(Map mapOfEnumToSimpleStruct); + + /** + * 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 StructWithNestedTimestampMember property for this object. + * + * @param structWithNestedTimestampMember + * The new value for the StructWithNestedTimestampMember property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder structWithNestedTimestampMember(StructWithTimestamp structWithNestedTimestampMember); + + /** + * Sets the value of the StructWithNestedTimestampMember property for this object. + * + * This is a convenience that creates an instance of the {@link StructWithTimestamp.Builder} avoiding the need + * to create one manually via {@link StructWithTimestamp#builder()}. + * + * 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. + * @see #structWithNestedTimestampMember(StructWithTimestamp) + */ + default Builder structWithNestedTimestampMember(Consumer structWithNestedTimestampMember) { + return structWithNestedTimestampMember(StructWithTimestamp.builder().apply(structWithNestedTimestampMember).build()); + } + + /** + * Sets the value of the BlobArg property for this object. + *

+ * To preserve immutability, the remaining bytes in the provided buffer will be copied into a new buffer when + * set. + *

+ * + * @param blobArg + * The new value for the BlobArg property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder blobArg(ByteBuffer blobArg); + + Builder blobArg(String blobArg); + + /** + * Sets the value of the StructWithNestedBlob property for this object. + * + * @param structWithNestedBlob + * The new value for the StructWithNestedBlob property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder structWithNestedBlob(StructWithNestedBlobType structWithNestedBlob); + + /** + * Sets the value of the StructWithNestedBlob property for this object. + * + * This is a convenience that creates an instance of the {@link StructWithNestedBlobType.Builder} avoiding the + * need to create one manually via {@link StructWithNestedBlobType#builder()}. + * + * 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. + * @see #structWithNestedBlob(StructWithNestedBlobType) + */ + default Builder structWithNestedBlob(Consumer structWithNestedBlob) { + return structWithNestedBlob(StructWithNestedBlobType.builder().apply(structWithNestedBlob).build()); + } + + /** + * Sets the value of the BlobMap property for this object. + * + * @param blobMap + * The new value for the BlobMap property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder blobMap(Map blobMap); + + /** + * Sets the value of the ListOfBlobs property for this object. + * + * @param listOfBlobs + * The new value for the ListOfBlobs property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfBlobs(Collection listOfBlobs); + + /** + * Sets the value of the ListOfBlobs property for this object. + * + * @param listOfBlobs + * The new value for the ListOfBlobs property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfBlobs(ByteBuffer... listOfBlobs); + + /** + * Sets the value of the RecursiveStruct property for this object. + * + * @param recursiveStruct + * The new value for the RecursiveStruct property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder recursiveStruct(RecursiveStructType recursiveStruct); + + /** + * Sets the value of the RecursiveStruct property for this object. + * + * This is a convenience that creates an instance of the {@link RecursiveStructType.Builder} avoiding the need + * to create one manually via {@link RecursiveStructType#builder()}. + * + * 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. + * @see #recursiveStruct(RecursiveStructType) + */ + default Builder recursiveStruct(Consumer recursiveStruct) { + return recursiveStruct(RecursiveStructType.builder().apply(recursiveStruct).build()); + } + + /** + * Sets the value of the PolymorphicTypeWithSubTypes property for this object. + * + * @param polymorphicTypeWithSubTypes + * The new value for the PolymorphicTypeWithSubTypes property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder polymorphicTypeWithSubTypes(BaseType polymorphicTypeWithSubTypes); + + /** + * Sets the value of the PolymorphicTypeWithSubTypes property for this object. + * + * This is a convenience that creates an instance of the {@link BaseType.Builder} avoiding the need to create + * one manually via {@link BaseType#builder()}. + * + * 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. + * @see #polymorphicTypeWithSubTypes(BaseType) + */ + default Builder polymorphicTypeWithSubTypes(Consumer polymorphicTypeWithSubTypes) { + return polymorphicTypeWithSubTypes(BaseType.builder().apply(polymorphicTypeWithSubTypes).build()); + } + + /** + * Sets the value of the PolymorphicTypeWithoutSubTypes property for this object. + * + * @param polymorphicTypeWithoutSubTypes + * The new value for the PolymorphicTypeWithoutSubTypes property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWithoutSubTypes); + + /** + * Sets the value of the PolymorphicTypeWithoutSubTypes property for this object. + * + * This is a convenience that creates an instance of the {@link SubTypeOne.Builder} avoiding the need to create + * one manually via {@link SubTypeOne#builder()}. + * + * 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. + * @see #polymorphicTypeWithoutSubTypes(SubTypeOne) + */ + default Builder polymorphicTypeWithoutSubTypes(Consumer polymorphicTypeWithoutSubTypes) { + return polymorphicTypeWithoutSubTypes(SubTypeOne.builder().apply(polymorphicTypeWithoutSubTypes).build()); + } + + /** + * Sets the value of the EnumType property for this object. + * + * @param enumType + * The new value for the EnumType property for this object. + * @see EnumType + * @return Returns a reference to this object so that method calls can be chained together. + * @see EnumType + */ + Builder enumType(String enumType); + + /** + * Sets the value of the EnumType property for this object. + * + * @param enumType + * The new value for the EnumType property for this object. + * @see EnumType + * @return Returns a reference to this object so that method calls can be chained together. + * @see EnumType + */ + Builder enumType(EnumType enumType); + } + + static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl implements Builder { + private String stringMember; + + private Integer integerMember; + + private Boolean booleanMember; + + private Float floatMember; + + private Double doubleMember; + + private Long longMember; + + private List simpleList; + + private List listOfEnums; + + private List> listOfMaps; + + private List listOfStructs; + + private Map> mapOfStringToIntegerList; + + private Map mapOfStringToString; + + private Map mapOfStringToSimpleStruct; + + private Map mapOfEnumToEnum; + + private Map mapOfEnumToString; + + private Map mapOfStringToEnum; + + private Map mapOfEnumToSimpleStruct; + + private Instant timestampMember; + + private StructWithTimestamp structWithNestedTimestampMember; + + private ByteBuffer blobArg; + + private StructWithNestedBlobType structWithNestedBlob; + + private Map blobMap; + + private List listOfBlobs; + + private RecursiveStructType recursiveStruct; + + private BaseType polymorphicTypeWithSubTypes; + + private SubTypeOne polymorphicTypeWithoutSubTypes; + + private String enumType; + + private BuilderImpl() { + } + + private BuilderImpl(AllTypesResponse model) { + super(model); + stringMember(model.stringMember); + integerMember(model.integerMember); + booleanMember(model.booleanMember); + floatMember(model.floatMember); + doubleMember(model.doubleMember); + longMember(model.longMember); + simpleList(model.simpleList); + listOfEnums(model.listOfEnums); + listOfMaps(model.listOfMaps); + listOfStructs(model.listOfStructs); + mapOfStringToIntegerList(model.mapOfStringToIntegerList); + mapOfStringToString(model.mapOfStringToString); + mapOfStringToSimpleStruct(model.mapOfStringToSimpleStruct); + mapOfEnumToEnum(model.mapOfEnumToEnum); + mapOfEnumToString(model.mapOfEnumToString); + mapOfStringToEnum(model.mapOfStringToEnum); + mapOfEnumToSimpleStruct(model.mapOfEnumToSimpleStruct); + timestampMember(model.timestampMember); + structWithNestedTimestampMember(model.structWithNestedTimestampMember); + blobArg(model.blobArg); + structWithNestedBlob(model.structWithNestedBlob); + blobMap(model.blobMap); + listOfBlobs(model.listOfBlobs); + recursiveStruct(model.recursiveStruct); + polymorphicTypeWithSubTypes(model.polymorphicTypeWithSubTypes); + polymorphicTypeWithoutSubTypes(model.polymorphicTypeWithoutSubTypes); + enumType(model.enumType); + } + + public final String getStringMember() { + return stringMember; + } + + @Override + public final Builder stringMember(String stringMember) { + this.stringMember = stringMember; + return this; + } + + public final void setStringMember(String stringMember) { + this.stringMember = stringMember; + } + + public final Integer getIntegerMember() { + return integerMember; + } + + @Override + public final Builder integerMember(Integer integerMember) { + this.integerMember = integerMember; + return this; + } + + public final void setIntegerMember(Integer integerMember) { + this.integerMember = integerMember; + } + + public final Boolean getBooleanMember() { + return booleanMember; + } + + @Override + public final Builder booleanMember(Boolean booleanMember) { + this.booleanMember = booleanMember; + return this; + } + + public final void setBooleanMember(Boolean booleanMember) { + this.booleanMember = booleanMember; + } + + public final Float getFloatMember() { + return floatMember; + } + + @Override + public final Builder floatMember(Float floatMember) { + this.floatMember = floatMember; + return this; + } + + public final void setFloatMember(Float floatMember) { + this.floatMember = floatMember; + } + + public final Double getDoubleMember() { + return doubleMember; + } + + @Override + public final Builder doubleMember(Double doubleMember) { + this.doubleMember = doubleMember; + return this; + } + + public final void setDoubleMember(Double doubleMember) { + this.doubleMember = doubleMember; + } + + public final Long getLongMember() { + return longMember; + } + + @Override + public final Builder longMember(Long longMember) { + this.longMember = longMember; + return this; + } + + public final void setLongMember(Long longMember) { + this.longMember = longMember; + } + + public final Collection getSimpleList() { + return simpleList; + } + + @Override + public final Builder simpleList(Collection simpleList) { + this.simpleList = ListOfStringsCopier.copy(simpleList); + return this; + } + + @Override + @SafeVarargs + public final Builder simpleList(String... simpleList) { + simpleList(Arrays.asList(simpleList)); + return this; + } + + public final void setSimpleList(Collection simpleList) { + this.simpleList = ListOfStringsCopier.copy(simpleList); + } + + public final Collection getListOfEnums() { + return listOfEnums; + } + + @Override + public final Builder listOfEnums(Collection listOfEnums) { + this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfEnums(String... listOfEnums) { + listOfEnums(Arrays.asList(listOfEnums)); + return this; + } + + public final void setListOfEnums(Collection listOfEnums) { + this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums); + } + + public final Collection> getListOfMaps() { + return listOfMaps; + } + + @Override + public final Builder listOfMaps(Collection> listOfMaps) { + this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfMaps(Map... listOfMaps) { + listOfMaps(Arrays.asList(listOfMaps)); + return this; + } + + public final void setListOfMaps(Collection> listOfMaps) { + this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps); + } + + public final Collection getListOfStructs() { + return listOfStructs != null ? listOfStructs.stream().map(SimpleStruct::toBuilder).collect(Collectors.toList()) + : null; + } + + @Override + public final Builder listOfStructs(Collection listOfStructs) { + this.listOfStructs = ListOfSimpleStructsCopier.copy(listOfStructs); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfStructs(SimpleStruct... listOfStructs) { + listOfStructs(Arrays.asList(listOfStructs)); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfStructs(Consumer... listOfStructs) { + listOfStructs(Stream.of(listOfStructs).map(c -> SimpleStruct.builder().apply(c).build()).collect(Collectors.toList())); + return this; + } + + public final void setListOfStructs(Collection listOfStructs) { + this.listOfStructs = ListOfSimpleStructsCopier.copyFromBuilder(listOfStructs); + } + + public final Map> getMapOfStringToIntegerList() { + return mapOfStringToIntegerList; + } + + @Override + public final Builder mapOfStringToIntegerList(Map> mapOfStringToIntegerList) { + this.mapOfStringToIntegerList = MapOfStringToIntegerListCopier.copy(mapOfStringToIntegerList); + return this; + } + + public final void setMapOfStringToIntegerList(Map> mapOfStringToIntegerList) { + this.mapOfStringToIntegerList = MapOfStringToIntegerListCopier.copy(mapOfStringToIntegerList); + } + + public final Map getMapOfStringToString() { + return mapOfStringToString; + } + + @Override + public final Builder mapOfStringToString(Map mapOfStringToString) { + this.mapOfStringToString = MapOfStringToStringCopier.copy(mapOfStringToString); + return this; + } + + public final void setMapOfStringToString(Map mapOfStringToString) { + this.mapOfStringToString = MapOfStringToStringCopier.copy(mapOfStringToString); + } + + public final Map getMapOfStringToSimpleStruct() { + return mapOfStringToSimpleStruct != null ? CollectionUtils.mapValues(mapOfStringToSimpleStruct, + SimpleStruct::toBuilder) : null; + } + + @Override + public final Builder mapOfStringToSimpleStruct(Map mapOfStringToSimpleStruct) { + this.mapOfStringToSimpleStruct = MapOfStringToSimpleStructCopier.copy(mapOfStringToSimpleStruct); + return this; + } + + public final void setMapOfStringToSimpleStruct(Map mapOfStringToSimpleStruct) { + this.mapOfStringToSimpleStruct = MapOfStringToSimpleStructCopier.copyFromBuilder(mapOfStringToSimpleStruct); + } + + public final Map getMapOfEnumToEnum() { + return mapOfEnumToEnum; + } + + @Override + public final Builder mapOfEnumToEnum(Map mapOfEnumToEnum) { + this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copy(mapOfEnumToEnum); + return this; + } + + public final void setMapOfEnumToEnum(Map mapOfEnumToEnum) { + this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copy(mapOfEnumToEnum); + } + + public final Map getMapOfEnumToString() { + return mapOfEnumToString; + } + + @Override + public final Builder mapOfEnumToString(Map mapOfEnumToString) { + this.mapOfEnumToString = MapOfEnumToStringCopier.copy(mapOfEnumToString); + return this; + } + + public final void setMapOfEnumToString(Map mapOfEnumToString) { + this.mapOfEnumToString = MapOfEnumToStringCopier.copy(mapOfEnumToString); + } + + public final Map getMapOfStringToEnum() { + return mapOfStringToEnum; + } + + @Override + public final Builder mapOfStringToEnum(Map mapOfStringToEnum) { + this.mapOfStringToEnum = MapOfStringToEnumCopier.copy(mapOfStringToEnum); + return this; + } + + public final void setMapOfStringToEnum(Map mapOfStringToEnum) { + this.mapOfStringToEnum = MapOfStringToEnumCopier.copy(mapOfStringToEnum); + } + + public final Map getMapOfEnumToSimpleStruct() { + return mapOfEnumToSimpleStruct != null ? CollectionUtils.mapValues(mapOfEnumToSimpleStruct, SimpleStruct::toBuilder) + : null; + } + + @Override + public final Builder mapOfEnumToSimpleStruct(Map mapOfEnumToSimpleStruct) { + this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copy(mapOfEnumToSimpleStruct); + return this; + } + + public final void setMapOfEnumToSimpleStruct(Map mapOfEnumToSimpleStruct) { + this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copyFromBuilder(mapOfEnumToSimpleStruct); + } + + public final Instant getTimestampMember() { + return timestampMember; + } + + @Override + public final Builder timestampMember(Instant timestampMember) { + this.timestampMember = timestampMember; + return this; + } + + public final void setTimestampMember(Instant timestampMember) { + this.timestampMember = timestampMember; + } + + public final StructWithTimestamp.Builder getStructWithNestedTimestampMember() { + return structWithNestedTimestampMember != null ? structWithNestedTimestampMember.toBuilder() : null; + } + + @Override + public final Builder structWithNestedTimestampMember(StructWithTimestamp structWithNestedTimestampMember) { + this.structWithNestedTimestampMember = structWithNestedTimestampMember; + return this; + } + + public final void setStructWithNestedTimestampMember(StructWithTimestamp.BuilderImpl structWithNestedTimestampMember) { + this.structWithNestedTimestampMember = structWithNestedTimestampMember != null ? structWithNestedTimestampMember + .build() : null; + } + + public final ByteBuffer getBlobArg() { + return blobArg; + } + + @Override + public final Builder blobArg(ByteBuffer blobArg) { + this.blobArg = StandardMemberCopier.copy(blobArg); + return this; + } + + public final void setBlobArg(ByteBuffer blobArg) { + this.blobArg = StandardMemberCopier.copy(blobArg); + } + + public Builder blobArg(String blobArg) { + blobArg(new StringToByteBufferAdapter().adapt(blobArg)); + return this; + } + + public void setBlobArg(String blobArg) { + this.blobArg = new StringToByteBufferAdapter().adapt(blobArg); + } + + public final StructWithNestedBlobType.Builder getStructWithNestedBlob() { + return structWithNestedBlob != null ? structWithNestedBlob.toBuilder() : null; + } + + @Override + public final Builder structWithNestedBlob(StructWithNestedBlobType structWithNestedBlob) { + this.structWithNestedBlob = structWithNestedBlob; + return this; + } + + public final void setStructWithNestedBlob(StructWithNestedBlobType.BuilderImpl structWithNestedBlob) { + this.structWithNestedBlob = structWithNestedBlob != null ? structWithNestedBlob.build() : null; + } + + public final Map getBlobMap() { + return blobMap; + } + + @Override + public final Builder blobMap(Map blobMap) { + this.blobMap = BlobMapTypeCopier.copy(blobMap); + return this; + } + + public final void setBlobMap(Map blobMap) { + this.blobMap = BlobMapTypeCopier.copy(blobMap); + } + + public final Collection getListOfBlobs() { + return listOfBlobs; + } + + @Override + public final Builder listOfBlobs(Collection listOfBlobs) { + this.listOfBlobs = ListOfBlobsTypeCopier.copy(listOfBlobs); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfBlobs(ByteBuffer... listOfBlobs) { + listOfBlobs(Arrays.asList(listOfBlobs)); + return this; + } + + public final void setListOfBlobs(Collection listOfBlobs) { + this.listOfBlobs = ListOfBlobsTypeCopier.copy(listOfBlobs); + } + + public final RecursiveStructType.Builder getRecursiveStruct() { + return recursiveStruct != null ? recursiveStruct.toBuilder() : null; + } + + @Override + public final Builder recursiveStruct(RecursiveStructType recursiveStruct) { + this.recursiveStruct = recursiveStruct; + return this; + } + + public final void setRecursiveStruct(RecursiveStructType.BuilderImpl recursiveStruct) { + this.recursiveStruct = recursiveStruct != null ? recursiveStruct.build() : null; + } + + public final BaseType.Builder getPolymorphicTypeWithSubTypes() { + return polymorphicTypeWithSubTypes != null ? polymorphicTypeWithSubTypes.toBuilder() : null; + } + + @Override + public final Builder polymorphicTypeWithSubTypes(BaseType polymorphicTypeWithSubTypes) { + this.polymorphicTypeWithSubTypes = polymorphicTypeWithSubTypes; + return this; + } + + public final void setPolymorphicTypeWithSubTypes(BaseType.BuilderImpl polymorphicTypeWithSubTypes) { + this.polymorphicTypeWithSubTypes = polymorphicTypeWithSubTypes != null ? polymorphicTypeWithSubTypes.build() : null; + } + + public final SubTypeOne.Builder getPolymorphicTypeWithoutSubTypes() { + return polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.toBuilder() : null; + } + + @Override + public final Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWithoutSubTypes) { + this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes; + return this; + } + + public final void setPolymorphicTypeWithoutSubTypes(SubTypeOne.BuilderImpl polymorphicTypeWithoutSubTypes) { + this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.build() + : null; + } + + public final String getEnumType() { + return enumType; + } + + @Override + public final Builder enumType(String enumType) { + this.enumType = enumType; + return this; + } + + @Override + public final Builder enumType(EnumType enumType) { + this.enumType(enumType.toString()); + return this; + } + + public final void setEnumType(String enumType) { + this.enumType = enumType; + } + + @Override + public AllTypesResponse build() { + return new AllTypesResponse(this); + } + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofblobstypecopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofblobstypecopier.java new file mode 100644 index 000000000000..45e1651b58f9 --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofblobstypecopier.java @@ -0,0 +1,22 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import static java.util.stream.Collectors.toList; + +import java.nio.ByteBuffer; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import javax.annotation.Generated; +import software.amazon.awssdk.core.runtime.StandardMemberCopier; + +@Generated("software.amazon.awssdk:codegen") +final class ListOfBlobsTypeCopier { + static List copy(Collection listOfBlobsTypeParam) { + if (listOfBlobsTypeParam == null) { + return null; + } + List listOfBlobsTypeParamCopy = listOfBlobsTypeParam.stream().map(StandardMemberCopier::copy) + .collect(toList()); + return Collections.unmodifiableList(listOfBlobsTypeParamCopy); + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofenumscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofenumscopier.java new file mode 100644 index 000000000000..18c025d01a2d --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofenumscopier.java @@ -0,0 +1,20 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import static java.util.stream.Collectors.toList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import javax.annotation.Generated; + +@Generated("software.amazon.awssdk:codegen") +final class ListOfEnumsCopier { + static List copy(Collection listOfEnumsParam) { + if (listOfEnumsParam == null) { + return null; + } + List listOfEnumsParamCopy = new ArrayList<>(listOfEnumsParam); + return Collections.unmodifiableList(listOfEnumsParamCopy); + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofintegerscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofintegerscopier.java new file mode 100644 index 000000000000..5d325fa14f21 --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofintegerscopier.java @@ -0,0 +1,20 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import static java.util.stream.Collectors.toList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import javax.annotation.Generated; + +@Generated("software.amazon.awssdk:codegen") +final class ListOfIntegersCopier { + static List copy(Collection listOfIntegersParam) { + if (listOfIntegersParam == null) { + return null; + } + List listOfIntegersParamCopy = new ArrayList<>(listOfIntegersParam); + return Collections.unmodifiableList(listOfIntegersParamCopy); + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listoflistoflistofstringscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listoflistoflistofstringscopier.java new file mode 100644 index 000000000000..d6f5553b4a42 --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listoflistoflistofstringscopier.java @@ -0,0 +1,21 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import static java.util.stream.Collectors.toList; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import javax.annotation.Generated; + +@Generated("software.amazon.awssdk:codegen") +final class ListOfListOfListOfStringsCopier { + static List>> copy( + Collection>> listOfListOfListOfStringsParam) { + if (listOfListOfListOfStringsParam == null) { + return null; + } + List>> listOfListOfListOfStringsParamCopy = listOfListOfListOfStringsParam.stream() + .map(ListOfListOfStringsCopier::copy).collect(toList()); + return Collections.unmodifiableList(listOfListOfListOfStringsParamCopy); + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listoflistofstringscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listoflistofstringscopier.java new file mode 100644 index 000000000000..f0d8b24838de --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listoflistofstringscopier.java @@ -0,0 +1,20 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import static java.util.stream.Collectors.toList; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import javax.annotation.Generated; + +@Generated("software.amazon.awssdk:codegen") +final class ListOfListOfStringsCopier { + static List> copy(Collection> listOfListOfStringsParam) { + if (listOfListOfStringsParam == null) { + return null; + } + List> listOfListOfStringsParamCopy = listOfListOfStringsParam.stream().map(ListOfStringsCopier::copy) + .collect(toList()); + return Collections.unmodifiableList(listOfListOfStringsParamCopy); + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofmapstringtostringcopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofmapstringtostringcopier.java new file mode 100644 index 000000000000..d8d232d0ea9b --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofmapstringtostringcopier.java @@ -0,0 +1,21 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import static java.util.stream.Collectors.toList; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; + +@Generated("software.amazon.awssdk:codegen") +final class ListOfMapStringToStringCopier { + static List> copy(Collection> listOfMapStringToStringParam) { + if (listOfMapStringToStringParam == null) { + return null; + } + List> listOfMapStringToStringParamCopy = listOfMapStringToStringParam.stream() + .map(MapOfStringToStringCopier::copy).collect(toList()); + return Collections.unmodifiableList(listOfMapStringToStringParamCopy); + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofsimplestructscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofsimplestructscopier.java new file mode 100644 index 000000000000..85d52768f1bd --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofsimplestructscopier.java @@ -0,0 +1,27 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import static java.util.stream.Collectors.toList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import javax.annotation.Generated; + +@Generated("software.amazon.awssdk:codegen") +final class ListOfSimpleStructsCopier { + static List copy(Collection listOfSimpleStructsParam) { + if (listOfSimpleStructsParam == null) { + return null; + } + List listOfSimpleStructsParamCopy = new ArrayList<>(listOfSimpleStructsParam); + return Collections.unmodifiableList(listOfSimpleStructsParamCopy); + } + + static List copyFromBuilder(Collection listOfSimpleStructsParam) { + if (listOfSimpleStructsParam == null) { + return null; + } + return copy(listOfSimpleStructsParam.stream().map(SimpleStruct.Builder::build).collect(toList())); + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofstringscopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofstringscopier.java new file mode 100644 index 000000000000..577ad10a234c --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/listofstringscopier.java @@ -0,0 +1,20 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import static java.util.stream.Collectors.toList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import javax.annotation.Generated; + +@Generated("software.amazon.awssdk:codegen") +final class ListOfStringsCopier { + static List copy(Collection listOfStringsParam) { + if (listOfStringsParam == null) { + return null; + } + List listOfStringsParamCopy = new ArrayList<>(listOfStringsParam); + return Collections.unmodifiableList(listOfStringsParamCopy); + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/nestedcontainersrequest.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/nestedcontainersrequest.java new file mode 100644 index 000000000000..b74b33ef47cb --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/nestedcontainersrequest.java @@ -0,0 +1,277 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Consumer; +import javax.annotation.Generated; +import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; +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 NestedContainersRequest extends JsonProtocolTestsRequest implements + ToCopyableBuilder { + private final List> listOfListOfStrings; + + private final List>> listOfListOfListOfStrings; + + private final Map>> mapOfStringToListOfListOfStrings; + + private NestedContainersRequest(BuilderImpl builder) { + super(builder); + this.listOfListOfStrings = builder.listOfListOfStrings; + this.listOfListOfListOfStrings = builder.listOfListOfListOfStrings; + this.mapOfStringToListOfListOfStrings = builder.mapOfStringToListOfListOfStrings; + } + + /** + * Returns the value of the ListOfListOfStrings property for this object. + *

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

+ * + * @return The value of the ListOfListOfStrings property for this object. + */ + public List> listOfListOfStrings() { + return listOfListOfStrings; + } + + /** + * Returns the value of the ListOfListOfListOfStrings property for this object. + *

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

+ * + * @return The value of the ListOfListOfListOfStrings property for this object. + */ + public List>> listOfListOfListOfStrings() { + return listOfListOfListOfStrings; + } + + /** + * Returns the value of the MapOfStringToListOfListOfStrings property for this object. + *

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

+ * + * @return The value of the MapOfStringToListOfListOfStrings property for this object. + */ + public Map>> mapOfStringToListOfListOfStrings() { + return mapOfStringToListOfListOfStrings; + } + + @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 + Objects.hashCode(listOfListOfStrings()); + hashCode = 31 * hashCode + Objects.hashCode(listOfListOfListOfStrings()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToListOfListOfStrings()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof NestedContainersRequest)) { + return false; + } + NestedContainersRequest other = (NestedContainersRequest) obj; + return Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) + && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) + && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); + } + + @Override + public String toString() { + return ToString.builder("NestedContainersRequest").add("ListOfListOfStrings", listOfListOfStrings()) + .add("ListOfListOfListOfStrings", listOfListOfListOfStrings()) + .add("MapOfStringToListOfListOfStrings", mapOfStringToListOfListOfStrings()).build(); + } + + public Optional getValueForField(String fieldName, Class clazz) { + switch (fieldName) { + case "ListOfListOfStrings": + return Optional.of(clazz.cast(listOfListOfStrings())); + case "ListOfListOfListOfStrings": + return Optional.of(clazz.cast(listOfListOfListOfStrings())); + case "MapOfStringToListOfListOfStrings": + return Optional.of(clazz.cast(mapOfStringToListOfListOfStrings())); + default: + return Optional.empty(); + } + } + + public interface Builder extends JsonProtocolTestsRequest.Builder, CopyableBuilder { + /** + * Sets the value of the ListOfListOfStrings property for this object. + * + * @param listOfListOfStrings + * The new value for the ListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfListOfStrings(Collection> listOfListOfStrings); + + /** + * Sets the value of the ListOfListOfStrings property for this object. + * + * @param listOfListOfStrings + * The new value for the ListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfListOfStrings(Collection... listOfListOfStrings); + + /** + * Sets the value of the ListOfListOfListOfStrings property for this object. + * + * @param listOfListOfListOfStrings + * The new value for the ListOfListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfListOfListOfStrings(Collection>> listOfListOfListOfStrings); + + /** + * Sets the value of the ListOfListOfListOfStrings property for this object. + * + * @param listOfListOfListOfStrings + * The new value for the ListOfListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfListOfListOfStrings(Collection>... listOfListOfListOfStrings); + + /** + * Sets the value of the MapOfStringToListOfListOfStrings property for this object. + * + * @param mapOfStringToListOfListOfStrings + * The new value for the MapOfStringToListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToListOfListOfStrings( + Map>> mapOfStringToListOfListOfStrings); + + @Override + Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); + + @Override + Builder overrideConfiguration(Consumer builderConsumer); + } + + static final class BuilderImpl extends JsonProtocolTestsRequest.BuilderImpl implements Builder { + private List> listOfListOfStrings; + + private List>> listOfListOfListOfStrings; + + private Map>> mapOfStringToListOfListOfStrings; + + private BuilderImpl() { + } + + private BuilderImpl(NestedContainersRequest model) { + super(model); + listOfListOfStrings(model.listOfListOfStrings); + listOfListOfListOfStrings(model.listOfListOfListOfStrings); + mapOfStringToListOfListOfStrings(model.mapOfStringToListOfListOfStrings); + } + + public final Collection> getListOfListOfStrings() { + return listOfListOfStrings; + } + + @Override + public final Builder listOfListOfStrings(Collection> listOfListOfStrings) { + this.listOfListOfStrings = ListOfListOfStringsCopier.copy(listOfListOfStrings); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfListOfStrings(Collection... listOfListOfStrings) { + listOfListOfStrings(Arrays.asList(listOfListOfStrings)); + return this; + } + + public final void setListOfListOfStrings(Collection> listOfListOfStrings) { + this.listOfListOfStrings = ListOfListOfStringsCopier.copy(listOfListOfStrings); + } + + public final Collection>> getListOfListOfListOfStrings() { + return listOfListOfListOfStrings; + } + + @Override + public final Builder listOfListOfListOfStrings( + Collection>> listOfListOfListOfStrings) { + this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfListOfListOfStrings(Collection>... listOfListOfListOfStrings) { + listOfListOfListOfStrings(Arrays.asList(listOfListOfListOfStrings)); + return this; + } + + public final void setListOfListOfListOfStrings( + Collection>> listOfListOfListOfStrings) { + this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); + } + + public final Map>> getMapOfStringToListOfListOfStrings() { + return mapOfStringToListOfListOfStrings; + } + + @Override + public final Builder mapOfStringToListOfListOfStrings( + Map>> mapOfStringToListOfListOfStrings) { + this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); + return this; + } + + public final void setMapOfStringToListOfListOfStrings( + Map>> mapOfStringToListOfListOfStrings) { + this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); + } + + @Override + public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { + super.overrideConfiguration(overrideConfiguration); + return this; + } + + @Override + public Builder overrideConfiguration(Consumer builderConsumer) { + super.overrideConfiguration(builderConsumer); + return this; + } + + @Override + public NestedContainersRequest build() { + return new NestedContainersRequest(this); + } + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/nestedcontainersresponse.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/nestedcontainersresponse.java new file mode 100644 index 000000000000..89c6a9fc3b43 --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/nestedcontainersresponse.java @@ -0,0 +1,257 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import javax.annotation.Generated; +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 NestedContainersResponse extends JsonProtocolTestsResponse implements + ToCopyableBuilder { + private final List> listOfListOfStrings; + + private final List>> listOfListOfListOfStrings; + + private final Map>> mapOfStringToListOfListOfStrings; + + private NestedContainersResponse(BuilderImpl builder) { + super(builder); + this.listOfListOfStrings = builder.listOfListOfStrings; + this.listOfListOfListOfStrings = builder.listOfListOfListOfStrings; + this.mapOfStringToListOfListOfStrings = builder.mapOfStringToListOfListOfStrings; + } + + /** + * Returns the value of the ListOfListOfStrings property for this object. + *

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

+ * + * @return The value of the ListOfListOfStrings property for this object. + */ + public List> listOfListOfStrings() { + return listOfListOfStrings; + } + + /** + * Returns the value of the ListOfListOfListOfStrings property for this object. + *

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

+ * + * @return The value of the ListOfListOfListOfStrings property for this object. + */ + public List>> listOfListOfListOfStrings() { + return listOfListOfListOfStrings; + } + + /** + * Returns the value of the MapOfStringToListOfListOfStrings property for this object. + *

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

+ * + * @return The value of the MapOfStringToListOfListOfStrings property for this object. + */ + public Map>> mapOfStringToListOfListOfStrings() { + return mapOfStringToListOfListOfStrings; + } + + @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 + Objects.hashCode(listOfListOfStrings()); + hashCode = 31 * hashCode + Objects.hashCode(listOfListOfListOfStrings()); + hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToListOfListOfStrings()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof NestedContainersResponse)) { + return false; + } + NestedContainersResponse other = (NestedContainersResponse) obj; + return Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) + && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) + && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); + } + + @Override + public String toString() { + return ToString.builder("NestedContainersResponse").add("ListOfListOfStrings", listOfListOfStrings()) + .add("ListOfListOfListOfStrings", listOfListOfListOfStrings()) + .add("MapOfStringToListOfListOfStrings", mapOfStringToListOfListOfStrings()).build(); + } + + public Optional getValueForField(String fieldName, Class clazz) { + switch (fieldName) { + case "ListOfListOfStrings": + return Optional.of(clazz.cast(listOfListOfStrings())); + case "ListOfListOfListOfStrings": + return Optional.of(clazz.cast(listOfListOfListOfStrings())); + case "MapOfStringToListOfListOfStrings": + return Optional.of(clazz.cast(mapOfStringToListOfListOfStrings())); + default: + return Optional.empty(); + } + } + + public interface Builder extends JsonProtocolTestsResponse.Builder, CopyableBuilder { + /** + * Sets the value of the ListOfListOfStrings property for this object. + * + * @param listOfListOfStrings + * The new value for the ListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfListOfStrings(Collection> listOfListOfStrings); + + /** + * Sets the value of the ListOfListOfStrings property for this object. + * + * @param listOfListOfStrings + * The new value for the ListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfListOfStrings(Collection... listOfListOfStrings); + + /** + * Sets the value of the ListOfListOfListOfStrings property for this object. + * + * @param listOfListOfListOfStrings + * The new value for the ListOfListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfListOfListOfStrings(Collection>> listOfListOfListOfStrings); + + /** + * Sets the value of the ListOfListOfListOfStrings property for this object. + * + * @param listOfListOfListOfStrings + * The new value for the ListOfListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder listOfListOfListOfStrings(Collection>... listOfListOfListOfStrings); + + /** + * Sets the value of the MapOfStringToListOfListOfStrings property for this object. + * + * @param mapOfStringToListOfListOfStrings + * The new value for the MapOfStringToListOfListOfStrings property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder mapOfStringToListOfListOfStrings( + Map>> mapOfStringToListOfListOfStrings); + } + + static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl implements Builder { + private List> listOfListOfStrings; + + private List>> listOfListOfListOfStrings; + + private Map>> mapOfStringToListOfListOfStrings; + + private BuilderImpl() { + } + + private BuilderImpl(NestedContainersResponse model) { + super(model); + listOfListOfStrings(model.listOfListOfStrings); + listOfListOfListOfStrings(model.listOfListOfListOfStrings); + mapOfStringToListOfListOfStrings(model.mapOfStringToListOfListOfStrings); + } + + public final Collection> getListOfListOfStrings() { + return listOfListOfStrings; + } + + @Override + public final Builder listOfListOfStrings(Collection> listOfListOfStrings) { + this.listOfListOfStrings = ListOfListOfStringsCopier.copy(listOfListOfStrings); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfListOfStrings(Collection... listOfListOfStrings) { + listOfListOfStrings(Arrays.asList(listOfListOfStrings)); + return this; + } + + public final void setListOfListOfStrings(Collection> listOfListOfStrings) { + this.listOfListOfStrings = ListOfListOfStringsCopier.copy(listOfListOfStrings); + } + + public final Collection>> getListOfListOfListOfStrings() { + return listOfListOfListOfStrings; + } + + @Override + public final Builder listOfListOfListOfStrings( + Collection>> listOfListOfListOfStrings) { + this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); + return this; + } + + @Override + @SafeVarargs + public final Builder listOfListOfListOfStrings(Collection>... listOfListOfListOfStrings) { + listOfListOfListOfStrings(Arrays.asList(listOfListOfListOfStrings)); + return this; + } + + public final void setListOfListOfListOfStrings( + Collection>> listOfListOfListOfStrings) { + this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); + } + + public final Map>> getMapOfStringToListOfListOfStrings() { + return mapOfStringToListOfListOfStrings; + } + + @Override + public final Builder mapOfStringToListOfListOfStrings( + Map>> mapOfStringToListOfListOfStrings) { + this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); + return this; + } + + public final void setMapOfStringToListOfListOfStrings( + Map>> mapOfStringToListOfListOfStrings) { + this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); + } + + @Override + public NestedContainersResponse build() { + return new NestedContainersResponse(this); + } + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/recursivelisttypecopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/recursivelisttypecopier.java new file mode 100644 index 000000000000..2f676d2d8177 --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/recursivelisttypecopier.java @@ -0,0 +1,27 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import static java.util.stream.Collectors.toList; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import javax.annotation.Generated; + +@Generated("software.amazon.awssdk:codegen") +final class RecursiveListTypeCopier { + static List copy(Collection recursiveListTypeParam) { + if (recursiveListTypeParam == null) { + return null; + } + List recursiveListTypeParamCopy = new ArrayList<>(recursiveListTypeParam); + return Collections.unmodifiableList(recursiveListTypeParamCopy); + } + + static List copyFromBuilder(Collection recursiveListTypeParam) { + if (recursiveListTypeParam == null) { + return null; + } + return copy(recursiveListTypeParam.stream().map(RecursiveStructType.Builder::build).collect(toList())); + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/recursivestructtype.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/recursivestructtype.java new file mode 100644 index 000000000000..fb91a472d29c --- /dev/null +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/recursivestructtype.java @@ -0,0 +1,327 @@ +package software.amazon.awssdk.services.jsonprotocoltests.model; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.annotation.Generated; +import software.amazon.awssdk.annotations.SdkInternalApi; +import software.amazon.awssdk.core.protocol.ProtocolMarshaller; +import software.amazon.awssdk.core.protocol.StructuredPojo; +import software.amazon.awssdk.services.jsonprotocoltests.transform.RecursiveStructTypeMarshaller; +import software.amazon.awssdk.utils.CollectionUtils; +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 RecursiveStructType implements StructuredPojo, + ToCopyableBuilder { + private final String noRecurse; + + private final RecursiveStructType recursiveStruct; + + private final List recursiveList; + + private final Map recursiveMap; + + private RecursiveStructType(BuilderImpl builder) { + this.noRecurse = builder.noRecurse; + this.recursiveStruct = builder.recursiveStruct; + this.recursiveList = builder.recursiveList; + this.recursiveMap = builder.recursiveMap; + } + + /** + * Returns the value of the NoRecurse property for this object. + * + * @return The value of the NoRecurse property for this object. + */ + public String noRecurse() { + return noRecurse; + } + + /** + * Returns the value of the RecursiveStruct property for this object. + * + * @return The value of the RecursiveStruct property for this object. + */ + public RecursiveStructType recursiveStruct() { + return recursiveStruct; + } + + /** + * Returns the value of the RecursiveList property for this object. + *

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

+ * + * @return The value of the RecursiveList property for this object. + */ + public List recursiveList() { + return recursiveList; + } + + /** + * Returns the value of the RecursiveMap property for this object. + *

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

+ * + * @return The value of the RecursiveMap property for this object. + */ + public Map recursiveMap() { + return recursiveMap; + } + + @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 + Objects.hashCode(noRecurse()); + hashCode = 31 * hashCode + Objects.hashCode(recursiveStruct()); + hashCode = 31 * hashCode + Objects.hashCode(recursiveList()); + hashCode = 31 * hashCode + Objects.hashCode(recursiveMap()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof RecursiveStructType)) { + return false; + } + RecursiveStructType other = (RecursiveStructType) obj; + return Objects.equals(noRecurse(), other.noRecurse()) && Objects.equals(recursiveStruct(), other.recursiveStruct()) + && Objects.equals(recursiveList(), other.recursiveList()) && Objects.equals(recursiveMap(), other.recursiveMap()); + } + + @Override + public String toString() { + return ToString.builder("RecursiveStructType").add("NoRecurse", noRecurse()).add("RecursiveStruct", recursiveStruct()) + .add("RecursiveList", recursiveList()).add("RecursiveMap", recursiveMap()).build(); + } + + public Optional getValueForField(String fieldName, Class clazz) { + switch (fieldName) { + case "NoRecurse": + return Optional.of(clazz.cast(noRecurse())); + case "RecursiveStruct": + return Optional.of(clazz.cast(recursiveStruct())); + case "RecursiveList": + return Optional.of(clazz.cast(recursiveList())); + case "RecursiveMap": + return Optional.of(clazz.cast(recursiveMap())); + default: + return Optional.empty(); + } + } + + @SdkInternalApi + @Override + public void marshall(ProtocolMarshaller protocolMarshaller) { + RecursiveStructTypeMarshaller.getInstance().marshall(this, protocolMarshaller); + } + + public interface Builder extends CopyableBuilder { + /** + * Sets the value of the NoRecurse property for this object. + * + * @param noRecurse + * The new value for the NoRecurse property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder noRecurse(String noRecurse); + + /** + * Sets the value of the RecursiveStruct property for this object. + * + * @param recursiveStruct + * The new value for the RecursiveStruct property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder recursiveStruct(RecursiveStructType recursiveStruct); + + /** + * Sets the value of the RecursiveStruct property for this object. + * + * This is a convenience that creates an instance of the {@link RecursiveStructType.Builder} avoiding the need + * to create one manually via {@link RecursiveStructType#builder()}. + * + * 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. + * @see #recursiveStruct(RecursiveStructType) + */ + default Builder recursiveStruct(Consumer recursiveStruct) { + return recursiveStruct(RecursiveStructType.builder().apply(recursiveStruct).build()); + } + + /** + * Sets the value of the RecursiveList property for this object. + * + * @param recursiveList + * The new value for the RecursiveList property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder recursiveList(Collection recursiveList); + + /** + * Sets the value of the RecursiveList property for this object. + * + * @param recursiveList + * The new value for the RecursiveList property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder recursiveList(RecursiveStructType... recursiveList); + + /** + * Sets the value of the RecursiveList property for this object. + * + * This is a convenience that creates an instance of the {@link List.Builder} avoiding the + * need to create one manually via {@link List#builder()}. + * + * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately + * and its result is passed to {@link #recursiveList(List)}. + * + * @param recursiveList + * a consumer that will call methods on {@link List.Builder} + * @return Returns a reference to this object so that method calls can be chained together. + * @see #recursiveList(List) + */ + Builder recursiveList(Consumer... recursiveList); + + /** + * Sets the value of the RecursiveMap property for this object. + * + * @param recursiveMap + * The new value for the RecursiveMap property for this object. + * @return Returns a reference to this object so that method calls can be chained together. + */ + Builder recursiveMap(Map recursiveMap); + } + + static final class BuilderImpl implements Builder { + private String noRecurse; + + private RecursiveStructType recursiveStruct; + + private List recursiveList; + + private Map recursiveMap; + + private BuilderImpl() { + } + + private BuilderImpl(RecursiveStructType model) { + noRecurse(model.noRecurse); + recursiveStruct(model.recursiveStruct); + recursiveList(model.recursiveList); + recursiveMap(model.recursiveMap); + } + + public final String getNoRecurse() { + return noRecurse; + } + + @Override + public final Builder noRecurse(String noRecurse) { + this.noRecurse = noRecurse; + return this; + } + + public final void setNoRecurse(String noRecurse) { + this.noRecurse = noRecurse; + } + + public final Builder getRecursiveStruct() { + return recursiveStruct != null ? recursiveStruct.toBuilder() : null; + } + + @Override + public final Builder recursiveStruct(RecursiveStructType recursiveStruct) { + this.recursiveStruct = recursiveStruct; + return this; + } + + public final void setRecursiveStruct(BuilderImpl recursiveStruct) { + this.recursiveStruct = recursiveStruct != null ? recursiveStruct.build() : null; + } + + public final Collection getRecursiveList() { + return recursiveList != null ? recursiveList.stream().map(RecursiveStructType::toBuilder) + .collect(Collectors.toList()) : null; + } + + @Override + public final Builder recursiveList(Collection recursiveList) { + this.recursiveList = RecursiveListTypeCopier.copy(recursiveList); + return this; + } + + @Override + @SafeVarargs + public final Builder recursiveList(RecursiveStructType... recursiveList) { + recursiveList(Arrays.asList(recursiveList)); + return this; + } + + @Override + @SafeVarargs + public final Builder recursiveList(Consumer... recursiveList) { + recursiveList(Stream.of(recursiveList).map(c -> RecursiveStructType.builder().apply(c).build()) + .collect(Collectors.toList())); + return this; + } + + public final void setRecursiveList(Collection recursiveList) { + this.recursiveList = RecursiveListTypeCopier.copyFromBuilder(recursiveList); + } + + public final Map getRecursiveMap() { + return recursiveMap != null ? CollectionUtils.mapValues(recursiveMap, RecursiveStructType::toBuilder) : null; + } + + @Override + public final Builder recursiveMap(Map recursiveMap) { + this.recursiveMap = RecursiveMapTypeCopier.copy(recursiveMap); + return this; + } + + public final void setRecursiveMap(Map recursiveMap) { + this.recursiveMap = RecursiveMapTypeCopier.copyFromBuilder(recursiveMap); + } + + @Override + public RecursiveStructType build() { + return new RecursiveStructType(this); + } + } +} diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/recursivelisttypecopier.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/recursivelisttypecopier.java index 527481923eef..80ae7fb87f62 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/recursivelisttypecopier.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/recursivelisttypecopier.java @@ -2,18 +2,21 @@ import static java.util.stream.Collectors.toList; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import javax.annotation.Generated; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; @Generated("software.amazon.awssdk:codegen") final class RecursiveListTypeCopier { static List copy(Collection recursiveListTypeParam) { - if (recursiveListTypeParam == null) { - return null; + if (recursiveListTypeParam == null || recursiveListTypeParam instanceof SdkAutoConstructList) { + return DefaultSdkAutoConstructList.getInstance(); } - List recursiveListTypeParamCopy = recursiveListTypeParam.stream().collect(toList()); + List recursiveListTypeParamCopy = new ArrayList<>(recursiveListTypeParam); return Collections.unmodifiableList(recursiveListTypeParamCopy); } 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 65af0401f765..3e29af0f94b9 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 @@ -13,6 +13,7 @@ import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.protocol.ProtocolMarshaller; import software.amazon.awssdk.core.protocol.StructuredPojo; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; import software.amazon.awssdk.services.jsonprotocoltests.transform.RecursiveStructTypeMarshaller; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.ToString; @@ -116,27 +117,27 @@ public boolean equals(Object obj) { } RecursiveStructType other = (RecursiveStructType) obj; return Objects.equals(noRecurse(), other.noRecurse()) && Objects.equals(recursiveStruct(), other.recursiveStruct()) - && Objects.equals(recursiveList(), other.recursiveList()) && Objects.equals(recursiveMap(), other.recursiveMap()); + && Objects.equals(recursiveList(), other.recursiveList()) && Objects.equals(recursiveMap(), other.recursiveMap()); } @Override public String toString() { return ToString.builder("RecursiveStructType").add("NoRecurse", noRecurse()).add("RecursiveStruct", recursiveStruct()) - .add("RecursiveList", recursiveList()).add("RecursiveMap", recursiveMap()).build(); + .add("RecursiveList", recursiveList()).add("RecursiveMap", recursiveMap()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { - case "NoRecurse": - return Optional.of(clazz.cast(noRecurse())); - case "RecursiveStruct": - return Optional.of(clazz.cast(recursiveStruct())); - case "RecursiveList": - return Optional.of(clazz.cast(recursiveList())); - case "RecursiveMap": - return Optional.of(clazz.cast(recursiveMap())); - default: - return Optional.empty(); + case "NoRecurse": + return Optional.of(clazz.cast(noRecurse())); + case "RecursiveStruct": + return Optional.of(clazz.cast(recursiveStruct())); + case "RecursiveList": + return Optional.of(clazz.cast(recursiveList())); + case "RecursiveMap": + return Optional.of(clazz.cast(recursiveMap())); + default: + return Optional.empty(); } } @@ -232,7 +233,7 @@ static final class BuilderImpl implements Builder { private RecursiveStructType recursiveStruct; - private List recursiveList; + private List recursiveList = DefaultSdkAutoConstructList.getInstance(); private Map recursiveMap; @@ -276,7 +277,7 @@ public final void setRecursiveStruct(BuilderImpl recursiveStruct) { public final Collection getRecursiveList() { return recursiveList != null ? recursiveList.stream().map(RecursiveStructType::toBuilder) - .collect(Collectors.toList()) : null; + .collect(Collectors.toList()) : null; } @Override @@ -296,7 +297,7 @@ public final Builder recursiveList(RecursiveStructType... recursiveList) { @SafeVarargs public final Builder recursiveList(Consumer... recursiveList) { recursiveList(Stream.of(recursiveList).map(c -> RecursiveStructType.builder().apply(c).build()) - .collect(Collectors.toList())); + .collect(Collectors.toList())); return this; } diff --git a/core/src/main/java/software/amazon/awssdk/core/protocol/json/internal/SimpleTypeJsonMarshallers.java b/core/src/main/java/software/amazon/awssdk/core/protocol/json/internal/SimpleTypeJsonMarshallers.java index bc993f2c3fc9..fbe6e1bc839e 100644 --- a/core/src/main/java/software/amazon/awssdk/core/protocol/json/internal/SimpleTypeJsonMarshallers.java +++ b/core/src/main/java/software/amazon/awssdk/core/protocol/json/internal/SimpleTypeJsonMarshallers.java @@ -24,6 +24,7 @@ import software.amazon.awssdk.core.protocol.MarshallLocation; import software.amazon.awssdk.core.protocol.StructuredPojo; import software.amazon.awssdk.core.protocol.json.StructuredJsonGenerator; +import software.amazon.awssdk.core.util.SdkAutoConstructList; @SdkInternalApi public final class SimpleTypeJsonMarshallers { @@ -120,6 +121,12 @@ public void marshall(List list, StructuredJsonGenerator jsonGenerator, JsonMarsh } jsonGenerator.writeEndArray(); } + + @Override + protected boolean shouldEmit(List list) { + return !list.isEmpty() || !(list instanceof SdkAutoConstructList); + + } }; /** @@ -153,6 +160,9 @@ private abstract static class BaseJsonMarshaller implements JsonMarshaller @Override public final void marshall(T val, JsonMarshallerContext context, String paramName) { + if (!shouldEmit(val)) { + return; + } if (paramName != null) { context.jsonGenerator().writeFieldName(paramName); } @@ -160,6 +170,10 @@ public final void marshall(T val, JsonMarshallerContext context, String paramNam } public abstract void marshall(T val, StructuredJsonGenerator jsonGenerator, JsonMarshallerContext context); + + protected boolean shouldEmit(T val) { + return true; + } } } diff --git a/core/src/main/java/software/amazon/awssdk/core/util/DefaultSdkAutoConstructList.java b/core/src/main/java/software/amazon/awssdk/core/util/DefaultSdkAutoConstructList.java new file mode 100644 index 000000000000..3e1c36a64614 --- /dev/null +++ b/core/src/main/java/software/amazon/awssdk/core/util/DefaultSdkAutoConstructList.java @@ -0,0 +1,161 @@ +/* + * Copyright 2010-2018 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.core.util; + +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import software.amazon.awssdk.annotations.SdkInternalApi; + +/** + * Default implementation of {@link SdkAutoConstructList}. + *

+ * This is an empty, unmodifiable list. + * + * @param The element type. + */ +@SdkInternalApi +public final class DefaultSdkAutoConstructList implements SdkAutoConstructList { + private static final DefaultSdkAutoConstructList INSTANCE = new DefaultSdkAutoConstructList(); + + private final List impl = Collections.unmodifiableList(Collections.emptyList()); + + private DefaultSdkAutoConstructList() { + } + + @SuppressWarnings("unchecked") + public static DefaultSdkAutoConstructList getInstance() { + return (DefaultSdkAutoConstructList) INSTANCE; + } + + @Override + public int size() { + return impl.size(); + } + + @Override + public boolean isEmpty() { + return impl.isEmpty(); + } + + @Override + public boolean contains(Object o) { + return impl.contains(o); + } + + @Override + public Iterator iterator() { + return impl.iterator(); + } + + @Override + public Object[] toArray() { + return impl.toArray(); + } + + @Override + public T1[] toArray(T1[] a) { + return (T1[]) impl.toArray(a); + } + + @Override + public boolean add(T t) { + return impl.add(t); + } + + @Override + public boolean remove(Object o) { + return impl.remove(o); + } + + @Override + public boolean containsAll(Collection c) { + return impl.containsAll(c); + } + + @Override + public boolean addAll(Collection c) { + return impl.addAll(c); + } + + @Override + public boolean addAll(int index, Collection c) { + return impl.addAll(index, c); + } + + @Override + public boolean removeAll(Collection c) { + return impl.removeAll(c); + } + + @Override + public boolean retainAll(Collection c) { + return impl.retainAll(c); + } + + @Override + public void clear() { + impl.clear(); + } + + @Override + public T get(int index) { + return (T) impl.get(index); + } + + @Override + public T set(int index, T element) { + return (T) impl.set(index, element); + } + + @Override + public void add(int index, T element) { + impl.add(index, element); + } + + @Override + public T remove(int index) { + return (T) impl.remove(index); + } + + @Override + public int indexOf(Object o) { + return impl.indexOf(o); + } + + @Override + public int lastIndexOf(Object o) { + return impl.lastIndexOf(o); + } + + @Override + public ListIterator listIterator() { + return impl.listIterator(); + } + + @Override + public ListIterator listIterator(int index) { + return impl.listIterator(index); + } + + @Override + public List subList(int fromIndex, int toIndex) { + return impl.subList(fromIndex, toIndex); + } + +} diff --git a/core/src/main/java/software/amazon/awssdk/core/util/SdkAutoConstructList.java b/core/src/main/java/software/amazon/awssdk/core/util/SdkAutoConstructList.java new file mode 100644 index 000000000000..3400f93b6477 --- /dev/null +++ b/core/src/main/java/software/amazon/awssdk/core/util/SdkAutoConstructList.java @@ -0,0 +1,34 @@ +/* + * Copyright 2010-2018 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.core.util; + +import java.util.List; + +import software.amazon.awssdk.annotations.SdkInternalApi; + +/** + * A list that was auto constructed by the SDK. + *

+ * The main purpose of this class is to help distinguish explicitly empty lists + * set on requests by the user, as some services may treat {@code null} or + * missing lists and empty list members differently. As such, this class should + * not be used directly by the user. + * + * @param The element type. + */ +@SdkInternalApi +public interface SdkAutoConstructList extends List { +} diff --git a/pom.xml b/pom.xml index df770032c270..668ca2417f36 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,7 @@ test/protocol-tests-core test/service-test-utils test/test-utils + test/codegen-generated-classes-test annotations utils diff --git a/services/dynamodb/src/main/resources/codegen-resources/dynamodb/customization.config b/services/dynamodb/src/main/resources/codegen-resources/dynamodb/customization.config index b04c5732fd3f..51167bd48455 100644 --- a/services/dynamodb/src/main/resources/codegen-resources/dynamodb/customization.config +++ b/services/dynamodb/src/main/resources/codegen-resources/dynamodb/customization.config @@ -15,5 +15,6 @@ } ] } - } + }, + "useAutoConstructList": false } diff --git a/services/dynamodb/src/main/resources/codegen-resources/dynamodbstreams/customization.config b/services/dynamodb/src/main/resources/codegen-resources/dynamodbstreams/customization.config index 7c5c95cc1f99..e5c170a4a8a4 100644 --- a/services/dynamodb/src/main/resources/codegen-resources/dynamodbstreams/customization.config +++ b/services/dynamodb/src/main/resources/codegen-resources/dynamodbstreams/customization.config @@ -31,5 +31,7 @@ }, "shareModelsWith" : "dynamodb", - "skipSmokeTests": "true" + "skipSmokeTests": "true", + + "useAutoConstructList": false } diff --git a/services/kinesis/src/main/resources/codegen-resources/kinesis/customization.config b/services/kinesis/src/main/resources/codegen-resources/kinesis/customization.config index 6534326e390e..4cdbfa87c2b3 100644 --- a/services/kinesis/src/main/resources/codegen-resources/kinesis/customization.config +++ b/services/kinesis/src/main/resources/codegen-resources/kinesis/customization.config @@ -5,6 +5,6 @@ "customServiceMetadata": { "protocol": "cbor" }, - "skipSmokeTests": "true" - + "skipSmokeTests": "true", + "useAutoConstructList": true } diff --git a/services/rds/src/test/java/software/amazon/awssdk/services/rds/PresignRequestHandlerTest.java b/services/rds/src/test/java/software/amazon/awssdk/services/rds/PresignRequestHandlerTest.java index cd3234849453..abb9309d2381 100644 --- a/services/rds/src/test/java/software/amazon/awssdk/services/rds/PresignRequestHandlerTest.java +++ b/services/rds/src/test/java/software/amazon/awssdk/services/rds/PresignRequestHandlerTest.java @@ -26,6 +26,7 @@ import java.net.URISyntaxException; import java.time.Clock; import java.util.Calendar; +import java.util.Collections; import java.util.GregorianCalendar; import java.util.TimeZone; import org.junit.Test; @@ -97,13 +98,17 @@ public void testComputesPresignedUrlCorrectly() throws URISyntaxException { "&SourceDBSnapshotIdentifier=arn%3Aaws%3Ards%3Aus-east-1%3A123456789012%3Asnapshot%3Ards%3Atest-instance-ss-2016-12-20-23-19" + "&TargetDBSnapshotIdentifier=test-instance-ss-copy-2" + "&KmsKeyId=arn%3Aaws%3Akms%3Aus-west-2%3A123456789012%3Akey%2F11111111-2222-3333-4444-555555555555" + + // FIXME: The empty "Tags" list should not be getting + // marshalled, but we need to fix the marshallers to be aware + // of auto construct lists + "&Tags=" + "&DestinationRegion=us-west-2" + "&X-Amz-Algorithm=AWS4-HMAC-SHA256" + "&X-Amz-Date=20161221T180735Z" + "&X-Amz-SignedHeaders=host" + "&X-Amz-Expires=604800" + "&X-Amz-Credential=foo%2F20161221%2Fus-east-1%2Frds%2Faws4_request" + - "&X-Amz-Signature=f839ca3c728dc96e7c978befeac648296b9f778f6724073de4217173859d13d9"; + "&X-Amz-Signature=6a7e40b24c91517a6de0e60bc65a1a812deaa0a0aa3b54ab513bef3ed34f78c9"; assertEquals(expectedPreSignedUrl, presignedRequest.rawQueryParameters().get("PreSignedUrl").get(0)); } diff --git a/test/codegen-generated-classes-test/pom.xml b/test/codegen-generated-classes-test/pom.xml new file mode 100644 index 000000000000..de949e8418de --- /dev/null +++ b/test/codegen-generated-classes-test/pom.xml @@ -0,0 +1,153 @@ + + + 4.0.0 + + aws-sdk-java-pom + software.amazon.awssdk + 2.0.0-preview-11-SNAPSHOT + ../../pom.xml + + + codegen-generated-classes-test + AWS Java SDK :: Codegen Generated Classes Test + + Tests for code generated classes. + + https://aws.amazon.com/sdkforjava + + + ../.. + + + + + aws-core + software.amazon.awssdk + ${awsjavasdk.version} + + + apache-client + software.amazon.awssdk + ${awsjavasdk.version} + runtime + + + netty-nio-client + software.amazon.awssdk + ${awsjavasdk.version} + runtime + + + + junit + junit + test + + + com.github.tomakehurst + wiremock + test + + + log4j + log4j + test + + + org.slf4j + slf4j-log4j12 + test + + + software.amazon.awssdk + test-utils + ${awsjavasdk.version} + test + + + org.hamcrest + hamcrest-all + test + + + commons-io + commons-io + test + + + org.mockito + mockito-core + test + + + nl.jqno.equalsverifier + equalsverifier + test + + + org.unitils + unitils-core + test + + + software.amazon.awssdk + apache-client + ${awsjavasdk.version} + test + + + software.amazon.awssdk + utils + ${awsjavasdk.version} + + + org.assertj + assertj-core + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + software.amazon.awssdk + codegen-maven-plugin + ${awsjavasdk.version} + + + generate-sources + + generate + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + generate-sources + + add-resource + + + + + ${project.build.directory}/generated-sources/sdk + + + + + + + + + + diff --git a/test/codegen-generated-classes-test/src/main/resources/codegen-resources/autoconstructedlists/codegen.config b/test/codegen-generated-classes-test/src/main/resources/codegen-resources/autoconstructedlists/codegen.config new file mode 100644 index 000000000000..8b11a7a160b1 --- /dev/null +++ b/test/codegen-generated-classes-test/src/main/resources/codegen-resources/autoconstructedlists/codegen.config @@ -0,0 +1,5 @@ +{ + "serviceInterfaceName" : "AmazonCodeGenerationJsonRpcCustomized", + "packageSuffix" : "codegeneration.jsonrpc.customized", + "defaultEndpoint" : "https://code-generation-json-rpc-customized.us-east-1.amazonaws.com" +} diff --git a/test/codegen-generated-classes-test/src/main/resources/codegen-resources/autoconstructedlists/customization.config b/test/codegen-generated-classes-test/src/main/resources/codegen-resources/autoconstructedlists/customization.config new file mode 100644 index 000000000000..b832a525227a --- /dev/null +++ b/test/codegen-generated-classes-test/src/main/resources/codegen-resources/autoconstructedlists/customization.config @@ -0,0 +1,16 @@ +{ + "blacklistedSimpleMethods" : [ + "allTypes", + "nestedContainers", + "operationWithNoInputOrOutput" + ], + "convenienceTypeOverloads": [ + { + "shapeName": "AllTypesStructure", + "memberName": "BlobArg", + "convenienceType": "java.lang.String", + "typeAdapterFqcn": "software.amazon.awssdk.core.runtime.adapters.types.StringToByteBufferAdapter" + } + ], + "useAutoConstructList": true +} \ No newline at end of file diff --git a/test/codegen-generated-classes-test/src/main/resources/codegen-resources/autoconstructedlists/service-2.json b/test/codegen-generated-classes-test/src/main/resources/codegen-resources/autoconstructedlists/service-2.json new file mode 100644 index 000000000000..52f31fafabda --- /dev/null +++ b/test/codegen-generated-classes-test/src/main/resources/codegen-resources/autoconstructedlists/service-2.json @@ -0,0 +1,267 @@ +{ + "version":"2.0", + "metadata":{ + "apiVersion":"2016-03-11", + "endpointPrefix":"code-generation-json-rpc-customized", + "jsonVersion":"1.1", + "protocol":"json", + "serviceAbbreviation":"AmazonCodeGenerationJsonRpcCustomized", + "serviceFullName":"Amazon Code Generation Json Rpc Customized", + "signatureVersion":"v4", + "targetPrefix":"AmazonCodeGenerationJsonRpcCustomized", + "timestampFormat":"unixTimestamp" + }, + "operations":{ + "AllTypes":{ + "name":"AllTypes", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"AllTypesStructure"}, + "output":{"shape":"AllTypesStructure"}, + "errors":[ + {"shape":"EmptyModeledException"} + ] + }, + "NestedContainers":{ + "name":"NestedContainers", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"NestedContainersStructure"}, + "output":{"shape":"NestedContainersStructure"} + }, + "OperationWithNoInputOrOutput":{ + "name":"OperationWithNoInputOrOutput", + "http":{ + "method":"POST", + "requestUri":"/" + } + }, + "StreamingInputOperation":{ + "name":"StreamingInputOperation", + "http":{ + "method":"POST", + "requestUri":"/2016-03-11/streamingInputOperation" + }, + "input":{"shape":"StructureWithStreamingMember"} + }, + "StreamingOutputOperation":{ + "name":"StreamingOutputOperation", + "http":{ + "method":"POST", + "requestUri":"/2016-03-11/streamingOutputOperation" + }, + "output":{"shape":"StructureWithStreamingMember"} + } + }, + "shapes":{ + "AllTypesStructure":{ + "type":"structure", + "members":{ + "StringMember":{"shape":"String"}, + "IntegerMember":{"shape":"Integer"}, + "BooleanMember":{"shape":"Boolean"}, + "FloatMember":{"shape":"Float"}, + "DoubleMember":{"shape":"Double"}, + "LongMember":{"shape":"Long"}, + "SimpleList":{"shape":"ListOfStrings"}, + "ListOfEnums":{"shape":"ListOfEnums"}, + "ListOfMaps":{"shape":"ListOfMapStringToString"}, + "ListOfStructs":{"shape":"ListOfSimpleStructs"}, + "MapOfStringToIntegerList":{"shape":"MapOfStringToIntegerList"}, + "MapOfStringToString":{"shape":"MapOfStringToString"}, + "MapOfStringToSimpleStruct":{"shape":"MapOfStringToSimpleStruct"}, + "MapOfEnumToEnum":{"shape":"MapOfEnumToEnum"}, + "MapOfEnumToString":{"shape":"MapOfEnumToString"}, + "MapOfStringToEnum":{"shape":"MapOfStringToEnum"}, + "MapOfEnumToSimpleStruct":{"shape":"MapOfEnumToSimpleStruct"}, + "TimestampMember":{"shape":"Timestamp"}, + "StructWithNestedTimestampMember":{"shape":"StructWithTimestamp"}, + "BlobArg":{"shape":"BlobType"}, + "StructWithNestedBlob":{"shape":"StructWithNestedBlobType"}, + "BlobMap":{"shape":"BlobMapType"}, + "ListOfBlobs":{"shape":"ListOfBlobsType"}, + "RecursiveStruct":{"shape":"RecursiveStructType"}, + "PolymorphicTypeWithSubTypes":{"shape":"BaseType"}, + "PolymorphicTypeWithoutSubTypes":{"shape":"SubTypeOne"}, + "EnumType":{"shape":"EnumType"} + } + }, + "BaseType":{ + "type":"structure", + "members":{ + "BaseMember":{"shape":"String"} + } + }, + "BlobMapType":{ + "type":"map", + "key":{"shape":"String"}, + "value":{"shape":"BlobType"} + }, + "BlobType":{"type":"blob"}, + "Boolean":{"type":"boolean"}, + "Double":{"type":"double"}, + "EmptyModeledException":{ + "type":"structure", + "members":{ + }, + "exception":true + }, + "Float":{"type":"float"}, + "IdempotentOperationStructure":{ + "type":"structure", + "members":{ + "IdempotencyToken":{ + "shape":"String", + "idempotencyToken":true + } + } + }, + "Integer":{"type":"integer"}, + "ListOfBlobsType":{ + "type":"list", + "member":{"shape":"BlobType"} + }, + "ListOfIntegers":{ + "type":"list", + "member":{"shape":"Integer"} + }, + "ListOfListOfListOfStrings":{ + "type":"list", + "member":{"shape":"ListOfListOfStrings"} + }, + "ListOfListOfStrings":{ + "type":"list", + "member":{"shape":"ListOfStrings"} + }, + "ListOfMapStringToString":{ + "type":"list", + "member":{"shape":"MapOfStringToString"} + }, + "ListOfSimpleStructs":{ + "type":"list", + "member":{"shape":"SimpleStruct"} + }, + "ListOfStrings":{ + "type":"list", + "member":{"shape":"String"} + }, + "ListOfEnums":{ + "type":"list", + "member":{"shape":"EnumType"} + }, + "Long":{"type":"long"}, + "MapOfStringToIntegerList":{ + "type":"map", + "key":{"shape":"String"}, + "value":{"shape":"ListOfIntegers"} + }, + "MapOfStringToListOfListOfStrings":{ + "type":"map", + "key":{"shape":"String"}, + "value":{"shape":"ListOfListOfStrings"} + }, + "MapOfStringToSimpleStruct":{ + "type":"map", + "key":{"shape":"String"}, + "value":{"shape":"SimpleStruct"} + }, + "MapOfStringToString":{ + "type":"map", + "key":{"shape":"String"}, + "value":{"shape":"String"} + }, + "MapOfEnumToEnum":{ + "type":"map", + "key":{"shape":"EnumType"}, + "value":{"shape":"EnumType"} + }, + "MapOfEnumToString":{ + "type":"map", + "key":{"shape":"EnumType"}, + "value":{"shape":"String"} + }, + "MapOfStringToEnum":{ + "type":"map", + "key":{"shape":"String"}, + "value":{"shape":"EnumType"} + }, + "MapOfEnumToSimpleStruct":{ + "type":"map", + "key":{"shape":"EnumType"}, + "value":{"shape":"SimpleStruct"} + }, + "NestedContainersStructure":{ + "type":"structure", + "members":{ + "ListOfListOfStrings":{"shape":"ListOfListOfStrings"}, + "ListOfListOfListOfStrings":{"shape":"ListOfListOfListOfStrings"}, + "MapOfStringToListOfListOfStrings":{"shape":"MapOfStringToListOfListOfStrings"} + } + }, + "RecursiveListType":{ + "type":"list", + "member":{"shape":"RecursiveStructType"} + }, + "RecursiveMapType":{ + "type":"map", + "key":{"shape":"String"}, + "value":{"shape":"RecursiveStructType"} + }, + "RecursiveStructType":{ + "type":"structure", + "members":{ + "NoRecurse":{"shape":"String"}, + "RecursiveStruct":{"shape":"RecursiveStructType"}, + "RecursiveList":{"shape":"RecursiveListType"}, + "RecursiveMap":{"shape":"RecursiveMapType"} + } + }, + "SimpleStruct":{ + "type":"structure", + "members":{ + "StringMember":{"shape":"String"} + } + }, + "StreamType":{ + "type":"blob", + "streaming":true + }, + "String":{"type":"string"}, + "StructWithNestedBlobType":{ + "type":"structure", + "members":{ + "NestedBlob":{"shape":"BlobType"} + } + }, + "StructWithTimestamp":{ + "type":"structure", + "members":{ + "NestedTimestamp":{"shape":"Timestamp"} + } + }, + "StructureWithStreamingMember":{ + "type":"structure", + "members":{ + "StreamingMember":{"shape":"StreamType"} + }, + "payload":"StreamingMember" + }, + "SubTypeOne":{ + "type":"structure", + "members":{ + "SubTypeOneMember":{"shape":"String"} + } + }, + "EnumType": { + "type":"string", + "enum": [ + "EnumValue1", "EnumValue2" + ] + }, + "Timestamp":{"type":"timestamp"} + } +} diff --git a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/codegenerationjsonrpccustomized/model/ListCopierTest.java b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/codegenerationjsonrpccustomized/model/ListCopierTest.java new file mode 100644 index 000000000000..34c13ac522d9 --- /dev/null +++ b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/codegenerationjsonrpccustomized/model/ListCopierTest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2018 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.services.codegenerationjsonrpccustomized.model; + +import org.junit.Test; +import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList; +import software.amazon.awssdk.core.util.SdkAutoConstructList; + +import java.util.ArrayList; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for generated list member copiers. + */ +public class ListCopierTest { + @Test + public void nullParamsAreCopiedAsAutoConstructedList() { + assertThat(ListOfStringsCopier.copy(null)).isInstanceOf(SdkAutoConstructList.class); + } + + @Test + public void preservesAutoConstructedListInput() { + assertThat(ListOfStringsCopier.copy(DefaultSdkAutoConstructList.getInstance())).isInstanceOf(SdkAutoConstructList.class); + } + + @Test + public void explicitlyEmptyListsAreNotCopiedAsAutoConstructed() { + assertThat(ListOfStringsCopier.copy(new ArrayList<>())).isNotInstanceOf(SdkAutoConstructList.class); + } +} diff --git a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/codegenerationjsonrpccustomized/model/ModelBuilderListMemberTest.java b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/codegenerationjsonrpccustomized/model/ModelBuilderListMemberTest.java new file mode 100644 index 000000000000..e68019972037 --- /dev/null +++ b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/codegenerationjsonrpccustomized/model/ModelBuilderListMemberTest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2010-2018 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.services.codegenerationjsonrpccustomized.model; + +import org.junit.Test; +import software.amazon.awssdk.core.util.SdkAutoConstructList; + +import java.util.ArrayList; +import java.util.Collection; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Test for verifying list member behavior for model builders. + */ +public class ModelBuilderListMemberTest { + @Test + public void defaultConstructedModelsHaveInitialValue() { + AllTypesRequest request = AllTypesRequest.builder().build(); + + assertThat(request.listOfEnumsAsStrings()).isInstanceOf(SdkAutoConstructList.class); + } + + @Test + public void nullSetterCreatesSdkAutoConstructedList() { + AllTypesRequest request = AllTypesRequest.builder() + .listOfEnums((Collection) null) + .build(); + + assertThat(request.listOfEnumsAsStrings()).isInstanceOf(SdkAutoConstructList.class); + } + + @Test + public void modelToBuilderRoundTripPreservesAutoConstructedLists() { + AllTypesRequest request = AllTypesRequest.builder().build(); + AllTypesRequest roundTrip = request.toBuilder().build(); + + assertThat(roundTrip.listOfEnumsAsStrings()).isInstanceOf(SdkAutoConstructList.class); + } + + @Test + public void modelToBuilderRoundTripPreservesExplicitEmptyLists() { + AllTypesRequest request = AllTypesRequest.builder() + .listOfEnums(new ArrayList<>()) + .build(); + AllTypesRequest roundTrip = request.toBuilder().build(); + + assertThat(roundTrip.listOfEnumsAsStrings()).isNotInstanceOf(SdkAutoConstructList.class); + } +} diff --git a/test/protocol-tests/src/main/resources/codegen-resources/restxml/customization.config b/test/protocol-tests/src/main/resources/codegen-resources/restxml/customization.config index d43e77206f3b..d4c416cb9175 100644 --- a/test/protocol-tests/src/main/resources/codegen-resources/restxml/customization.config +++ b/test/protocol-tests/src/main/resources/codegen-resources/restxml/customization.config @@ -9,5 +9,7 @@ "operationWithModeledContentType", "queryParamWithoutValue", "restXmlTypes" - ] + ], + // FIXME: RestXml marshallers need to be made auto construct aware + "useAutoConstructList": false }