Skip to content

Use array for SetShape #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,6 @@ public Void arrayNode(ArrayNode node) {
String openElement = "[";
String closeElement = "]";

// Handle sets needing to use the Set typing instead of standard array syntax.
if (workingShape.isSetShape()) {
openElement = "new Set(" + openElement;
closeElement = closeElement + ")";
}

// Write the value out directly.
writer.openBlock("$L\n", closeElement + ",\n", openElement, () -> {
Shape wrapperShape = this.workingShape;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public Symbol listShape(ListShape shape) {
@Override
public Symbol setShape(SetShape shape) {
Symbol reference = toSymbol(shape.getMember());
return createSymbolBuilder(shape, format("Set<%s>", reference.getName()), null)
return createSymbolBuilder(shape, format("(%s)[]", reference.getName()), null)
.addReference(reference)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public final Void mapShape(MapShape shape) {
* const deserializeAws_restJson1_1ParameterSet = (
* output: any,
* context: SerdeContext
* ): Set<Parameter> => {
* ): Parameter[] => {
* return (output || []).map((entry: any) =>
* deserializeAws_restJson1_1Parameter(entry, context)
* );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public final Void mapShape(MapShape shape) {
*
* <pre>{@code
* const serializeAws_restJson1_1ParametersSet = (
* input: Set<Parameter>,
* input: Parameter[],
* context: SerdeContext
* ): any => {
* return (input || []).map(entry =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1397,10 +1397,6 @@ private String getCollectionOutputParam(
// Iterate over each entry and do deser work.
outputParam += ".map(_entry => " + collectionTargetValue + ")";

// Make sets when necessary.
if (target.isSetShape()) {
outputParam = "new Set(" + outputParam + ")";
}
return outputParam;
default:
throw new CodegenException("Unexpected collection binding location `" + bindingType + "`");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ const compareParts = (expectedParts: comparableParts, generatedParts: comparable
*/
const equivalentContents = (expected: any, generated: any): boolean => {
let localExpected = expected;
// Handle comparing sets to arrays properly.
if (expected instanceof Set) {
localExpected = Array.from(expected);
}

// Short circuit on equality.
if (localExpected == generated) {
Expand Down