Refactor and use some Java 7 features (#2225)

* Fix typo in (unused) method name

* Tidy up Rust server generator

Remove some repetition and use some nifty new methods introduced in Java 8

* Start using Objects.hash and Objects.equals

* Convert more equals implementations over

To use Objects.equals

* Convert more hashCode implementations over

To use Objects.hash. Might have the pleasant side-effect of improving
performance a bit.
This commit is contained in:
Benjamin Gill 2019-03-05 17:12:52 +00:00 committed by William Cheng
parent c57abbe5bd
commit bcb4b03798
9 changed files with 534 additions and 870 deletions

View File

@ -21,6 +21,7 @@ import org.openapitools.codegen.auth.AuthMethod;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
public class ClientOpts { public class ClientOpts {
protected String uri; protected String uri;
@ -78,26 +79,15 @@ public class ClientOpts {
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
ClientOpts that = (ClientOpts) o; ClientOpts that = (ClientOpts) o;
return Objects.equals(uri, that.uri) &&
if (uri != null ? !uri.equals(that.uri) : that.uri != null) Objects.equals(target, that.target) &&
return false; Objects.equals(auth, that.auth) &&
if (target != null ? !target.equals(that.target) : that.target != null) Objects.equals(properties, that.properties) &&
return false; Objects.equals(outputDirectory, that.outputDirectory);
if (auth != null ? !auth.equals(that.auth) : that.auth != null)
return false;
if (properties != null ? !properties.equals(that.properties) : that.properties != null)
return false;
return outputDirectory != null ? outputDirectory.equals(that.outputDirectory) : that.outputDirectory == null;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = uri != null ? uri.hashCode() : 0; return Objects.hash(uri, target, auth, properties, outputDirectory);
result = 31 * result + (target != null ? target.hashCode() : 0);
result = 31 * result + (auth != null ? auth.hashCode() : 0);
result = 31 * result + (properties != null ? properties.hashCode() : 0);
result = 31 * result + (outputDirectory != null ? outputDirectory.hashCode() : 0);
return result;
} }
} }

View File

@ -132,125 +132,87 @@ public class CodegenModel {
CodegenModel that = (CodegenModel) o; CodegenModel that = (CodegenModel) o;
if (parent != null ? !parent.equals(that.parent) : that.parent != null) return Objects.equals(parent, that.parent) &&
return false; Objects.equals(parentSchema, that.parentSchema) &&
if (parentSchema != null ? !parentSchema.equals(that.parentSchema) : that.parentSchema != null) Objects.equals(interfaces, that.interfaces) &&
return false; Objects.equals(allParents, that.allParents) &&
if (interfaces != null ? !interfaces.equals(that.interfaces) : that.interfaces != null) Objects.equals(parentModel, that.parentModel) &&
return false; Objects.equals(interfaceModels, that.interfaceModels) &&
if (allParents != null ? !allParents.equals(that.allParents) : that.allParents != null) Objects.equals(name, that.name) &&
return false; Objects.equals(classname, that.classname) &&
if (parentModel != null ? !parentModel.equals(that.parentModel) : that.parentModel != null) Objects.equals(title, that.title) &&
return false; Objects.equals(description, that.description) &&
if (interfaceModels != null ? !interfaceModels.equals(that.interfaceModels) : that.interfaceModels != null) Objects.equals(classVarName, that.classVarName) &&
return false; Objects.equals(modelJson, that.modelJson) &&
if (name != null ? !name.equals(that.name) : that.name != null) Objects.equals(dataType, that.dataType) &&
return false; Objects.equals(xmlPrefix, that.xmlPrefix) &&
if (classname != null ? !classname.equals(that.classname) : that.classname != null) Objects.equals(xmlNamespace, that.xmlNamespace) &&
return false; Objects.equals(xmlName, that.xmlName) &&
if (title != null ? !title.equals(that.title) : that.title != null) Objects.equals(classFilename, that.classFilename) &&
return false; Objects.equals(unescapedDescription, that.unescapedDescription) &&
if (description != null ? !description.equals(that.description) : that.description != null) Objects.equals(discriminator, that.discriminator) &&
return false; Objects.equals(defaultValue, that.defaultValue) &&
if (classVarName != null ? !classVarName.equals(that.classVarName) : that.classVarName != null) Objects.equals(vars, that.vars) &&
return false; Objects.equals(requiredVars, that.requiredVars) &&
if (modelJson != null ? !modelJson.equals(that.modelJson) : that.modelJson != null) Objects.equals(optionalVars, that.optionalVars) &&
return false; Objects.equals(allVars, that.allVars) &&
if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null) Objects.equals(allowableValues, that.allowableValues) &&
return false; Objects.equals(mandatory, that.mandatory) &&
if (xmlPrefix != null ? !xmlPrefix.equals(that.xmlPrefix) : that.xmlPrefix != null) Objects.equals(allMandatory, that.allMandatory) &&
return false; Objects.equals(imports, that.imports) &&
if (xmlNamespace != null ? !xmlNamespace.equals(that.xmlNamespace) : that.xmlNamespace != null) Objects.equals(hasVars, that.hasVars) &&
return false; Objects.equals(emptyVars, that.emptyVars) &&
if (xmlName != null ? !xmlName.equals(that.xmlName) : that.xmlName != null) Objects.equals(hasMoreModels, that.hasMoreModels) &&
return false; Objects.equals(hasEnums, that.hasEnums) &&
if (classFilename != null ? !classFilename.equals(that.classFilename) : that.classFilename != null) Objects.equals(isEnum, that.isEnum) &&
return false; Objects.equals(externalDocumentation, that.externalDocumentation) &&
if (unescapedDescription != null ? !unescapedDescription.equals(that.unescapedDescription) : that.unescapedDescription != null) Objects.equals(hasOnlyReadOnly, that.hasOnlyReadOnly) &&
return false; Objects.equals(hasChildren, that.hasChildren) &&
if (discriminator != null ? !discriminator.equals(that.discriminator) : that.discriminator != null) Objects.equals(parentVars, that.parentVars) &&
return false; Objects.equals(vendorExtensions, that.vendorExtensions);
if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null)
return false;
if (vars != null ? !vars.equals(that.vars) : that.vars != null)
return false;
if (requiredVars != null ? !requiredVars.equals(that.requiredVars) : that.requiredVars != null)
return false;
if (optionalVars != null ? !optionalVars.equals(that.optionalVars) : that.optionalVars != null)
return false;
if (allVars != null ? !allVars.equals(that.allVars) : that.allVars != null)
return false;
if (allowableValues != null ? !allowableValues.equals(that.allowableValues) : that.allowableValues != null)
return false;
if (mandatory != null ? !mandatory.equals(that.mandatory) : that.mandatory != null)
return false;
if (allMandatory != null ? !allMandatory.equals(that.allMandatory) : that.allMandatory != null)
return false;
if (imports != null ? !imports.equals(that.imports) : that.imports != null)
return false;
if (hasVars != that.hasVars)
return false;
if (emptyVars != that.emptyVars)
return false;
if (hasMoreModels != that.hasMoreModels)
return false;
if (hasEnums != that.hasEnums)
return false;
if (isEnum != that.isEnum)
return false;
if (externalDocumentation != null ? !externalDocumentation.equals(that.externalDocumentation) : that.externalDocumentation != null)
return false;
if (!Objects.equals(hasOnlyReadOnly, that.hasOnlyReadOnly))
return false;
if (!Objects.equals(hasChildren, that.hasChildren))
return false;
if (!Objects.equals(parentVars, that.parentVars))
return false;
return vendorExtensions != null ? vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions == null;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = parent != null ? parent.hashCode() : 0; return Objects.hash(
result = 31 * result + (parentSchema != null ? parentSchema.hashCode() : 0); parent,
result = 31 * result + (interfaces != null ? interfaces.hashCode() : 0); parentSchema,
result = 31 * result + (allParents != null ? allParents.hashCode() : 0); interfaces,
result = 31 * result + (parentModel != null ? parentModel.hashCode() : 0); allParents,
result = 31 * result + (interfaceModels != null ? interfaceModels.hashCode() : 0); parentModel,
result = 31 * result + (name != null ? name.hashCode() : 0); interfaceModels,
result = 31 * result + (classname != null ? classname.hashCode() : 0); name,
result = 31 * result + (title != null ? title.hashCode() : 0); classname,
result = 31 * result + (description != null ? description.hashCode() : 0); title,
result = 31 * result + (classVarName != null ? classVarName.hashCode() : 0); description,
result = 31 * result + (modelJson != null ? modelJson.hashCode() : 0); classVarName,
result = 31 * result + (dataType != null ? dataType.hashCode() : 0); modelJson,
result = 31 * result + (xmlPrefix != null ? xmlPrefix.hashCode() : 0); dataType,
result = 31 * result + (xmlNamespace != null ? xmlNamespace.hashCode() : 0); xmlPrefix,
result = 31 * result + (xmlName != null ? xmlName.hashCode() : 0); xmlNamespace,
result = 31 * result + (classFilename != null ? classFilename.hashCode() : 0); xmlName,
result = 31 * result + (unescapedDescription != null ? unescapedDescription.hashCode() : 0); classFilename,
result = 31 * result + (discriminator != null ? discriminator.hashCode() : 0); unescapedDescription,
result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0); discriminator,
result = 31 * result + (vars != null ? vars.hashCode() : 0); defaultValue,
result = 31 * result + (requiredVars != null ? requiredVars.hashCode() : 0); vars,
result = 31 * result + (optionalVars != null ? optionalVars.hashCode() : 0); requiredVars,
result = 31 * result + (allVars != null ? allVars.hashCode() : 0); optionalVars,
result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0); allVars,
result = 31 * result + (mandatory != null ? mandatory.hashCode() : 0); allowableValues,
result = 31 * result + (allMandatory != null ? allMandatory.hashCode() : 0); mandatory,
result = 31 * result + (imports != null ? imports.hashCode() : 0); allMandatory,
result = 31 * result + (hasVars ? 13 : 31); imports,
result = 31 * result + (emptyVars ? 13 : 31); hasVars,
result = 31 * result + (hasMoreModels ? 13 : 31); emptyVars,
result = 31 * result + (hasEnums ? 13 : 31); hasMoreModels,
result = 31 * result + (isEnum ? 13 : 31); hasEnums,
result = 31 * result + (externalDocumentation != null ? externalDocumentation.hashCode() : 0); isEnum,
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); externalDocumentation,
result = 31 * result + Objects.hash(hasOnlyReadOnly); vendorExtensions,
result = 31 * result + Objects.hash(hasChildren); hasOnlyReadOnly,
result = 31 * result + Objects.hash(parentVars); hasChildren,
return result; parentVars);
} }
public String getParent() { public String getParent() {

View File

@ -254,179 +254,123 @@ public class CodegenOperation {
CodegenOperation that = (CodegenOperation) o; CodegenOperation that = (CodegenOperation) o;
if (responseHeaders != null ? !responseHeaders.equals(that.responseHeaders) : that.responseHeaders != null) return Objects.equals(responseHeaders, that.responseHeaders) &&
return false; Objects.equals(hasAuthMethods, that.hasAuthMethods) &&
if (hasAuthMethods != that.hasAuthMethods) Objects.equals(hasConsumes, that.hasConsumes) &&
return false; Objects.equals(hasProduces, that.hasProduces) &&
if (hasConsumes != that.hasConsumes) Objects.equals(hasParams, that.hasParams) &&
return false; Objects.equals(hasOptionalParams, that.hasOptionalParams) &&
if (hasProduces != that.hasProduces) Objects.equals(returnTypeIsPrimitive, that.returnTypeIsPrimitive) &&
return false; Objects.equals(returnSimpleType, that.returnSimpleType) &&
if (hasParams != that.hasParams) Objects.equals(subresourceOperation, that.subresourceOperation) &&
return false; Objects.equals(isMapContainer, that.isMapContainer) &&
if (hasOptionalParams != that.hasOptionalParams) Objects.equals(isListContainer, that.isListContainer) &&
return false; Objects.equals(isMultipart, that.isMultipart) &&
if (returnTypeIsPrimitive != that.returnTypeIsPrimitive) Objects.equals(hasMore, that.hasMore) &&
return false; Objects.equals(isResponseBinary, that.isResponseBinary) &&
if (returnSimpleType != that.returnSimpleType) Objects.equals(hasReference, that.hasReference) &&
return false; Objects.equals(isResponseFile, that.isResponseFile) &&
if (subresourceOperation != that.subresourceOperation) Objects.equals(isDeprecated, that.isDeprecated) &&
return false; Objects.equals(isCallbackRequest, that.isCallbackRequest) &&
if (isMapContainer != that.isMapContainer) Objects.equals(path, that.path) &&
return false; Objects.equals(operationId, that.operationId) &&
if (isListContainer != that.isListContainer) Objects.equals(returnType, that.returnType) &&
return false; Objects.equals(httpMethod, that.httpMethod) &&
if (isMultipart != that.isMultipart) Objects.equals(returnBaseType, that.returnBaseType) &&
return false; Objects.equals(returnContainer, that.returnContainer) &&
if (hasMore != that.hasMore) Objects.equals(summary, that.summary) &&
return false; Objects.equals(unescapedNotes, that.unescapedNotes) &&
if (isResponseBinary != that.isResponseBinary) Objects.equals(notes, that.notes) &&
return false; Objects.equals(baseName, that.baseName) &&
if (hasReference != that.hasReference) Objects.equals(defaultResponse, that.defaultResponse) &&
return false; Objects.equals(discriminator, that.discriminator) &&
if (isResponseFile != that.isResponseFile) Objects.equals(consumes, that.consumes) &&
return false; Objects.equals(produces, that.produces) &&
if (isDeprecated != that.isDeprecated) Objects.equals(servers, that.servers) &&
return false; Objects.equals(bodyParam, that.bodyParam) &&
if (isCallbackRequest != that.isCallbackRequest) Objects.equals(allParams, that.allParams) &&
return false; Objects.equals(bodyParams, that.bodyParams) &&
if (path != null ? !path.equals(that.path) : that.path != null) Objects.equals(pathParams, that.pathParams) &&
return false; Objects.equals(queryParams, that.queryParams) &&
if (operationId != null ? !operationId.equals(that.operationId) : that.operationId != null) Objects.equals(headerParams, that.headerParams) &&
return false; Objects.equals(formParams, that.formParams) &&
if (returnType != null ? !returnType.equals(that.returnType) : that.returnType != null) Objects.equals(cookieParams, that.cookieParams) &&
return false; Objects.equals(requiredParams, that.requiredParams) &&
if (httpMethod != null ? !httpMethod.equals(that.httpMethod) : that.httpMethod != null) Objects.equals(optionalParams, that.optionalParams) &&
return false; Objects.equals(authMethods, that.authMethods) &&
if (returnBaseType != null ? !returnBaseType.equals(that.returnBaseType) : that.returnBaseType != null) Objects.equals(tags, that.tags) &&
return false; Objects.equals(responses, that.responses) &&
if (returnContainer != null ? !returnContainer.equals(that.returnContainer) : that.returnContainer != null) Objects.equals(callbacks, that.callbacks) &&
return false; Objects.equals(imports, that.imports) &&
if (summary != null ? !summary.equals(that.summary) : that.summary != null) Objects.equals(examples, that.examples) &&
return false; Objects.equals(externalDocs, that.externalDocs) &&
if (unescapedNotes != null ? !unescapedNotes.equals(that.unescapedNotes) : that.unescapedNotes != null) Objects.equals(vendorExtensions, that.vendorExtensions) &&
return false; Objects.equals(nickname, that.nickname) &&
if (notes != null ? !notes.equals(that.notes) : that.notes != null) Objects.equals(prioritizedContentTypes, that.prioritizedContentTypes) &&
return false; Objects.equals(operationIdOriginal, that.operationIdOriginal) &&
if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null) Objects.equals(operationIdLowerCase, that.operationIdLowerCase) &&
return false; Objects.equals(operationIdCamelCase, that.operationIdCamelCase);
if (defaultResponse != null ? !defaultResponse.equals(that.defaultResponse) : that.defaultResponse != null)
return false;
if (discriminator != null ? !discriminator.equals(that.discriminator) : that.discriminator != null)
return false;
if (consumes != null ? !consumes.equals(that.consumes) : that.consumes != null)
return false;
if (produces != null ? !produces.equals(that.produces) : that.produces != null)
return false;
if (servers != null ? !servers.equals(that.servers) : that.servers != null)
return false;
if (bodyParam != null ? !bodyParam.equals(that.bodyParam) : that.bodyParam != null)
return false;
if (allParams != null ? !allParams.equals(that.allParams) : that.allParams != null)
return false;
if (bodyParams != null ? !bodyParams.equals(that.bodyParams) : that.bodyParams != null)
return false;
if (pathParams != null ? !pathParams.equals(that.pathParams) : that.pathParams != null)
return false;
if (queryParams != null ? !queryParams.equals(that.queryParams) : that.queryParams != null)
return false;
if (headerParams != null ? !headerParams.equals(that.headerParams) : that.headerParams != null)
return false;
if (formParams != null ? !formParams.equals(that.formParams) : that.formParams != null)
return false;
if (cookieParams != null ? !cookieParams.equals(that.cookieParams) : that.cookieParams != null)
return false;
if (requiredParams != null ? !requiredParams.equals(that.requiredParams) : that.requiredParams!= null)
return false;
if (optionalParams != null ? !optionalParams.equals(that.optionalParams) : that.optionalParams!= null)
return false;
if (authMethods != null ? !authMethods.equals(that.authMethods) : that.authMethods != null)
return false;
if (tags != null ? !tags.equals(that.tags) : that.tags != null)
return false;
if (responses != null ? !responses.equals(that.responses) : that.responses != null)
return false;
if (callbacks != null ? !callbacks.equals(that.callbacks) : that.callbacks != null)
return false;
if (imports != null ? !imports.equals(that.imports) : that.imports != null)
return false;
if (examples != null ? !examples.equals(that.examples) : that.examples != null)
return false;
if (externalDocs != null ? !externalDocs.equals(that.externalDocs) : that.externalDocs != null)
return false;
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null)
return false;
if (nickname != null ? !nickname.equals(that.nickname) : that.nickname != null)
return false;
if ( prioritizedContentTypes != null ? !prioritizedContentTypes.equals(that.prioritizedContentTypes) : that.prioritizedContentTypes != null )
return false;
if ( operationIdOriginal != null ? !operationIdOriginal.equals(that.operationIdOriginal) : that.operationIdOriginal != null )
return false;
if ( operationIdLowerCase != null ? !operationIdLowerCase.equals(that.operationIdLowerCase) : that.operationIdLowerCase != null )
return false;
return operationIdCamelCase != null ? operationIdCamelCase.equals(that.operationIdCamelCase) : that.operationIdCamelCase == null;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = responseHeaders.hashCode(); return Objects.hash(
result = 31 * result + (hasAuthMethods ? 13:31); responseHeaders,
result = 31 * result + (hasConsumes ? 13:31); hasAuthMethods,
result = 31 * result + (hasProduces ? 13:31); hasConsumes,
result = 31 * result + (hasParams ? 13:31); hasProduces,
result = 31 * result + (hasOptionalParams ? 13:31); hasParams,
result = 31 * result + (returnTypeIsPrimitive ? 13:31); hasOptionalParams,
result = 31 * result + (returnSimpleType ? 13:31); returnTypeIsPrimitive,
result = 31 * result + (subresourceOperation ? 13:31); returnSimpleType,
result = 31 * result + (isMapContainer ? 13:31); subresourceOperation,
result = 31 * result + (isListContainer ? 13:31); isMapContainer,
result = 31 * result + (isMultipart ? 13:31); isListContainer,
result = 31 * result + (hasMore ? 13:31); isMultipart,
result = 31 * result + (isResponseBinary ? 13:31); hasMore,
result = 31 * result + (isResponseFile ? 13:31); isResponseBinary,
result = 31 * result + (hasReference ? 13:31); isResponseFile,
result = 31 * result + (isDeprecated ? 13:31); hasReference,
result = 31 * result + (isCallbackRequest ? 13:31); isDeprecated,
result = 31 * result + (path != null ? path.hashCode() : 0); isCallbackRequest,
result = 31 * result + (operationId != null ? operationId.hashCode() : 0); path,
result = 31 * result + (returnType != null ? returnType.hashCode() : 0); operationId,
result = 31 * result + (httpMethod != null ? httpMethod.hashCode() : 0); returnType,
result = 31 * result + (returnBaseType != null ? returnBaseType.hashCode() : 0); httpMethod,
result = 31 * result + (returnContainer != null ? returnContainer.hashCode() : 0); returnBaseType,
result = 31 * result + (summary != null ? summary.hashCode() : 0); returnContainer,
result = 31 * result + (unescapedNotes != null ? unescapedNotes.hashCode() : 0); summary,
result = 31 * result + (notes != null ? notes.hashCode() : 0); unescapedNotes,
result = 31 * result + (baseName != null ? baseName.hashCode() : 0); notes,
result = 31 * result + (defaultResponse != null ? defaultResponse.hashCode() : 0); baseName,
result = 31 * result + (discriminator != null ? discriminator.hashCode() : 0); defaultResponse,
result = 31 * result + (consumes != null ? consumes.hashCode() : 0); discriminator,
result = 31 * result + (produces != null ? produces.hashCode() : 0); consumes,
result = 31 * result + (servers != null ? servers.hashCode() : 0); produces,
result = 31 * result + (bodyParam != null ? bodyParam.hashCode() : 0); servers,
result = 31 * result + (allParams != null ? allParams.hashCode() : 0); bodyParam,
result = 31 * result + (bodyParams != null ? bodyParams.hashCode() : 0); allParams,
result = 31 * result + (pathParams != null ? pathParams.hashCode() : 0); bodyParams,
result = 31 * result + (queryParams != null ? queryParams.hashCode() : 0); pathParams,
result = 31 * result + (headerParams != null ? headerParams.hashCode() : 0); queryParams,
result = 31 * result + (formParams != null ? formParams.hashCode() : 0); headerParams,
result = 31 * result + (cookieParams != null ? cookieParams.hashCode() : 0); formParams,
result = 31 * result + (requiredParams!= null ? requiredParams.hashCode() : 0); cookieParams,
result = 31 * result + (optionalParams != null ? optionalParams.hashCode() : 0); requiredParams,
result = 31 * result + (authMethods != null ? authMethods.hashCode() : 0); optionalParams,
result = 31 * result + (tags != null ? tags.hashCode() : 0); authMethods,
result = 31 * result + (responses != null ? responses.hashCode() : 0); tags,
result = 31 * result + (callbacks != null ? callbacks.hashCode() : 0); responses,
result = 31 * result + (imports != null ? imports.hashCode() : 0); callbacks,
result = 31 * result + (examples != null ? examples.hashCode() : 0); imports,
result = 31 * result + (externalDocs != null ? externalDocs.hashCode() : 0); examples,
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); externalDocs,
result = 31 * result + (nickname != null ? nickname.hashCode() : 0); vendorExtensions,
result = 31 * result + (prioritizedContentTypes != null ? prioritizedContentTypes.hashCode() : 0); nickname,
result = 31 * result + (operationIdOriginal != null ? operationIdOriginal.hashCode() : 0); prioritizedContentTypes,
result = 31 * result + (operationIdLowerCase != null ? operationIdLowerCase.hashCode() : 0); operationIdOriginal,
result = 31 * result + (operationIdCamelCase != null ? operationIdCamelCase.hashCode() : 0); operationIdLowerCase,
return result; operationIdCamelCase);
} }

View File

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
public class CodegenParameter { public class CodegenParameter {
public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam, public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
@ -182,199 +183,137 @@ public class CodegenParameter {
CodegenParameter that = (CodegenParameter) o; CodegenParameter that = (CodegenParameter) o;
if (isEnum != that.isEnum) return false; return Objects.equals(isEnum, that.isEnum) &&
if (isFormParam != that.isFormParam) Objects.equals(isFormParam, that.isFormParam) &&
return false; Objects.equals(isQueryParam, that.isQueryParam) &&
if (isQueryParam != that.isQueryParam) Objects.equals(isPathParam, that.isPathParam) &&
return false; Objects.equals(isHeaderParam, that.isHeaderParam) &&
if (isPathParam != that.isPathParam) Objects.equals(isCookieParam, that.isCookieParam) &&
return false; Objects.equals(isBodyParam, that.isBodyParam) &&
if (isHeaderParam != that.isHeaderParam) Objects.equals(hasMore, that.hasMore) &&
return false; Objects.equals(isContainer, that.isContainer) &&
if (isCookieParam != that.isCookieParam) Objects.equals(secondaryParam, that.secondaryParam) &&
return false; Objects.equals(isCollectionFormatMulti, that.isCollectionFormatMulti) &&
if (isBodyParam != that.isBodyParam) Objects.equals(isPrimitiveType, that.isPrimitiveType) &&
return false; Objects.equals(isModel, that.isModel) &&
if (hasMore != that.hasMore) Objects.equals(baseName, that.baseName) &&
return false; Objects.equals(paramName, that.paramName) &&
if (isContainer != that.isContainer) Objects.equals(dataType, that.dataType) &&
return false; Objects.equals(datatypeWithEnum, that.datatypeWithEnum) &&
if (secondaryParam != that.secondaryParam) Objects.equals(enumName, that.enumName) &&
return false; Objects.equals(dataFormat, that.dataFormat) &&
if (isCollectionFormatMulti != that.isCollectionFormatMulti) Objects.equals(collectionFormat, that.collectionFormat) &&
return false; Objects.equals(description, that.description) &&
if (isPrimitiveType != that.isPrimitiveType) Objects.equals(unescapedDescription, that.unescapedDescription) &&
return false; Objects.equals(baseType, that.baseType) &&
if (isModel != that.isModel) Objects.equals(defaultValue, that.defaultValue) &&
return false; Objects.equals(example, that.example) &&
if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null) Objects.equals(jsonSchema, that.jsonSchema) &&
return false; Objects.equals(isString, that.isString) &&
if (paramName != null ? !paramName.equals(that.paramName) : that.paramName != null) Objects.equals(isNumeric, that.isNumeric) &&
return false; Objects.equals(isInteger, that.isInteger) &&
if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null) Objects.equals(isLong, that.isLong) &&
return false; Objects.equals(isNumber, that.isNumber) &&
if (datatypeWithEnum != null ? !datatypeWithEnum.equals(that.datatypeWithEnum) : that.datatypeWithEnum != null) Objects.equals(isFloat, that.isFloat) &&
return false; Objects.equals(isDouble, that.isDouble) &&
if (enumName != null ? !enumName.equals(that.enumName) : that.enumName != null) Objects.equals(isByteArray, that.isByteArray) &&
return false; Objects.equals(isBinary, that.isBinary) &&
if (dataFormat != null ? !dataFormat.equals(that.dataFormat) : that.dataFormat != null) Objects.equals(isBoolean, that.isBoolean) &&
return false; Objects.equals(isDate, that.isDate) &&
if (collectionFormat != null ? !collectionFormat.equals(that.collectionFormat) : that.collectionFormat != null) Objects.equals(isDateTime, that.isDateTime) &&
return false; Objects.equals(isUuid, that.isUuid) &&
if (description != null ? !description.equals(that.description) : that.description != null) Objects.equals(isEmail, that.isEmail) &&
return false; Objects.equals(isFreeFormObject, that.isFreeFormObject) &&
if (unescapedDescription != null ? !unescapedDescription.equals(that.unescapedDescription) : that.unescapedDescription != null) Objects.equals(isListContainer, that.isListContainer) &&
return false; Objects.equals(isMapContainer, that.isMapContainer) &&
if (baseType != null ? !baseType.equals(that.baseType) : that.baseType != null) Objects.equals(isFile, that.isFile) &&
return false; Objects.equals(_enum, that._enum) &&
if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null) Objects.equals(allowableValues, that.allowableValues) &&
return false; Objects.equals(items, that.items) &&
if (example != null ? !example.equals(that.example) : that.example != null) Objects.equals(mostInnerItems, that.mostInnerItems) &&
return false; Objects.equals(vendorExtensions, that.vendorExtensions) &&
if (jsonSchema != null ? !jsonSchema.equals(that.jsonSchema) : that.jsonSchema != null) Objects.equals(hasValidation, that.hasValidation) &&
return false; Objects.equals(isNullable, that.isNullable) &&
if (isString != that.isString) Objects.equals(required, that.required) &&
return false; Objects.equals(maximum, that.maximum) &&
if (isNumeric != that.isNumeric) Objects.equals(exclusiveMaximum, that.exclusiveMaximum) &&
return false; Objects.equals(minimum, that.minimum) &&
if (isInteger != that.isInteger) Objects.equals(exclusiveMinimum, that.exclusiveMinimum) &&
return false; Objects.equals(maxLength, that.maxLength) &&
if (isLong != that.isLong) Objects.equals(minLength, that.minLength) &&
return false; Objects.equals(pattern, that.pattern) &&
if (isNumber != that.isNumber) Objects.equals(maxItems, that.maxItems) &&
return false; Objects.equals(minItems, that.minItems) &&
if (isFloat != that.isFloat) Objects.equals(uniqueItems, that.uniqueItems) &&
return false; Objects.equals(multipleOf, that.multipleOf);
if (isDouble != that.isDouble)
return false;
if (isByteArray != that.isByteArray)
return false;
if (isBinary != that.isBinary)
return false;
if (isBoolean != that.isBoolean)
return false;
if (isDate != that.isDate)
return false;
if (isDateTime != that.isDateTime)
return false;
if (isUuid != that.isUuid)
return false;
if (isEmail != that.isEmail)
return false;
if (isFreeFormObject != that.isFreeFormObject)
return false;
if (isListContainer != that.isListContainer)
return false;
if (isMapContainer != that.isMapContainer)
return false;
if (isFile != that.isFile)
return false;
if (_enum != null ? !_enum.equals(that._enum) : that._enum != null)
return false;
if (allowableValues != null ? !allowableValues.equals(that.allowableValues) : that.allowableValues != null)
return false;
if (items != null ? !items.equals(that.items) : that.items != null)
return false;
if (mostInnerItems != null ? !mostInnerItems.equals(that.mostInnerItems) : that.mostInnerItems != null)
return false;
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null)
return false;
if (hasValidation != that.hasValidation)
return false;
if (isNullable != that.isNullable)
return false;
if (required != that.required)
return false;
if (maximum != null ? !maximum.equals(that.maximum) : that.maximum != null)
return false;
if (exclusiveMaximum != that.exclusiveMaximum)
return false;
if (minimum != null ? !minimum.equals(that.minimum) : that.minimum != null)
return false;
if (exclusiveMinimum != that.exclusiveMinimum)
return false;
if (maxLength != null ? !maxLength.equals(that.maxLength) : that.maxLength != null)
return false;
if (minLength != null ? !minLength.equals(that.minLength) : that.minLength != null)
return false;
if (pattern != null ? !pattern.equals(that.pattern) : that.pattern != null)
return false;
if (maxItems != null ? !maxItems.equals(that.maxItems) : that.maxItems != null)
return false;
if (minItems != null ? !minItems.equals(that.minItems) : that.minItems != null)
return false;
if (uniqueItems != that.uniqueItems)
return false;
return multipleOf != null ? multipleOf.equals(that.multipleOf) : that.multipleOf == null;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = isFormParam ? 13 : 31; return Objects.hash(
result = 31 * result + (isQueryParam ? 13 : 31); isFormParam,
result = 31 * result + (isPathParam ? 13 : 31); isQueryParam,
result = 31 * result + (isHeaderParam ? 13 : 31); isPathParam,
result = 31 * result + (isCookieParam ? 13 : 31); isHeaderParam,
result = 31 * result + (isBodyParam ? 13 : 31); isCookieParam,
result = 31 * result + (hasMore ? 13 : 31); isBodyParam,
result = 31 * result + (isContainer ? 13 : 31); hasMore,
result = 31 * result + (secondaryParam ? 13 : 31); isContainer,
result = 31 * result + (isCollectionFormatMulti ? 13 : 31); secondaryParam,
result = 31 * result + (isPrimitiveType ? 13 : 31); isCollectionFormatMulti,
result = 31 * result + (isModel ? 13 : 31); isPrimitiveType,
result = 31 * result + (baseName != null ? baseName.hashCode() : 0); isModel,
result = 31 * result + (paramName != null ? paramName.hashCode() : 0); baseName,
result = 31 * result + (dataType != null ? dataType.hashCode() : 0); paramName,
result = 31 * result + (datatypeWithEnum != null ? datatypeWithEnum.hashCode() : 0); dataType,
result = 31 * result + (enumName != null ? enumName.hashCode() : 0); datatypeWithEnum,
result = 31 * result + (dataFormat != null ? dataFormat.hashCode() : 0); enumName,
result = 31 * result + (collectionFormat != null ? collectionFormat.hashCode() : 0); dataFormat,
result = 31 * result + (description != null ? description.hashCode() : 0); collectionFormat,
result = 31 * result + (unescapedDescription != null ? unescapedDescription.hashCode() : 0); description,
result = 31 * result + (baseType != null ? baseType.hashCode() : 0); unescapedDescription,
result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0); baseType,
result = 31 * result + (example != null ? example.hashCode() : 0); defaultValue,
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0); example,
result = 31 * result + (isString ? 13 : 31); jsonSchema,
result = 31 * result + (isNumeric ? 13 : 31); isString,
result = 31 * result + (isInteger ? 13 : 31); isNumeric,
result = 31 * result + (isLong ? 13 : 31); isInteger,
result = 31 * result + (isFloat ? 13 : 31); isLong,
result = 31 * result + (isNumber ? 13 : 31); isFloat,
result = 31 * result + (isDouble ? 13 : 31); isNumber,
result = 31 * result + (isByteArray ? 13 : 31); isDouble,
result = 31 * result + (isBinary ? 13 : 31); isByteArray,
result = 31 * result + (isBoolean ? 13 : 31); isBinary,
result = 31 * result + (isDate ? 13 : 31); isBoolean,
result = 31 * result + (isDateTime ? 13 : 31); isDate,
result = 31 * result + (isUuid ? 13 : 31); isDateTime,
result = 31 * result + (isEmail ? 13 : 31); isUuid,
result = 31 * result + (isFreeFormObject ? 13 : 31); isEmail,
result = 31 * result + (isListContainer ? 13 : 31); isFreeFormObject,
result = 31 * result + (isMapContainer ? 13 : 31); isListContainer,
result = 31 * result + (isFile ? 13 : 31); isMapContainer,
result = 31 * result + (isEnum ? 1 : 0); isFile,
result = 31 * result + (_enum != null ? _enum.hashCode() : 0); isEnum,
result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0); _enum,
result = 31 * result + (items != null ? items.hashCode() : 0); allowableValues,
result = 31 * result + (mostInnerItems != null ? mostInnerItems.hashCode() : 0); items,
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); mostInnerItems,
result = 31 * result + (hasValidation ? 13 : 31); vendorExtensions,
result = 31 * result + (isNullable ? 13 : 31); hasValidation,
result = 31 * result + (required ? 13 : 31); isNullable,
result = 31 * result + (maximum != null ? maximum.hashCode() : 0); required,
result = 31 * result + (exclusiveMaximum ? 13 : 31); maximum,
result = 31 * result + (minimum != null ? minimum.hashCode() : 0); exclusiveMaximum,
result = 31 * result + (exclusiveMinimum ? 13 : 31); minimum,
result = 31 * result + (maxLength != null ? maxLength.hashCode() : 0); exclusiveMinimum,
result = 31 * result + (minLength != null ? minLength.hashCode() : 0); maxLength,
result = 31 * result + (pattern != null ? pattern.hashCode() : 0); minLength,
result = 31 * result + (maxItems != null ? maxItems.hashCode() : 0); pattern,
result = 31 * result + (minItems != null ? minItems.hashCode() : 0); maxItems,
result = 31 * result + (uniqueItems ? 13 : 31); minItems,
result = 31 * result + (multipleOf != null ? multipleOf.hashCode() : 0); uniqueItems,
return result; multipleOf);
} }
@java.lang.Override @java.lang.Override

View File

@ -412,83 +412,81 @@ public class CodegenProperty implements Cloneable {
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; return Objects.hash(
int result = 1; _enum,
result = prime * result + ((_enum == null) ? 0 : _enum.hashCode()); allowableValues,
result = prime * result + ((allowableValues == null) ? 0 : allowableValues.hashCode()); baseName,
result = prime * result + ((baseName == null) ? 0 : baseName.hashCode()); baseType,
result = prime * result + ((baseType == null) ? 0 : baseType.hashCode()); complexType,
result = prime * result + ((complexType == null) ? 0 : complexType.hashCode()); containerType,
result = prime * result + ((containerType == null) ? 0 : containerType.hashCode()); dataType,
result = prime * result + ((dataType == null) ? 0 : dataType.hashCode()); datatypeWithEnum,
result = prime * result + ((datatypeWithEnum == null) ? 0 : datatypeWithEnum.hashCode()); dataFormat,
result = prime * result + ((dataFormat == null) ? 0 : dataFormat.hashCode()); defaultValue,
result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode()); defaultValueWithParam,
result = prime * result + ((defaultValueWithParam == null) ? 0 : defaultValueWithParam.hashCode()); description,
result = prime * result + ((description == null) ? 0 : description.hashCode()); title,
result = prime * result + ((title == null) ? 0 : title.hashCode()); example,
result = prime * result + ((example == null) ? 0 : example.hashCode()); exclusiveMaximum,
result = prime * result + (exclusiveMaximum ? 13 : 31); exclusiveMinimum,
result = prime * result + (exclusiveMinimum ? 13 : 31); getter,
result = prime * result + ((getter == null) ? 0 : getter.hashCode()); hasMore,
result = prime * result + (hasMore ? 13 : 31); hasMoreNonReadOnly,
result = prime * result + ((hasMoreNonReadOnly ? 13 : 31)); isContainer,
result = prime * result + ((isContainer ? 13 : 31)); isEnum,
result = prime * result + (isEnum ? 1231 : 1237); isPrimitiveType,
result = prime * result + ((isPrimitiveType ? 13 : 31)); isModel,
result = prime * result + ((isModel ? 13 : 31)); isReadOnly,
result = prime * result + ((isReadOnly ? 13 : 31)); isWriteOnly,
result = prime * result + ((isWriteOnly ? 13 : 31)); isNullable,
result = prime * result + ((isNullable ? 13 : 31)); isSelfReference,
result = prime * result + ((isSelfReference ? 13 : 31)); items,
result = prime * result + ((items == null) ? 0 : items.hashCode()); mostInnerItems,
result = prime * result + ((mostInnerItems == null) ? 0 : mostInnerItems.hashCode()); jsonSchema,
result = prime * result + ((jsonSchema == null) ? 0 : jsonSchema.hashCode()); max,
result = prime * result + ((max == null) ? 0 : max.hashCode()); maxLength,
result = prime * result + ((maxLength == null) ? 0 : maxLength.hashCode()); maximum,
result = prime * result + ((maximum == null) ? 0 : maximum.hashCode()); min,
result = prime * result + ((min == null) ? 0 : min.hashCode()); minLength,
result = prime * result + ((minLength == null) ? 0 : minLength.hashCode()); minimum,
result = prime * result + ((minimum == null) ? 0 : minimum.hashCode()); name,
result = prime * result + ((name == null) ? 0 : name.hashCode()); pattern,
result = prime * result + ((pattern == null) ? 0 : pattern.hashCode()); required,
result = prime * result + ((required ? 13 : 31)); secondaryParam,
result = prime * result + ((secondaryParam ? 13 : 31)); setter,
result = prime * result + ((setter == null) ? 0 : setter.hashCode()); unescapedDescription,
result = prime * result + ((unescapedDescription == null) ? 0 : unescapedDescription.hashCode()); vendorExtensions,
result = prime * result + ((vendorExtensions == null) ? 0 : vendorExtensions.hashCode()); hasValidation,
result = prime * result + ((hasValidation ? 13 : 31)); isString,
result = prime * result + ((isString ? 13 : 31)); isNumeric,
result = prime * result + ((isNumeric ? 13 : 31)); isInteger,
result = prime * result + ((isInteger ? 13 : 31)); isLong,
result = prime * result + ((isLong ? 13 : 31)); isNumber,
result = prime * result + ((isNumber ? 13 : 31)); isFloat,
result = prime * result + ((isFloat ? 13 : 31)); isDouble,
result = prime * result + ((isDouble ? 13 : 31)); isByteArray,
result = prime * result + ((isByteArray ? 13 : 31)); isBinary,
result = prime * result + ((isBinary ? 13 : 31)); isFile,
result = prime * result + ((isFile ? 13 : 31)); isBoolean,
result = prime * result + ((isBoolean ? 13 : 31)); isDate,
result = prime * result + ((isDate ? 13 : 31)); isDateTime,
result = prime * result + ((isDateTime ? 13 : 31)); isUuid,
result = prime * result + ((isUuid ? 13 : 31)); isEmail,
result = prime * result + ((isEmail ? 13 : 31)); isFreeFormObject,
result = prime * result + ((isFreeFormObject ? 13 : 31)); isMapContainer,
result = prime * result + ((isMapContainer ? 13 : 31)); isListContainer,
result = prime * result + ((isListContainer ? 13 : 31)); isInherited,
result = prime * result + Objects.hashCode(isInherited); discriminatorValue,
result = prime * result + Objects.hashCode(discriminatorValue); nameInCamelCase,
result = prime * result + Objects.hashCode(nameInCamelCase); nameInSnakeCase,
result = prime * result + Objects.hashCode(nameInSnakeCase); enumName,
result = prime * result + Objects.hashCode(enumName); maxItems,
result = prime * result + ((maxItems == null) ? 0 : maxItems.hashCode()); minItems,
result = prime * result + ((minItems == null) ? 0 : minItems.hashCode()); isXmlAttribute,
result = prime * result + ((isXmlAttribute ? 13 : 31)); xmlPrefix,
result = prime * result + ((xmlPrefix == null) ? 0 : xmlPrefix.hashCode()); xmlName,
result = prime * result + ((xmlName == null) ? 0 : xmlName.hashCode()); xmlNamespace,
result = prime * result + ((xmlNamespace == null) ? 0 : xmlNamespace.hashCode()); isXmlWrapped);
result = prime * result + ((isXmlWrapped ? 13 : 31));
return result;
} }
@Override @Override
@ -499,216 +497,77 @@ public class CodegenProperty implements Cloneable {
if (getClass() != obj.getClass()) { if (getClass() != obj.getClass()) {
return false; return false;
} }
final CodegenProperty other = (CodegenProperty) obj; final CodegenProperty other = (CodegenProperty) obj;
if ((this.baseName == null) ? (other.baseName != null) : !this.baseName.equals(other.baseName)) {
return false;
}
if ((this.complexType == null) ? (other.complexType != null) : !this.complexType.equals(other.complexType)) {
return false;
}
if ((this.getter == null) ? (other.getter != null) : !this.getter.equals(other.getter)) {
return false;
}
if ((this.setter == null) ? (other.setter != null) : !this.setter.equals(other.setter)) {
return false;
}
if ((this.description == null) ? (other.description != null) : !this.description.equals(other.description)) {
return false;
}
if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
return false;
}
if ((this.dataType == null) ? (other.dataType != null) : !this.dataType.equals(other.dataType)) {
return false;
}
if ((this.datatypeWithEnum == null) ? (other.datatypeWithEnum != null) : !this.datatypeWithEnum.equals(other.datatypeWithEnum)) {
return false;
}
if ((this.dataFormat == null) ? (other.dataFormat != null) : !this.dataFormat.equals(other.dataFormat)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.min == null) ? (other.min != null) : !this.min.equals(other.min)) {
return false;
}
if ((this.max == null) ? (other.max != null) : !this.max.equals(other.max)) {
return false;
}
if ((this.defaultValue == null) ? (other.defaultValue != null) : !this.defaultValue.equals(other.defaultValue)) {
return false;
}
if ((this.baseType == null) ? (other.baseType != null) : !this.baseType.equals(other.baseType)) {
return false;
}
if ((this.containerType == null) ? (other.containerType != null) : !this.containerType.equals(other.containerType)) {
return false;
}
if (this.maxLength != other.maxLength && (this.maxLength == null || !this.maxLength.equals(other.maxLength))) {
return false;
}
if (this.minLength != other.minLength && (this.minLength == null || !this.minLength.equals(other.minLength))) {
return false;
}
if ((this.pattern == null) ? (other.pattern != null) : !this.pattern.equals(other.pattern)) {
return false;
}
if ((this.example == null) ? (other.example != null) : !this.example.equals(other.example)) {
return false;
}
if ((this.jsonSchema == null) ? (other.jsonSchema != null) : !this.jsonSchema.equals(other.jsonSchema)) {
return false;
}
if (this.minimum != other.minimum && (this.minimum == null || !this.minimum.equals(other.minimum))) {
return false;
}
if (this.maximum != other.maximum && (this.maximum == null || !this.maximum.equals(other.maximum))) {
return false;
}
if (this.exclusiveMinimum != other.exclusiveMinimum) {
return false;
}
if (this.exclusiveMaximum != other.exclusiveMaximum) {
return false;
}
if (this.required != other.required) {
return false;
}
if (this.secondaryParam != other.secondaryParam) {
return false;
}
if (this.isPrimitiveType != other.isPrimitiveType) {
return false;
}
if (this.isModel != other.isModel) {
return false;
}
if (this.isContainer != other.isContainer) {
return false;
}
if (this.isEnum != other.isEnum) {
return false;
}
if (this.isReadOnly != other.isReadOnly) {
return false;
}
if (this.isWriteOnly != other.isWriteOnly) {
return false;
}
if (this.isNullable != other.isNullable) {
return false;
}
if (this.isSelfReference != other.isSelfReference ) {
return false;
}
if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) {
return false;
}
if (this.allowableValues != other.allowableValues && (this.allowableValues == null || !this.allowableValues.equals(other.allowableValues))) {
return false;
}
if (this.vendorExtensions != other.vendorExtensions && (this.vendorExtensions == null || !this.vendorExtensions.equals(other.vendorExtensions))) { return Objects.equals(baseName, other.baseName) &&
return false; Objects.equals(complexType, other.complexType) &&
} Objects.equals(getter, other.getter) &&
Objects.equals(setter, other.setter) &&
if (this.hasValidation != other.hasValidation) { Objects.equals(description, other.description) &&
return false; Objects.equals(title, other.title) &&
} Objects.equals(dataType, other.dataType) &&
Objects.equals(datatypeWithEnum, other.datatypeWithEnum) &&
if (this.isString != other.isString) { Objects.equals(dataFormat, other.dataFormat) &&
return false; Objects.equals(name, other.name) &&
} Objects.equals(min, other.min) &&
Objects.equals(max, other.max) &&
if (this.isNumeric != other.isNumeric) { Objects.equals(defaultValue, other.defaultValue) &&
return false; Objects.equals(baseType, other.baseType) &&
} Objects.equals(containerType, other.containerType) &&
if (this.isInteger != other.isInteger) { Objects.equals(maxLength, other.maxLength) &&
return false; Objects.equals(minLength, other.minLength) &&
} Objects.equals(pattern, other.pattern) &&
if (this.isLong != other.isLong) { Objects.equals(example, other.example) &&
return false; Objects.equals(jsonSchema, other.jsonSchema) &&
} Objects.equals(minimum, other.minimum) &&
if (this.isNumber != other.isNumber) { Objects.equals(maximum, other.maximum) &&
return false; Objects.equals(exclusiveMinimum, other.exclusiveMinimum) &&
} Objects.equals(exclusiveMaximum, other.exclusiveMaximum) &&
if (this.isFloat != other.isFloat) { Objects.equals(required, other.required) &&
return false; Objects.equals(secondaryParam, other.secondaryParam) &&
} Objects.equals(isPrimitiveType, other.isPrimitiveType) &&
if (this.isDouble != other.isDouble) { Objects.equals(isModel, other.isModel) &&
return false; Objects.equals(isContainer, other.isContainer) &&
} Objects.equals(isEnum, other.isEnum) &&
if (this.isByteArray != other.isByteArray) { Objects.equals(isReadOnly, other.isReadOnly) &&
return false; Objects.equals(isWriteOnly, other.isWriteOnly) &&
} Objects.equals(isNullable, other.isNullable) &&
if (this.isBoolean != other.isBoolean) { Objects.equals(isSelfReference, other.isSelfReference) &&
return false; Objects.equals(_enum, other._enum) &&
} Objects.equals(allowableValues, other.allowableValues) &&
if (this.isDate != other.isDate) { Objects.equals(vendorExtensions, other.vendorExtensions) &&
return false; Objects.equals(hasValidation, other.hasValidation) &&
} Objects.equals(isString, other.isString) &&
if (this.isDateTime != other.isDateTime) { Objects.equals(isNumeric, other.isNumeric) &&
return false; Objects.equals(isInteger, other.isInteger) &&
} Objects.equals(isLong, other.isLong) &&
if (this.isUuid != other.isUuid) { Objects.equals(isNumber, other.isNumber) &&
return false; Objects.equals(isFloat, other.isFloat) &&
} Objects.equals(isDouble, other.isDouble) &&
if (this.isEmail != other.isEmail) { Objects.equals(isByteArray, other.isByteArray) &&
return false; Objects.equals(isBoolean, other.isBoolean) &&
} Objects.equals(isDate, other.isDate) &&
if (this.isFreeFormObject != other.isFreeFormObject) { Objects.equals(isDateTime, other.isDateTime) &&
return false; Objects.equals(isUuid, other.isUuid) &&
} Objects.equals(isEmail, other.isEmail) &&
if (this.isBinary != other.isBinary) { Objects.equals(isFreeFormObject, other.isFreeFormObject) &&
return false; Objects.equals(isBinary, other.isBinary) &&
} Objects.equals(isFile, other.isFile) &&
if (this.isFile != other.isFile) { Objects.equals(isListContainer, other.isListContainer) &&
return false; Objects.equals(isMapContainer, other.isMapContainer) &&
} Objects.equals(isInherited, other.isInherited) &&
if (this.isListContainer != other.isListContainer) { Objects.equals(discriminatorValue, other.discriminatorValue) &&
return false; Objects.equals(nameInCamelCase, other.nameInCamelCase) &&
} Objects.equals(nameInSnakeCase, other.nameInSnakeCase) &&
if (this.isMapContainer != other.isMapContainer) { Objects.equals(enumName, other.enumName) &&
return false; Objects.equals(maxItems, other.maxItems) &&
} Objects.equals(minItems, other.minItems) &&
if (!Objects.equals(this.isInherited, other.isInherited)) { Objects.equals(isXmlAttribute, other.isXmlAttribute) &&
return false; Objects.equals(xmlPrefix, other.xmlPrefix) &&
} Objects.equals(xmlName, other.xmlName) &&
if (!Objects.equals(this.discriminatorValue, other.discriminatorValue)) { Objects.equals(xmlNamespace, other.xmlNamespace) &&
return false; Objects.equals(isXmlWrapped, other.isXmlWrapped);
}
if (!Objects.equals(this.nameInCamelCase, other.nameInCamelCase)) {
return false;
}
if (!Objects.equals(this.nameInSnakeCase, other.nameInSnakeCase)) {
return false;
}
if (!Objects.equals(this.enumName, other.enumName)) {
return false;
}
if (this.maxItems != other.maxItems && (this.maxItems == null || !this.maxItems.equals(other.maxItems))) {
return false;
}
if (this.minItems != other.minItems && (this.minItems == null || !this.minItems.equals(other.minItems))) {
return false;
}
if (!Objects.equals(this.isXmlAttribute, other.isXmlAttribute)) {
return false;
}
if (!Objects.equals(this.xmlPrefix, other.xmlPrefix)) {
return false;
}
if (!Objects.equals(this.xmlName, other.xmlName)) {
return false;
}
if (!Objects.equals(this.xmlNamespace, other.xmlNamespace)) {
return false;
}
if (!Objects.equals(this.isXmlWrapped, other.isXmlWrapped)) {
return false;
}
return true;
} }
@Override @Override

View File

@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects;
public class CodegenSecurity { public class CodegenSecurity {
public String name; public String name;
@ -51,73 +52,52 @@ public class CodegenSecurity {
CodegenSecurity that = (CodegenSecurity) o; CodegenSecurity that = (CodegenSecurity) o;
if (name != null ? !name.equals(that.name) : that.name != null) return Objects.equals(name, that.name) &&
return false; Objects.equals(type, that.type) &&
if (type != null ? !type.equals(that.type) : that.type != null) Objects.equals(hasMore, that.hasMore) &&
return false; Objects.equals(isBasic, that.isBasic) &&
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null) Objects.equals(isBasicBasic, that.isBasicBasic) &&
return false; Objects.equals(isBasicBearer, that.isBasicBearer) &&
if (isBasic != null ? !isBasic.equals(that.isBasic) : that.isBasic != null) Objects.equals(bearerFormat, that.bearerFormat) &&
return false; Objects.equals(isOAuth, that.isOAuth) &&
if (isBasicBasic != null ? !isBasicBasic.equals(that.isBasicBasic) : that.isBasicBasic != null) Objects.equals(isApiKey, that.isApiKey) &&
return false; Objects.equals(vendorExtensions, that.vendorExtensions) &&
if (isBasicBearer != null ? !isBasicBearer.equals(that.isBasicBearer) : that.isBasicBearer != null) Objects.equals(keyParamName, that.keyParamName) &&
return false; Objects.equals(isKeyInQuery, that.isKeyInQuery) &&
if (bearerFormat != null ? !bearerFormat.equals(that.bearerFormat) : that.bearerFormat != null) Objects.equals(isKeyInHeader, that.isKeyInHeader) &&
return false; Objects.equals(flow, that.flow) &&
if (isOAuth != null ? !isOAuth.equals(that.isOAuth) : that.isOAuth != null) Objects.equals(authorizationUrl, that.authorizationUrl) &&
return false; Objects.equals(tokenUrl, that.tokenUrl) &&
if (isApiKey != null ? !isApiKey.equals(that.isApiKey) : that.isApiKey != null) Objects.equals(isCode, that.isCode) &&
return false; Objects.equals(isPassword, that.isPassword) &&
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null) Objects.equals(isApplication, that.isApplication) &&
return false; Objects.equals(isImplicit, that.isImplicit) &&
if (keyParamName != null ? !keyParamName.equals(that.keyParamName) : that.keyParamName != null) Objects.equals(scopes, that.scopes);
return false;
if (isKeyInQuery != null ? !isKeyInQuery.equals(that.isKeyInQuery) : that.isKeyInQuery != null)
return false;
if (isKeyInHeader != null ? !isKeyInHeader.equals(that.isKeyInHeader) : that.isKeyInHeader != null)
return false;
if (flow != null ? !flow.equals(that.flow) : that.flow != null)
return false;
if (authorizationUrl != null ? !authorizationUrl.equals(that.authorizationUrl) : that.authorizationUrl != null)
return false;
if (tokenUrl != null ? !tokenUrl.equals(that.tokenUrl) : that.tokenUrl != null)
return false;
if (isCode != null ? !isCode.equals(that.isCode) : that.isCode != null)
return false;
if (isPassword != null ? !isPassword.equals(that.isPassword) : that.isPassword != null)
return false;
if (isApplication != null ? !isApplication.equals(that.isApplication) : that.isApplication != null)
return false;
if (isImplicit != null ? !isImplicit.equals(that.isImplicit) : that.isImplicit != null)
return false;
return scopes != null ? scopes.equals(that.scopes) : that.scopes == null;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = name != null ? name.hashCode() : 0; return Objects.hash(
result = 31 * result + (type != null ? type.hashCode() : 0); name,
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0); type,
result = 31 * result + (isBasic != null ? isBasic.hashCode() : 0); hasMore,
result = 31 * result + (isBasicBasic != null ? isBasicBasic.hashCode() : 0); isBasic,
result = 31 * result + (isBasicBearer != null ? isBasicBearer.hashCode() : 0); isBasicBasic,
result = 31 * result + (bearerFormat != null ? bearerFormat.hashCode() : 0); isBasicBearer,
result = 31 * result + (isOAuth != null ? isOAuth.hashCode() : 0); bearerFormat,
result = 31 * result + (isApiKey != null ? isApiKey.hashCode() : 0); isOAuth,
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); isApiKey,
result = 31 * result + (keyParamName != null ? keyParamName.hashCode() : 0); vendorExtensions,
result = 31 * result + (isKeyInQuery != null ? isKeyInQuery.hashCode() : 0); keyParamName,
result = 31 * result + (isKeyInHeader != null ? isKeyInHeader.hashCode() : 0); isKeyInQuery,
result = 31 * result + (flow != null ? flow.hashCode() : 0); isKeyInHeader,
result = 31 * result + (authorizationUrl != null ? authorizationUrl.hashCode() : 0); flow,
result = 31 * result + (tokenUrl != null ? tokenUrl.hashCode() : 0); authorizationUrl,
result = 31 * result + (isCode != null ? isCode.hashCode() : 0); tokenUrl,
result = 31 * result + (isPassword != null ? isPassword.hashCode() : 0); isCode,
result = 31 * result + (isApplication != null ? isApplication.hashCode() : 0); isPassword,
result = 31 * result + (isImplicit != null ? isImplicit.hashCode() : 0); isApplication,
result = 31 * result + (scopes != null ? scopes.hashCode() : 0); isImplicit,
return result; scopes);
} }
} }

View File

@ -17,6 +17,8 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import java.util.Objects;
public class SupportingFile { public class SupportingFile {
public String templateFile; public String templateFile;
public String folder; public String folder;
@ -50,20 +52,14 @@ public class SupportingFile {
SupportingFile that = (SupportingFile) o; SupportingFile that = (SupportingFile) o;
if (templateFile != null ? !templateFile.equals(that.templateFile) : that.templateFile != null) return Objects.equals(templateFile, that.templateFile) &&
return false; Objects.equals(folder, that.folder) &&
if (folder != null ? !folder.equals(that.folder) : that.folder != null) Objects.equals(destinationFilename, that.destinationFilename);
return false;
return destinationFilename != null ? destinationFilename.equals(that.destinationFilename) : that.destinationFilename == null;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = templateFile != null ? templateFile.hashCode() : 0; return Objects.hash(templateFile, folder, destinationFilename);
result = 31 * result + (folder != null ? folder.hashCode() : 0);
result = 31 * result + (destinationFilename != null ? destinationFilename.hashCode() : 0);
return result;
} }
} }

View File

@ -205,11 +205,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
public void processOpts() { public void processOpts() {
super.processOpts(); super.processOpts();
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { setPackageName((String) additionalProperties.getOrDefault(CodegenConstants.PACKAGE_NAME, "openapi_client"));
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} else {
setPackageName("openapi_client");
}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) { if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION)); setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
@ -291,7 +287,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public String toApiName(String name) { public String toApiName(String name) {
if (name.length() == 0) { if (name.isEmpty()) {
return "default"; return "default";
} }
return underscore(name); return underscore(name);
@ -400,7 +396,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public String toEnumVarName(String value, String datatype) { public String toEnumVarName(String value, String datatype) {
String var = null; String var = null;
if (value.length() == 0) { if (value.isEmpty()) {
var = "EMPTY"; var = "EMPTY";
} }
@ -783,15 +779,18 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
return super.getTypeDeclaration(p); return super.getTypeDeclaration(p);
} }
@Override private boolean isNonPrimitive(CodegenParameter parameter) {
public CodegenParameter fromParameter(Parameter param, Set<String> imports) { return !parameter.isString && !parameter.isNumeric && !parameter.isByteArray &&
CodegenParameter parameter = super.fromParameter(param, imports);
if (!parameter.isString && !parameter.isNumeric && !parameter.isByteArray &&
!parameter.isBinary && !parameter.isFile && !parameter.isBoolean && !parameter.isBinary && !parameter.isFile && !parameter.isBoolean &&
!parameter.isDate && !parameter.isDateTime && !parameter.isUuid && !parameter.isDate && !parameter.isDateTime && !parameter.isUuid &&
!parameter.isListContainer && !parameter.isMapContainer && !parameter.isListContainer && !parameter.isMapContainer &&
!languageSpecificPrimitives.contains(parameter.dataType)) { !languageSpecificPrimitives.contains(parameter.dataType);
}
@Override
public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
CodegenParameter parameter = super.fromParameter(param, imports);
if (isNonPrimitive(parameter)) {
String name = "models::" + getTypeDeclaration(parameter.dataType); String name = "models::" + getTypeDeclaration(parameter.dataType);
parameter.dataType = name; parameter.dataType = name;
} }
@ -803,12 +802,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
public void postProcessParameter(CodegenParameter parameter) { public void postProcessParameter(CodegenParameter parameter) {
// If this parameter is not a primitive type, prefix it with "models::" // If this parameter is not a primitive type, prefix it with "models::"
// to ensure it's namespaced correctly in the Rust code. // to ensure it's namespaced correctly in the Rust code.
if (!parameter.isString && !parameter.isNumeric && !parameter.isByteArray && if (isNonPrimitive(parameter)) {
!parameter.isBinary && !parameter.isFile && !parameter.isBoolean &&
!parameter.isDate && !parameter.isDateTime && !parameter.isUuid &&
!parameter.isListContainer && !parameter.isMapContainer &&
!languageSpecificPrimitives.contains(parameter.dataType)) {
String name = "models::" + getTypeDeclaration(parameter.dataType); String name = "models::" + getTypeDeclaration(parameter.dataType);
parameter.dataType = name; parameter.dataType = name;
} }

View File

@ -373,7 +373,7 @@ public class ModelUtils {
return false; return false;
} }
public static boolean isShortchema(Schema schema) { public static boolean isShortSchema(Schema schema) {
if (SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) // type: integer if (SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) // type: integer
&& SchemaTypeUtil.INTEGER32_FORMAT.equals(schema.getFormat())) { // format: short (int32) && SchemaTypeUtil.INTEGER32_FORMAT.equals(schema.getFormat())) { // format: short (int32)
return true; return true;