Skip to content

Add short type support #2395

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 3 commits into from
Apr 16, 2021
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
6 changes: 6 additions & 0 deletions .changes/next-release/feature-AWSSDKforJavav2-70d4f4f.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "AWS SDK for Java v2",
"contributor": "duy310",
"description": "Added support for short type in Code generator."
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static final class TypeKey {
MARSHALLING_TYPE_MAPPINGS.put("Boolean", "BOOLEAN");
MARSHALLING_TYPE_MAPPINGS.put("BigDecimal", "BIG_DECIMAL");
MARSHALLING_TYPE_MAPPINGS.put("InputStream", "STREAM");
MARSHALLING_TYPE_MAPPINGS.put("Short", "SHORT");
MARSHALLING_TYPE_MAPPINGS.put(null, "NULL");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public final class AllTypesRequest extends JsonProtocolTestsRequest implements
.memberName("LongMember").getter(getter(AllTypesRequest::longMember)).setter(setter(Builder::longMember))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LongMember").build()).build();

private static final SdkField<Short> SHORT_MEMBER_FIELD = SdkField.<Short> builder(MarshallingType.SHORT)
.memberName("ShortMember").getter(getter(AllTypesRequest::shortMember)).setter(setter(Builder::shortMember))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ShortMember").build()).build();

private static final SdkField<List<String>> SIMPLE_LIST_FIELD = SdkField
.<List<String>> builder(MarshallingType.LIST)
.memberName("SimpleList")
Expand Down Expand Up @@ -422,7 +426,7 @@ SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES)

private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STRING_MEMBER_FIELD,
INTEGER_MEMBER_FIELD, BOOLEAN_MEMBER_FIELD, FLOAT_MEMBER_FIELD, DOUBLE_MEMBER_FIELD, LONG_MEMBER_FIELD,
SIMPLE_LIST_FIELD, LIST_OF_ENUMS_FIELD, LIST_OF_MAPS_FIELD, LIST_OF_STRUCTS_FIELD,
SHORT_MEMBER_FIELD, SIMPLE_LIST_FIELD, LIST_OF_ENUMS_FIELD, LIST_OF_MAPS_FIELD, LIST_OF_STRUCTS_FIELD,
LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD, LIST_OF_MAP_OF_STRING_TO_STRUCT_FIELD, MAP_OF_STRING_TO_INTEGER_LIST_FIELD,
MAP_OF_STRING_TO_STRING_FIELD, MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD, MAP_OF_ENUM_TO_ENUM_FIELD,
MAP_OF_ENUM_TO_STRING_FIELD, MAP_OF_STRING_TO_ENUM_FIELD, MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD,
Expand All @@ -443,6 +447,8 @@ SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES)

private final Long longMember;

private final Short shortMember;

private final List<String> simpleList;

private final List<String> listOfEnums;
Expand Down Expand Up @@ -503,6 +509,7 @@ private AllTypesRequest(BuilderImpl builder) {
this.floatMember = builder.floatMember;
this.doubleMember = builder.doubleMember;
this.longMember = builder.longMember;
this.shortMember = builder.shortMember;
this.simpleList = builder.simpleList;
this.listOfEnums = builder.listOfEnums;
this.listOfMaps = builder.listOfMaps;
Expand Down Expand Up @@ -585,6 +592,15 @@ public final Long longMember() {
return longMember;
}

/**
* Returns the value of the ShortMember property for this object.
*
* @return The value of the ShortMember property for this object.
*/
public final Short shortMember() {
return shortMember;
}

/**
* Returns true if the SimpleList property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
Expand Down Expand Up @@ -1232,6 +1248,7 @@ public final int hashCode() {
hashCode = 31 * hashCode + Objects.hashCode(floatMember());
hashCode = 31 * hashCode + Objects.hashCode(doubleMember());
hashCode = 31 * hashCode + Objects.hashCode(longMember());
hashCode = 31 * hashCode + Objects.hashCode(shortMember());
hashCode = 31 * hashCode + Objects.hashCode(hasSimpleList() ? simpleList() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasListOfEnums() ? listOfEnumsAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasListOfMaps() ? listOfMaps() : null);
Expand Down Expand Up @@ -1282,6 +1299,7 @@ public final boolean equalsBySdkFields(Object obj) {
return Objects.equals(stringMember(), other.stringMember()) && Objects.equals(integerMember(), other.integerMember())
&& Objects.equals(booleanMember(), other.booleanMember()) && Objects.equals(floatMember(), other.floatMember())
&& Objects.equals(doubleMember(), other.doubleMember()) && Objects.equals(longMember(), other.longMember())
&& Objects.equals(shortMember(), other.shortMember())
&& hasSimpleList() == other.hasSimpleList() && Objects.equals(simpleList(), other.simpleList())
&& hasListOfEnums() == other.hasListOfEnums()
&& Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings())
Expand Down Expand Up @@ -1336,6 +1354,7 @@ public final String toString() {
.add("FloatMember", floatMember())
.add("DoubleMember", doubleMember())
.add("LongMember", longMember())
.add("ShortMember", shortMember())
.add("SimpleList", hasSimpleList() ? simpleList() : null)
.add("ListOfEnums", hasListOfEnums() ? listOfEnumsAsStrings() : null)
.add("ListOfMaps", hasListOfMaps() ? listOfMaps() : null)
Expand Down Expand Up @@ -1375,6 +1394,8 @@ public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz)
return Optional.ofNullable(clazz.cast(doubleMember()));
case "LongMember":
return Optional.ofNullable(clazz.cast(longMember()));
case "ShortMember":
return Optional.ofNullable(clazz.cast(shortMember()));
case "SimpleList":
return Optional.ofNullable(clazz.cast(simpleList()));
case "ListOfEnums":
Expand Down Expand Up @@ -1500,6 +1521,15 @@ public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, Copy
*/
Builder longMember(Long longMember);

/**
* Sets the value of the ShortMember property for this object.
*
* @param shortMember
* The new value for the ShortMember property for this object.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder shortMember(Short shortMember);

/**
* Sets the value of the SimpleList property for this object.
*
Expand Down Expand Up @@ -2027,6 +2057,8 @@ static final class BuilderImpl extends JsonProtocolTestsRequest.BuilderImpl impl

private Long longMember;

private Short shortMember;

private List<String> simpleList = DefaultSdkAutoConstructList.getInstance();

private List<String> listOfEnums = DefaultSdkAutoConstructList.getInstance();
Expand Down Expand Up @@ -2090,6 +2122,7 @@ private BuilderImpl(AllTypesRequest model) {
floatMember(model.floatMember);
doubleMember(model.doubleMember);
longMember(model.longMember);
shortMember(model.shortMember);
simpleList(model.simpleList);
listOfEnumsWithStrings(model.listOfEnums);
listOfMaps(model.listOfMaps);
Expand Down Expand Up @@ -2202,6 +2235,20 @@ public final void setLongMember(Long longMember) {
this.longMember = longMember;
}

public final Short getShortMember() {
return shortMember;
}

@Override
public final Builder shortMember(Short shortMember) {
this.shortMember = shortMember;
return this;
}

public final void setShortMember(Short shortMember) {
this.shortMember = shortMember;
}

public final Collection<String> getSimpleList() {
if (simpleList instanceof SdkAutoConstructList) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public final class AllTypesResponse extends JsonProtocolTestsResponse implements
.memberName("LongMember").getter(getter(AllTypesResponse::longMember)).setter(setter(Builder::longMember))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LongMember").build()).build();

private static final SdkField<Short> SHORT_MEMBER_FIELD = SdkField.<Short> builder(MarshallingType.SHORT)
.memberName("ShortMember").getter(getter(AllTypesResponse::shortMember)).setter(setter(Builder::shortMember))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ShortMember").build()).build();

private static final SdkField<List<String>> SIMPLE_LIST_FIELD = SdkField
.<List<String>> builder(MarshallingType.LIST)
.memberName("SimpleList")
Expand Down Expand Up @@ -421,7 +425,7 @@ SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES)

private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STRING_MEMBER_FIELD,
INTEGER_MEMBER_FIELD, BOOLEAN_MEMBER_FIELD, FLOAT_MEMBER_FIELD, DOUBLE_MEMBER_FIELD, LONG_MEMBER_FIELD,
SIMPLE_LIST_FIELD, LIST_OF_ENUMS_FIELD, LIST_OF_MAPS_FIELD, LIST_OF_STRUCTS_FIELD,
SHORT_MEMBER_FIELD, SIMPLE_LIST_FIELD, LIST_OF_ENUMS_FIELD, LIST_OF_MAPS_FIELD, LIST_OF_STRUCTS_FIELD,
LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD, LIST_OF_MAP_OF_STRING_TO_STRUCT_FIELD, MAP_OF_STRING_TO_INTEGER_LIST_FIELD,
MAP_OF_STRING_TO_STRING_FIELD, MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD, MAP_OF_ENUM_TO_ENUM_FIELD,
MAP_OF_ENUM_TO_STRING_FIELD, MAP_OF_STRING_TO_ENUM_FIELD, MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD,
Expand All @@ -442,6 +446,8 @@ SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES)

private final Long longMember;

private final Short shortMember;

private final List<String> simpleList;

private final List<String> listOfEnums;
Expand Down Expand Up @@ -502,6 +508,7 @@ private AllTypesResponse(BuilderImpl builder) {
this.floatMember = builder.floatMember;
this.doubleMember = builder.doubleMember;
this.longMember = builder.longMember;
this.shortMember = builder.shortMember;
this.simpleList = builder.simpleList;
this.listOfEnums = builder.listOfEnums;
this.listOfMaps = builder.listOfMaps;
Expand Down Expand Up @@ -584,6 +591,15 @@ public final Long longMember() {
return longMember;
}

/**
* Returns the value of the ShortMember property for this object.
*
* @return The value of the ShortMember property for this object.
*/
public final Short shortMember() {
return shortMember;
}

/**
* Returns true if the SimpleList property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
Expand Down Expand Up @@ -1231,6 +1247,7 @@ public final int hashCode() {
hashCode = 31 * hashCode + Objects.hashCode(floatMember());
hashCode = 31 * hashCode + Objects.hashCode(doubleMember());
hashCode = 31 * hashCode + Objects.hashCode(longMember());
hashCode = 31 * hashCode + Objects.hashCode(shortMember());
hashCode = 31 * hashCode + Objects.hashCode(hasSimpleList() ? simpleList() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasListOfEnums() ? listOfEnumsAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasListOfMaps() ? listOfMaps() : null);
Expand Down Expand Up @@ -1281,6 +1298,7 @@ public final boolean equalsBySdkFields(Object obj) {
return Objects.equals(stringMember(), other.stringMember()) && Objects.equals(integerMember(), other.integerMember())
&& Objects.equals(booleanMember(), other.booleanMember()) && Objects.equals(floatMember(), other.floatMember())
&& Objects.equals(doubleMember(), other.doubleMember()) && Objects.equals(longMember(), other.longMember())
&& Objects.equals(shortMember(), other.shortMember())
&& hasSimpleList() == other.hasSimpleList() && Objects.equals(simpleList(), other.simpleList())
&& hasListOfEnums() == other.hasListOfEnums()
&& Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings())
Expand Down Expand Up @@ -1335,6 +1353,7 @@ public final String toString() {
.add("FloatMember", floatMember())
.add("DoubleMember", doubleMember())
.add("LongMember", longMember())
.add("ShortMember", shortMember())
.add("SimpleList", hasSimpleList() ? simpleList() : null)
.add("ListOfEnums", hasListOfEnums() ? listOfEnumsAsStrings() : null)
.add("ListOfMaps", hasListOfMaps() ? listOfMaps() : null)
Expand Down Expand Up @@ -1374,6 +1393,8 @@ public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz)
return Optional.ofNullable(clazz.cast(doubleMember()));
case "LongMember":
return Optional.ofNullable(clazz.cast(longMember()));
case "ShortMember":
return Optional.ofNullable(clazz.cast(shortMember()));
case "SimpleList":
return Optional.ofNullable(clazz.cast(simpleList()));
case "ListOfEnums":
Expand Down Expand Up @@ -1499,6 +1520,15 @@ public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, Cop
*/
Builder longMember(Long longMember);

/**
* Sets the value of the ShortMember property for this object.
*
* @param shortMember
* The new value for the ShortMember property for this object.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder shortMember(Short shortMember);

/**
* Sets the value of the SimpleList property for this object.
*
Expand Down Expand Up @@ -2020,6 +2050,8 @@ static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl imp

private Long longMember;

private Short shortMember;

private List<String> simpleList = DefaultSdkAutoConstructList.getInstance();

private List<String> listOfEnums = DefaultSdkAutoConstructList.getInstance();
Expand Down Expand Up @@ -2083,6 +2115,7 @@ private BuilderImpl(AllTypesResponse model) {
floatMember(model.floatMember);
doubleMember(model.doubleMember);
longMember(model.longMember);
shortMember(model.shortMember);
simpleList(model.simpleList);
listOfEnumsWithStrings(model.listOfEnums);
listOfMaps(model.listOfMaps);
Expand Down Expand Up @@ -2195,6 +2228,20 @@ public final void setLongMember(Long longMember) {
this.longMember = longMember;
}

public final Short getShortMember() {
return shortMember;
}

@Override
public final Builder shortMember(Short shortMember) {
this.shortMember = shortMember;
return this;
}

public final void setShortMember(Short shortMember) {
this.shortMember = shortMember;
}

public final Collection<String> getSimpleList() {
if (simpleList instanceof SdkAutoConstructList) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"FloatMember":{"shape":"Float"},
"DoubleMember":{"shape":"Double"},
"LongMember":{"shape":"Long"},
"ShortMember":{"shape":"Short"},
"SimpleList":{"shape":"ListOfStrings"},
"ListOfEnums":{"shape":"ListOfEnums"},
"ListOfMaps":{"shape":"ListOfMapStringToString"},
Expand Down Expand Up @@ -246,6 +247,7 @@
"member":{"shape":"MapOfStringToSimpleStruct"}
},
"Long":{"type":"long"},
"Short":{"type":"short"},
"MapOfStringToIntegerList":{
"type":"map",
"key":{"shape":"String"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"FloatMember":{"shape":"Float"},
"DoubleMember":{"shape":"Double"},
"LongMember":{"shape":"Long"},
"ShortMember":{"shape":"Short"},
"SimpleList":{"shape":"ListOfStrings"},
"ListOfEnums":{"shape":"ListOfEnums"},
"ListOfMaps":{"shape":"ListOfMapStringToString"},
Expand Down Expand Up @@ -198,6 +199,7 @@
"member":{"shape":"EnumType"}
},
"Long":{"type":"long"},
"Short":{"type":"short"},
"MapOfStringToIntegerList":{
"type":"map",
"key":{"shape":"String"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"FloatMember":{"shape":"Float"},
"DoubleMember":{"shape":"Double"},
"LongMember":{"shape":"Long"},
"ShortMember":{"shape":"Short"},
"SimpleList":{"shape":"ListOfStrings"},
"ListOfEnums":{"shape":"ListOfEnums"},
"ListOfMaps":{"shape":"ListOfMapStringToString"},
Expand Down Expand Up @@ -179,6 +180,7 @@
"member":{"shape":"EnumType"}
},
"Long":{"type":"long"},
"Short":{"type":"short"},
"MapOfStringToIntegerList":{
"type":"map",
"key":{"shape":"String"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public final class HeaderMarshaller {

public static final JsonMarshaller<Long> LONG = new SimpleHeaderMarshaller<>(ValueToStringConverter.FROM_LONG);

public static final JsonMarshaller<Short> SHORT = new SimpleHeaderMarshaller<>(ValueToStringConverter.FROM_SHORT);

public static final JsonMarshaller<Double> DOUBLE = new SimpleHeaderMarshaller<>(ValueToStringConverter.FROM_DOUBLE);

public static final JsonMarshaller<Float> FLOAT = new SimpleHeaderMarshaller<>(ValueToStringConverter.FROM_FLOAT);
Expand Down
Loading