Skip to content

Commit 9cf147f

Browse files
sreeshaswing328
authored andcommitted
[Java] Change Boolean fields of CodegenParameter and CodegenResponse to boolean. (#4747)
CodegenOperation and CodegenProperty classes have boolean fields instead of Boolean. This fix changes Boolean fields of CodegenParameter and CodegenResponse to boolean as well. Boolean fields are not necessary. Other classes interacting with them have to check for null before interacting with them which is unnecessary and leads to ugly code.
1 parent 8f2e9bc commit 9cf147f

File tree

8 files changed

+113
-118
lines changed

8 files changed

+113
-118
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,29 @@
66
import java.util.List;
77

88
public class CodegenParameter {
9-
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
9+
public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
1010
isCookieParam, isBodyParam, hasMore, isContainer,
1111
secondaryParam, isCollectionFormatMulti, isPrimitiveType;
12-
public String baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName;
12+
public String baseName, paramName, dataType, datatypeWithEnum, dataFormat,
13+
collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName;
1314
public String example; // example value (x-example)
1415
public String jsonSchema;
15-
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
16-
public Boolean isListContainer, isMapContainer;
17-
public Boolean isFile, notFile;
16+
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
17+
public boolean isListContainer, isMapContainer;
18+
public boolean isFile, notFile;
1819
public boolean isEnum;
1920
public List<String> _enum;
2021
public Map<String, Object> allowableValues;
2122
public CodegenProperty items;
2223
public Map<String, Object> vendorExtensions;
23-
public Boolean hasValidation;
24+
public boolean hasValidation;
2425

2526
/**
2627
* Determines whether this parameter is mandatory. If the parameter is in "path",
2728
* this property is required and its value MUST be true. Otherwise, the property
2829
* MAY be included and its default value is false.
2930
*/
30-
public Boolean required;
31+
public boolean required;
3132

3233
/**
3334
* See http://json-schema.org/latest/json-schema-validation.html#anchor17.
@@ -36,15 +37,15 @@ public class CodegenParameter {
3637
/**
3738
* See http://json-schema.org/latest/json-schema-validation.html#anchor17
3839
*/
39-
public Boolean exclusiveMaximum;
40+
public boolean exclusiveMaximum;
4041
/**
4142
* See http://json-schema.org/latest/json-schema-validation.html#anchor21
4243
*/
4344
public String minimum;
4445
/**
4546
* See http://json-schema.org/latest/json-schema-validation.html#anchor21
4647
*/
47-
public Boolean exclusiveMinimum;
48+
public boolean exclusiveMinimum;
4849
/**
4950
* See http://json-schema.org/latest/json-schema-validation.html#anchor26
5051
*/
@@ -68,7 +69,7 @@ public class CodegenParameter {
6869
/**
6970
* See http://json-schema.org/latest/json-schema-validation.html#anchor49
7071
*/
71-
public Boolean uniqueItems;
72+
public boolean uniqueItems;
7273
/**
7374
* See http://json-schema.org/latest/json-schema-validation.html#anchor14
7475
*/
@@ -156,27 +157,27 @@ public boolean equals(Object o) {
156157
CodegenParameter that = (CodegenParameter) o;
157158

158159
if (isEnum != that.isEnum) return false;
159-
if (isFormParam != null ? !isFormParam.equals(that.isFormParam) : that.isFormParam != null)
160+
if (isFormParam != that.isFormParam)
160161
return false;
161-
if (isQueryParam != null ? !isQueryParam.equals(that.isQueryParam) : that.isQueryParam != null)
162+
if (isQueryParam != that.isQueryParam)
162163
return false;
163-
if (isPathParam != null ? !isPathParam.equals(that.isPathParam) : that.isPathParam != null)
164+
if (isPathParam != that.isPathParam)
164165
return false;
165-
if (isHeaderParam != null ? !isHeaderParam.equals(that.isHeaderParam) : that.isHeaderParam != null)
166+
if (isHeaderParam != that.isHeaderParam)
166167
return false;
167-
if (isCookieParam != null ? !isCookieParam.equals(that.isCookieParam) : that.isCookieParam != null)
168+
if (isCookieParam != that.isCookieParam)
168169
return false;
169-
if (isBodyParam != null ? !isBodyParam.equals(that.isBodyParam) : that.isBodyParam != null)
170+
if (isBodyParam != that.isBodyParam)
170171
return false;
171-
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
172+
if (hasMore != that.hasMore)
172173
return false;
173-
if (isContainer != null ? !isContainer.equals(that.isContainer) : that.isContainer != null)
174+
if (isContainer != that.isContainer)
174175
return false;
175-
if (secondaryParam != null ? !secondaryParam.equals(that.secondaryParam) : that.secondaryParam != null)
176+
if (secondaryParam != that.secondaryParam)
176177
return false;
177-
if (isCollectionFormatMulti != null ? !isCollectionFormatMulti.equals(that.isCollectionFormatMulti) : that.isCollectionFormatMulti != null)
178+
if (isCollectionFormatMulti != that.isCollectionFormatMulti)
178179
return false;
179-
if (isPrimitiveType != null ? !isPrimitiveType.equals(that.isPrimitiveType) : that.isPrimitiveType != null)
180+
if (isPrimitiveType != that.isPrimitiveType)
180181
return false;
181182
if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null)
182183
return false;
@@ -204,33 +205,33 @@ public boolean equals(Object o) {
204205
return false;
205206
if (jsonSchema != null ? !jsonSchema.equals(that.jsonSchema) : that.jsonSchema != null)
206207
return false;
207-
if (isString != null ? !isString.equals(that.isString) : that.isString != null)
208+
if (isString != that.isString)
208209
return false;
209-
if (isInteger != null ? !isInteger.equals(that.isInteger) : that.isInteger != null)
210+
if (isInteger != that.isInteger)
210211
return false;
211-
if (isLong != null ? !isLong.equals(that.isLong) : that.isLong != null)
212+
if (isLong != that.isLong)
212213
return false;
213-
if (isFloat != null ? !isFloat.equals(that.isFloat) : that.isFloat != null)
214+
if (isFloat != that.isFloat)
214215
return false;
215-
if (isDouble != null ? !isDouble.equals(that.isDouble) : that.isDouble != null)
216+
if (isDouble != that.isDouble)
216217
return false;
217-
if (isByteArray != null ? !isByteArray.equals(that.isByteArray) : that.isByteArray != null)
218+
if (isByteArray != that.isByteArray)
218219
return false;
219-
if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null)
220+
if (isBinary != that.isBinary)
220221
return false;
221-
if (isBoolean != null ? !isBoolean.equals(that.isBoolean) : that.isBoolean != null)
222+
if (isBoolean != that.isBoolean)
222223
return false;
223-
if (isDate != null ? !isDate.equals(that.isDate) : that.isDate != null)
224+
if (isDate != that.isDate)
224225
return false;
225-
if (isDateTime != null ? !isDateTime.equals(that.isDateTime) : that.isDateTime != null)
226+
if (isDateTime != that.isDateTime)
226227
return false;
227-
if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null)
228+
if (isListContainer != that.isListContainer)
228229
return false;
229-
if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null)
230+
if (isMapContainer != that.isMapContainer)
230231
return false;
231-
if (isFile != null ? !isFile.equals(that.isFile) : that.isFile != null)
232+
if (isFile != that.isFile)
232233
return false;
233-
if (notFile != null ? !notFile.equals(that.notFile) : that.notFile != null)
234+
if (notFile != that.notFile)
234235
return false;
235236
if (_enum != null ? !_enum.equals(that._enum) : that._enum != null)
236237
return false;
@@ -240,17 +241,17 @@ public boolean equals(Object o) {
240241
return false;
241242
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null)
242243
return false;
243-
if (hasValidation != null ? !hasValidation.equals(that.hasValidation) : that.hasValidation != null)
244+
if (hasValidation != that.hasValidation)
244245
return false;
245-
if (required != null ? !required.equals(that.required) : that.required != null)
246+
if (required != that.required)
246247
return false;
247248
if (maximum != null ? !maximum.equals(that.maximum) : that.maximum != null)
248249
return false;
249-
if (exclusiveMaximum != null ? !exclusiveMaximum.equals(that.exclusiveMaximum) : that.exclusiveMaximum != null)
250+
if (exclusiveMaximum != that.exclusiveMaximum)
250251
return false;
251252
if (minimum != null ? !minimum.equals(that.minimum) : that.minimum != null)
252253
return false;
253-
if (exclusiveMinimum != null ? !exclusiveMinimum.equals(that.exclusiveMinimum) : that.exclusiveMinimum != null)
254+
if (exclusiveMinimum != that.exclusiveMinimum)
254255
return false;
255256
if (maxLength != null ? !maxLength.equals(that.maxLength) : that.maxLength != null)
256257
return false;
@@ -262,25 +263,25 @@ public boolean equals(Object o) {
262263
return false;
263264
if (minItems != null ? !minItems.equals(that.minItems) : that.minItems != null)
264265
return false;
265-
if (uniqueItems != null ? !uniqueItems.equals(that.uniqueItems) : that.uniqueItems != null)
266+
if (uniqueItems != that.uniqueItems)
266267
return false;
267268
return multipleOf != null ? multipleOf.equals(that.multipleOf) : that.multipleOf == null;
268269

269270
}
270271

271272
@Override
272273
public int hashCode() {
273-
int result = isFormParam != null ? isFormParam.hashCode() : 0;
274-
result = 31 * result + (isQueryParam != null ? isQueryParam.hashCode() : 0);
275-
result = 31 * result + (isPathParam != null ? isPathParam.hashCode() : 0);
276-
result = 31 * result + (isHeaderParam != null ? isHeaderParam.hashCode() : 0);
277-
result = 31 * result + (isCookieParam != null ? isCookieParam.hashCode() : 0);
278-
result = 31 * result + (isBodyParam != null ? isBodyParam.hashCode() : 0);
279-
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
280-
result = 31 * result + (isContainer != null ? isContainer.hashCode() : 0);
281-
result = 31 * result + (secondaryParam != null ? secondaryParam.hashCode() : 0);
282-
result = 31 * result + (isCollectionFormatMulti != null ? isCollectionFormatMulti.hashCode() : 0);
283-
result = 31 * result + (isPrimitiveType != null ? isPrimitiveType.hashCode() : 0);
274+
int result = isFormParam ? 13:31;
275+
result = 31 * result + (isQueryParam ? 13:31);
276+
result = 31 * result + (isPathParam ? 13:31);
277+
result = 31 * result + (isHeaderParam ? 13:31);
278+
result = 31 * result + (isCookieParam ? 13:31);
279+
result = 31 * result + (isBodyParam ? 13:31);
280+
result = 31 * result + (hasMore ? 13:31);
281+
result = 31 * result + (isContainer ? 13:31);
282+
result = 31 * result + (secondaryParam ? 13:31);
283+
result = 31 * result + (isCollectionFormatMulti ? 13:31);
284+
result = 31 * result + (isPrimitiveType ? 13:31);
284285
result = 31 * result + (baseName != null ? baseName.hashCode() : 0);
285286
result = 31 * result + (paramName != null ? paramName.hashCode() : 0);
286287
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
@@ -294,37 +295,37 @@ public int hashCode() {
294295
result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
295296
result = 31 * result + (example != null ? example.hashCode() : 0);
296297
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
297-
result = 31 * result + (isString != null ? isString.hashCode() : 0);
298-
result = 31 * result + (isInteger != null ? isInteger.hashCode() : 0);
299-
result = 31 * result + (isLong != null ? isLong.hashCode() : 0);
300-
result = 31 * result + (isFloat != null ? isFloat.hashCode() : 0);
301-
result = 31 * result + (isDouble != null ? isDouble.hashCode() : 0);
302-
result = 31 * result + (isByteArray != null ? isByteArray.hashCode() : 0);
303-
result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0);
304-
result = 31 * result + (isBoolean != null ? isBoolean.hashCode() : 0);
305-
result = 31 * result + (isDate != null ? isDate.hashCode() : 0);
306-
result = 31 * result + (isDateTime != null ? isDateTime.hashCode() : 0);
307-
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
308-
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
309-
result = 31 * result + (isFile != null ? isFile.hashCode() : 0);
310-
result = 31 * result + (notFile != null ? notFile.hashCode() : 0);
298+
result = 31 * result + (isString ? 13:31);
299+
result = 31 * result + (isInteger ? 13:31);
300+
result = 31 * result + (isLong ? 13:31);
301+
result = 31 * result + (isFloat ? 13:31);
302+
result = 31 * result + (isDouble ? 13:31);
303+
result = 31 * result + (isByteArray ? 13:31);
304+
result = 31 * result + (isBinary ? 13:31);
305+
result = 31 * result + (isBoolean ? 13:31);
306+
result = 31 * result + (isDate ? 13:31);
307+
result = 31 * result + (isDateTime ? 13:31);
308+
result = 31 * result + (isListContainer ? 13:31);
309+
result = 31 * result + (isMapContainer ? 13:31);
310+
result = 31 * result + (isFile ? 13:31);
311+
result = 31 * result + (notFile ? 13:31);
311312
result = 31 * result + (isEnum ? 1 : 0);
312313
result = 31 * result + (_enum != null ? _enum.hashCode() : 0);
313314
result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0);
314315
result = 31 * result + (items != null ? items.hashCode() : 0);
315316
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
316-
result = 31 * result + (hasValidation != null ? hasValidation.hashCode() : 0);
317-
result = 31 * result + (required != null ? required.hashCode() : 0);
317+
result = 31 * result + (hasValidation ? 13:31);
318+
result = 31 * result + (required ? 13:31);
318319
result = 31 * result + (maximum != null ? maximum.hashCode() : 0);
319-
result = 31 * result + (exclusiveMaximum != null ? exclusiveMaximum.hashCode() : 0);
320+
result = 31 * result + (exclusiveMaximum ? 13:31);
320321
result = 31 * result + (minimum != null ? minimum.hashCode() : 0);
321-
result = 31 * result + (exclusiveMinimum != null ? exclusiveMinimum.hashCode() : 0);
322+
result = 31 * result + (exclusiveMinimum ? 13:31);
322323
result = 31 * result + (maxLength != null ? maxLength.hashCode() : 0);
323324
result = 31 * result + (minLength != null ? minLength.hashCode() : 0);
324325
result = 31 * result + (pattern != null ? pattern.hashCode() : 0);
325326
result = 31 * result + (maxItems != null ? maxItems.hashCode() : 0);
326327
result = 31 * result + (minItems != null ? minItems.hashCode() : 0);
327-
result = 31 * result + (uniqueItems != null ? uniqueItems.hashCode() : 0);
328+
result = 31 * result + (uniqueItems ? 13:31);
328329
result = 31 * result + (multipleOf != null ? multipleOf.hashCode() : 0);
329330
return result;
330331
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,20 @@
77
public class CodegenResponse {
88
public final List<CodegenProperty> headers = new ArrayList<CodegenProperty>();
99
public String code, message;
10-
public Boolean hasMore;
10+
public boolean hasMore;
1111
public List<Map<String, Object>> examples;
1212
public String dataType, baseType, containerType;
13-
public Boolean isDefault;
14-
public Boolean simpleType;
15-
public Boolean primitiveType;
16-
public Boolean isMapContainer;
17-
public Boolean isListContainer;
18-
public Boolean isBinary = Boolean.FALSE;
19-
public Boolean isFile = Boolean.FALSE;
13+
public boolean isDefault;
14+
public boolean simpleType;
15+
public boolean primitiveType;
16+
public boolean isMapContainer;
17+
public boolean isListContainer;
18+
public boolean isBinary = false;
19+
public boolean isFile = false;
2020
public Object schema;
2121
public String jsonSchema;
2222
public Map<String, Object> vendorExtensions;
2323

24-
public boolean isWildcard() {
25-
return "0".equals(code) || "default".equals(code);
26-
}
27-
2824
@Override
2925
public String toString() {
3026
return String.format("%s(%s)", code, containerType);
@@ -43,7 +39,7 @@ public boolean equals(Object o) {
4339
return false;
4440
if (message != null ? !message.equals(that.message) : that.message != null)
4541
return false;
46-
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
42+
if (hasMore != that.hasMore)
4743
return false;
4844
if (examples != null ? !examples.equals(that.examples) : that.examples != null)
4945
return false;
@@ -53,19 +49,19 @@ public boolean equals(Object o) {
5349
return false;
5450
if (containerType != null ? !containerType.equals(that.containerType) : that.containerType != null)
5551
return false;
56-
if (isDefault != null ? !isDefault.equals(that.isDefault) : that.isDefault != null)
52+
if (isDefault != that.isDefault)
5753
return false;
58-
if (simpleType != null ? !simpleType.equals(that.simpleType) : that.simpleType != null)
54+
if (simpleType != that.simpleType)
5955
return false;
60-
if (primitiveType != null ? !primitiveType.equals(that.primitiveType) : that.primitiveType != null)
56+
if (primitiveType != that.primitiveType)
6157
return false;
62-
if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null)
58+
if (isMapContainer != that.isMapContainer)
6359
return false;
64-
if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null)
60+
if (isListContainer != that.isListContainer)
6561
return false;
66-
if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null)
62+
if (isBinary != that.isBinary)
6763
return false;
68-
if (isFile != null ? !isFile.equals(that.isFile) : that.isFile != null)
64+
if (isFile != that.isFile)
6965
return false;
7066
if (schema != null ? !schema.equals(that.schema) : that.schema != null)
7167
return false;
@@ -80,18 +76,18 @@ public int hashCode() {
8076
int result = headers.hashCode();
8177
result = 31 * result + (code != null ? code.hashCode() : 0);
8278
result = 31 * result + (message != null ? message.hashCode() : 0);
83-
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
79+
result = 31 * result + (hasMore ? 13:31);
8480
result = 31 * result + (examples != null ? examples.hashCode() : 0);
8581
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
8682
result = 31 * result + (baseType != null ? baseType.hashCode() : 0);
8783
result = 31 * result + (containerType != null ? containerType.hashCode() : 0);
88-
result = 31 * result + (isDefault != null ? isDefault.hashCode() : 0);
89-
result = 31 * result + (simpleType != null ? simpleType.hashCode() : 0);
90-
result = 31 * result + (primitiveType != null ? primitiveType.hashCode() : 0);
91-
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
92-
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
93-
result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0);
94-
result = 31 * result + (isFile != null ? isFile.hashCode() : 0);
84+
result = 31 * result + (isDefault ? 13:31);
85+
result = 31 * result + (simpleType ? 13:31);
86+
result = 31 * result + (primitiveType ? 13:31);
87+
result = 31 * result + (isMapContainer ? 13:31);
88+
result = 31 * result + (isListContainer ? 13:31);
89+
result = 31 * result + (isBinary ? 13:31);
90+
result = 31 * result + (isFile ? 13:31);
9591
result = 31 * result + (schema != null ? schema.hashCode() : 0);
9692
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
9793
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);

0 commit comments

Comments
 (0)