Skip to content

Allow subtypes of Map for Collection elements #743

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 1 commit into from
Oct 2, 2018
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 @@ -201,7 +201,7 @@ public FieldSpec asField(MemberModel memberModel, Modifier... modifiers) {
private TypeName listParameterType(ListModel listModel) {
MemberModel elementModel = listModel.getListMemberModel();
TypeName listElementType = parameterType(elementModel);
if (elementModel.isList()) {
if (isContainerType(elementModel)) {
listElementType = WildcardTypeName.subtypeOf(listElementType);
}
return ParameterizedTypeName.get(ClassName.get(Collection.class), listElementType);
Expand All @@ -227,4 +227,8 @@ private TypeName mapValueParameterType(MapModel mapModel) {

return valueType;
}

private static boolean isContainerType(MemberModel m) {
return m.isList() || m.isMap();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ public interface Builder extends JsonProtocolTestsRequest.Builder, CopyableBuild
* 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<Map<String, String>> listOfMaps);
Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps);

/**
* Sets the value of the ListOfMaps property for this object.
Expand Down Expand Up @@ -1341,12 +1341,12 @@ public final void setListOfEnums(Collection<String> listOfEnums) {
this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums);
}

public final Collection<Map<String, String>> getListOfMaps() {
public final Collection<? extends Map<String, String>> getListOfMaps() {
return listOfMaps;
}

@Override
public final Builder listOfMaps(Collection<Map<String, String>> listOfMaps) {
public final Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps) {
this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps);
return this;
}
Expand All @@ -1358,7 +1358,7 @@ public final Builder listOfMaps(Map<String, String>... listOfMaps) {
return this;
}

public final void setListOfMaps(Collection<Map<String, String>> listOfMaps) {
public final void setListOfMaps(Collection<? extends Map<String, String>> listOfMaps) {
this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ public interface Builder extends JsonProtocolTestsResponse.Builder, CopyableBuil
* 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<Map<String, String>> listOfMaps);
Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps);

/**
* Sets the value of the ListOfMaps property for this object.
Expand Down Expand Up @@ -1334,12 +1334,12 @@ public final void setListOfEnums(Collection<String> listOfEnums) {
this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums);
}

public final Collection<Map<String, String>> getListOfMaps() {
public final Collection<? extends Map<String, String>> getListOfMaps() {
return listOfMaps;
}

@Override
public final Builder listOfMaps(Collection<Map<String, String>> listOfMaps) {
public final Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps) {
this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps);
return this;
}
Expand All @@ -1351,7 +1351,7 @@ public final Builder listOfMaps(Map<String, String>... listOfMaps) {
return this;
}

public final void setListOfMaps(Collection<Map<String, String>> listOfMaps) {
public final void setListOfMaps(Collection<? extends Map<String, String>> listOfMaps) {
this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@Generated("software.amazon.awssdk:codegen")
final class ListOfMapStringToStringCopier {
static List<Map<String, String>> copy(Collection<Map<String, String>> listOfMapStringToStringParam) {
static List<Map<String, String>> copy(Collection<? extends Map<String, String>> listOfMapStringToStringParam) {
if (listOfMapStringToStringParam == null || listOfMapStringToStringParam instanceof SdkAutoConstructList) {
return DefaultSdkAutoConstructList.getInstance();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ public interface Builder extends JsonProtocolTestsRequest.Builder, CopyableBuild
* 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<Map<String, String>> listOfMaps);
Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps);

/**
* Sets the value of the ListOfMaps property for this object.
Expand Down Expand Up @@ -1339,12 +1339,12 @@ public final void setListOfEnums(Collection<String> listOfEnums) {
this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums);
}

public final Collection<Map<String, String>> getListOfMaps() {
public final Collection<? extends Map<String, String>> getListOfMaps() {
return listOfMaps;
}

@Override
public final Builder listOfMaps(Collection<Map<String, String>> listOfMaps) {
public final Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps) {
this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps);
return this;
}
Expand All @@ -1356,7 +1356,7 @@ public final Builder listOfMaps(Map<String, String>... listOfMaps) {
return this;
}

public final void setListOfMaps(Collection<Map<String, String>> listOfMaps) {
public final void setListOfMaps(Collection<? extends Map<String, String>> listOfMaps) {
this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ public interface Builder extends JsonProtocolTestsResponse.Builder, CopyableBuil
* 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<Map<String, String>> listOfMaps);
Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps);

/**
* Sets the value of the ListOfMaps property for this object.
Expand Down Expand Up @@ -1332,12 +1332,12 @@ public final void setListOfEnums(Collection<String> listOfEnums) {
this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums);
}

public final Collection<Map<String, String>> getListOfMaps() {
public final Collection<? extends Map<String, String>> getListOfMaps() {
return listOfMaps;
}

@Override
public final Builder listOfMaps(Collection<Map<String, String>> listOfMaps) {
public final Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps) {
this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps);
return this;
}
Expand All @@ -1349,7 +1349,7 @@ public final Builder listOfMaps(Map<String, String>... listOfMaps) {
return this;
}

public final void setListOfMaps(Collection<Map<String, String>> listOfMaps) {
public final void setListOfMaps(Collection<? extends Map<String, String>> listOfMaps) {
this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Generated("software.amazon.awssdk:codegen")
final class ListOfMapStringToStringCopier {
static List<Map<String, String>> copy(Collection<Map<String, String>> listOfMapStringToStringParam) {
static List<Map<String, String>> copy(Collection<? extends Map<String, String>> listOfMapStringToStringParam) {
if (listOfMapStringToStringParam == null) {
return null;
}
Expand Down