Skip to content

Commit 5538421

Browse files
author
ci.datadog-api-spec
committed
pre-commit fixes
1 parent ab2ee70 commit 5538421

File tree

3 files changed

+12
-84
lines changed

3 files changed

+12
-84
lines changed

src/main/java/com/datadog/api/client/v1/model/DistributionPointItem.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,29 +125,11 @@ public DistributionPointItem deserialize(JsonParser jp, DeserializationContext c
125125
try {
126126
boolean attemptParsing = true;
127127
// ensure that we respect type coercion as set on the client ObjectMapper
128-
if (List.class.equals(Integer.class)
129-
|| List.class.equals(Long.class)
130-
|| List.class.equals(Float.class)
131-
|| List.class.equals(Double.class)
132-
|| List.class.equals(Boolean.class)
133-
|| List.class.equals(String.class)) {
134-
attemptParsing = typeCoercion;
135-
if (!attemptParsing) {
136-
attemptParsing |=
137-
((List.class.equals(Integer.class) || List.class.equals(Long.class))
138-
&& token == JsonToken.VALUE_NUMBER_INT);
139-
attemptParsing |=
140-
((List.class.equals(Float.class) || List.class.equals(Double.class))
141-
&& (token == JsonToken.VALUE_NUMBER_FLOAT
142-
|| token == JsonToken.VALUE_NUMBER_INT));
143-
attemptParsing |=
144-
(List.class.equals(Boolean.class)
145-
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
146-
attemptParsing |= (List.class.equals(String.class) && token == JsonToken.VALUE_STRING);
147-
}
128+
if (token != JsonToken.START_ARRAY) {
129+
attemptParsing = false;
148130
}
149131
if (attemptParsing) {
150-
tmp = tree.traverse(jp.getCodec()).readValueAs(List.class);
132+
tmp = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<>() {});
151133
// TODO: there is no validation against JSON schema constraints
152134
// (min, max, enum, pattern...), this does not perform a strict JSON
153135
// validation, which means the 'match' count may be higher than it should be.

src/main/java/com/datadog/api/client/v1/model/SharedDashboardInvitesData.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,29 +131,11 @@ public SharedDashboardInvitesData deserialize(JsonParser jp, DeserializationCont
131131
try {
132132
boolean attemptParsing = true;
133133
// ensure that we respect type coercion as set on the client ObjectMapper
134-
if (List.class.equals(Integer.class)
135-
|| List.class.equals(Long.class)
136-
|| List.class.equals(Float.class)
137-
|| List.class.equals(Double.class)
138-
|| List.class.equals(Boolean.class)
139-
|| List.class.equals(String.class)) {
140-
attemptParsing = typeCoercion;
141-
if (!attemptParsing) {
142-
attemptParsing |=
143-
((List.class.equals(Integer.class) || List.class.equals(Long.class))
144-
&& token == JsonToken.VALUE_NUMBER_INT);
145-
attemptParsing |=
146-
((List.class.equals(Float.class) || List.class.equals(Double.class))
147-
&& (token == JsonToken.VALUE_NUMBER_FLOAT
148-
|| token == JsonToken.VALUE_NUMBER_INT));
149-
attemptParsing |=
150-
(List.class.equals(Boolean.class)
151-
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
152-
attemptParsing |= (List.class.equals(String.class) && token == JsonToken.VALUE_STRING);
153-
}
134+
if (token != JsonToken.START_ARRAY) {
135+
attemptParsing = false;
154136
}
155137
if (attemptParsing) {
156-
tmp = tree.traverse(jp.getCodec()).readValueAs(List.class);
138+
tmp = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<>() {});
157139
// TODO: there is no validation against JSON schema constraints
158140
// (min, max, enum, pattern...), this does not perform a strict JSON
159141
// validation, which means the 'match' count may be higher than it should be.

src/main/java/com/datadog/api/client/v2/model/CustomAttributeValuesUnion.java

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -126,29 +126,11 @@ public CustomAttributeValuesUnion deserialize(JsonParser jp, DeserializationCont
126126
try {
127127
boolean attemptParsing = true;
128128
// ensure that we respect type coercion as set on the client ObjectMapper
129-
if (List.class.equals(Integer.class)
130-
|| List.class.equals(Long.class)
131-
|| List.class.equals(Float.class)
132-
|| List.class.equals(Double.class)
133-
|| List.class.equals(Boolean.class)
134-
|| List.class.equals(String.class)) {
135-
attemptParsing = typeCoercion;
136-
if (!attemptParsing) {
137-
attemptParsing |=
138-
((List.class.equals(Integer.class) || List.class.equals(Long.class))
139-
&& token == JsonToken.VALUE_NUMBER_INT);
140-
attemptParsing |=
141-
((List.class.equals(Float.class) || List.class.equals(Double.class))
142-
&& (token == JsonToken.VALUE_NUMBER_FLOAT
143-
|| token == JsonToken.VALUE_NUMBER_INT));
144-
attemptParsing |=
145-
(List.class.equals(Boolean.class)
146-
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
147-
attemptParsing |= (List.class.equals(String.class) && token == JsonToken.VALUE_STRING);
148-
}
129+
if (token != JsonToken.START_ARRAY) {
130+
attemptParsing = false;
149131
}
150132
if (attemptParsing) {
151-
tmp = tree.traverse(jp.getCodec()).readValueAs(List.class);
133+
tmp = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<>() {});
152134
// TODO: there is no validation against JSON schema constraints
153135
// (min, max, enum, pattern...), this does not perform a strict JSON
154136
// validation, which means the 'match' count may be higher than it should be.
@@ -207,29 +189,11 @@ public CustomAttributeValuesUnion deserialize(JsonParser jp, DeserializationCont
207189
try {
208190
boolean attemptParsing = true;
209191
// ensure that we respect type coercion as set on the client ObjectMapper
210-
if (List.class.equals(Integer.class)
211-
|| List.class.equals(Long.class)
212-
|| List.class.equals(Float.class)
213-
|| List.class.equals(Double.class)
214-
|| List.class.equals(Boolean.class)
215-
|| List.class.equals(String.class)) {
216-
attemptParsing = typeCoercion;
217-
if (!attemptParsing) {
218-
attemptParsing |=
219-
((List.class.equals(Integer.class) || List.class.equals(Long.class))
220-
&& token == JsonToken.VALUE_NUMBER_INT);
221-
attemptParsing |=
222-
((List.class.equals(Float.class) || List.class.equals(Double.class))
223-
&& (token == JsonToken.VALUE_NUMBER_FLOAT
224-
|| token == JsonToken.VALUE_NUMBER_INT));
225-
attemptParsing |=
226-
(List.class.equals(Boolean.class)
227-
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
228-
attemptParsing |= (List.class.equals(String.class) && token == JsonToken.VALUE_STRING);
229-
}
192+
if (token != JsonToken.START_ARRAY) {
193+
attemptParsing = false;
230194
}
231195
if (attemptParsing) {
232-
tmp = tree.traverse(jp.getCodec()).readValueAs(List.class);
196+
tmp = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<>() {});
233197
// TODO: there is no validation against JSON schema constraints
234198
// (min, max, enum, pattern...), this does not perform a strict JSON
235199
// validation, which means the 'match' count may be higher than it should be.

0 commit comments

Comments
 (0)