Non functional Java styling changes (#10808)

* Replace explicit <Type> with <>

* Remove redundant toString() calls on String

* Use StandardCharsets.UTF_8 instead "UTF-8" string

* Simpler annotation format and redundant this

* Dont concat on empty String, use String.valueOf()

* Dont run equals on empty String

* Use string.anyMatch instead counting

* Collection add all instead iterating and adding

* Replace string contact with append chain in stringBuilders
This commit is contained in:
agilob 2021-11-09 06:36:01 +00:00 committed by GitHub
parent 53d3c9fc70
commit 4d947a1c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
115 changed files with 523 additions and 531 deletions

View File

@ -45,7 +45,7 @@ public class CodegenConfigLoader {
try { try {
return (CodegenConfig) Class.forName(name).getDeclaredConstructor().newInstance(); return (CodegenConfig) Class.forName(name).getDeclaredConstructor().newInstance();
} catch (Exception e) { } catch (Exception e) {
throw new GeneratorNotFoundException("Can't load config class with name '".concat(name) + "'\nAvailable:\n" + availableConfigs.toString(), e); throw new GeneratorNotFoundException("Can't load config class with name '".concat(name) + "'\nAvailable:\n" + availableConfigs, e);
} }
} }

View File

@ -45,9 +45,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public List<CodegenModel> children; public List<CodegenModel> children;
// anyOf, oneOf, allOf // anyOf, oneOf, allOf
public Set<String> anyOf = new TreeSet<String>(); public Set<String> anyOf = new TreeSet<>();
public Set<String> oneOf = new TreeSet<String>(); public Set<String> oneOf = new TreeSet<>();
public Set<String> allOf = new TreeSet<String>(); public Set<String> allOf = new TreeSet<>();
// The schema name as written in the OpenAPI document. // The schema name as written in the OpenAPI document.
public String name; public String name;
@ -66,20 +66,20 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public boolean isAlias; // Is this effectively an alias of another simple type public boolean isAlias; // Is this effectively an alias of another simple type
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime, isShort, isUnboundedInteger, isBoolean; public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime, isShort, isUnboundedInteger, isBoolean;
private boolean additionalPropertiesIsAnyType; private boolean additionalPropertiesIsAnyType;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>(); // all properties (without parent's properties) public List<CodegenProperty> vars = new ArrayList<>(); // all properties (without parent's properties)
public List<CodegenProperty> allVars = new ArrayList<CodegenProperty>(); // all properties (with parent's properties) public List<CodegenProperty> allVars = new ArrayList<>(); // all properties (with parent's properties)
public List<CodegenProperty> requiredVars = new ArrayList<CodegenProperty>(); // a list of required properties public List<CodegenProperty> requiredVars = new ArrayList<>(); // a list of required properties
public List<CodegenProperty> optionalVars = new ArrayList<CodegenProperty>(); // a list of optional properties public List<CodegenProperty> optionalVars = new ArrayList<>(); // a list of optional properties
public List<CodegenProperty> readOnlyVars = new ArrayList<CodegenProperty>(); // a list of read-only properties public List<CodegenProperty> readOnlyVars = new ArrayList<>(); // a list of read-only properties
public List<CodegenProperty> readWriteVars = new ArrayList<CodegenProperty>(); // a list of properties for read, write public List<CodegenProperty> readWriteVars = new ArrayList<>(); // a list of properties for read, write
public List<CodegenProperty> parentVars = new ArrayList<CodegenProperty>(); public List<CodegenProperty> parentVars = new ArrayList<>();
public Map<String, Object> allowableValues; public Map<String, Object> allowableValues;
// Sorted sets of required parameters. // Sorted sets of required parameters.
public Set<String> mandatory = new TreeSet<String>(); // without parent's required properties public Set<String> mandatory = new TreeSet<>(); // without parent's required properties
public Set<String> allMandatory = new TreeSet<String>(); // with parent's required properties public Set<String> allMandatory = new TreeSet<>(); // with parent's required properties
public Set<String> imports = new TreeSet<String>(); public Set<String> imports = new TreeSet<>();
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasValidation; public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasValidation;
/** /**
* Indicates the OAS schema specifies "nullable: true". * Indicates the OAS schema specifies "nullable: true".
@ -104,7 +104,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public boolean hasOnlyReadOnly = true; // true if all properties are read-only public boolean hasOnlyReadOnly = true; // true if all properties are read-only
public ExternalDocumentation externalDocumentation; public ExternalDocumentation externalDocumentation;
public Map<String, Object> vendorExtensions = new HashMap<String, Object>(); public Map<String, Object> vendorExtensions = new HashMap<>();
private CodegenComposedSchemas composedSchemas; private CodegenComposedSchemas composedSchemas;
private boolean hasMultipleTypes = false; private boolean hasMultipleTypes = false;
@ -320,7 +320,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public void setDiscriminator(CodegenDiscriminator discriminator) { public void setDiscriminator(CodegenDiscriminator discriminator) {
this.discriminator = discriminator; this.discriminator = discriminator;
if (discriminator instanceof CodegenDiscriminator && !discriminator.getMappedModels().isEmpty()) { if (discriminator != null && !discriminator.getMappedModels().isEmpty()) {
this.hasDiscriminatorWithNonEmptyMapping = true; this.hasDiscriminatorWithNonEmptyMapping = true;
} }
} }
@ -1067,13 +1067,13 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
private List<CodegenProperty> removeDuplicatedProperty(List<CodegenProperty> vars) { private List<CodegenProperty> removeDuplicatedProperty(List<CodegenProperty> vars) {
// clone the list first // clone the list first
List<CodegenProperty> newList = new ArrayList<CodegenProperty>(); List<CodegenProperty> newList = new ArrayList<>();
for (CodegenProperty cp : vars) { for (CodegenProperty cp : vars) {
newList.add(cp.clone()); newList.add(cp.clone());
} }
Set<String> propertyNames = new TreeSet<String>(); Set<String> propertyNames = new TreeSet<>();
Set<String> duplicatedNames = new TreeSet<String>(); Set<String> duplicatedNames = new TreeSet<>();
ListIterator<CodegenProperty> iterator = newList.listIterator(); ListIterator<CodegenProperty> iterator = newList.listIterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {

View File

@ -147,8 +147,8 @@ public class DefaultCodegen implements CodegenConfig {
protected Map<String, String> typeMapping; protected Map<String, String> typeMapping;
protected Map<String, String> instantiationTypes; protected Map<String, String> instantiationTypes;
protected Set<String> reservedWords; protected Set<String> reservedWords;
protected Set<String> languageSpecificPrimitives = new HashSet<String>(); protected Set<String> languageSpecificPrimitives = new HashSet<>();
protected Map<String, String> importMapping = new HashMap<String, String>(); protected Map<String, String> importMapping = new HashMap<>();
protected String modelPackage = "", apiPackage = "", fileSuffix; protected String modelPackage = "", apiPackage = "", fileSuffix;
protected String modelNamePrefix = "", modelNameSuffix = ""; protected String modelNamePrefix = "", modelNameSuffix = "";
protected String apiNamePrefix = "", apiNameSuffix = "Api"; protected String apiNamePrefix = "", apiNameSuffix = "Api";
@ -159,25 +159,25 @@ public class DefaultCodegen implements CodegenConfig {
apiTemplateFiles are for API outputs only (controllers/handlers). apiTemplateFiles are for API outputs only (controllers/handlers).
API templates may be written multiple times; APIs are grouped by tag and the file is written once per tag group. API templates may be written multiple times; APIs are grouped by tag and the file is written once per tag group.
*/ */
protected Map<String, String> apiTemplateFiles = new HashMap<String, String>(); protected Map<String, String> apiTemplateFiles = new HashMap<>();
protected Map<String, String> modelTemplateFiles = new HashMap<String, String>(); protected Map<String, String> modelTemplateFiles = new HashMap<>();
protected Map<String, String> apiTestTemplateFiles = new HashMap<String, String>(); protected Map<String, String> apiTestTemplateFiles = new HashMap<>();
protected Map<String, String> modelTestTemplateFiles = new HashMap<String, String>(); protected Map<String, String> modelTestTemplateFiles = new HashMap<>();
protected Map<String, String> apiDocTemplateFiles = new HashMap<String, String>(); protected Map<String, String> apiDocTemplateFiles = new HashMap<>();
protected Map<String, String> modelDocTemplateFiles = new HashMap<String, String>(); protected Map<String, String> modelDocTemplateFiles = new HashMap<>();
protected Map<String, String> reservedWordsMappings = new HashMap<String, String>(); protected Map<String, String> reservedWordsMappings = new HashMap<>();
protected String templateDir; protected String templateDir;
protected String embeddedTemplateDir; protected String embeddedTemplateDir;
protected Map<String, Object> additionalProperties = new HashMap<>(); protected Map<String, Object> additionalProperties = new HashMap<>();
protected Map<String, String> serverVariables = new HashMap<String, String>(); protected Map<String, String> serverVariables = new HashMap<>();
protected Map<String, Object> vendorExtensions = new HashMap<String, Object>(); protected Map<String, Object> vendorExtensions = new HashMap<>();
/* /*
Supporting files are those which aren't models, APIs, or docs. Supporting files are those which aren't models, APIs, or docs.
These get a different map of data bound to the templates. Supporting files are written once. These get a different map of data bound to the templates. Supporting files are written once.
See also 'apiTemplateFiles'. See also 'apiTemplateFiles'.
*/ */
protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>(); protected List<SupportingFile> supportingFiles = new ArrayList<>();
protected List<CliOption> cliOptions = new ArrayList<CliOption>(); protected List<CliOption> cliOptions = new ArrayList<>();
protected boolean skipOverwrite; protected boolean skipOverwrite;
protected boolean removeOperationIdPrefix; protected boolean removeOperationIdPrefix;
protected String removeOperationIdPrefixDelimiter = "_"; protected String removeOperationIdPrefixDelimiter = "_";
@ -210,7 +210,7 @@ public class DefaultCodegen implements CodegenConfig {
*/ */
protected boolean supportsAdditionalPropertiesWithComposedSchema; protected boolean supportsAdditionalPropertiesWithComposedSchema;
protected boolean supportsMixins; protected boolean supportsMixins;
protected Map<String, String> supportedLibraries = new LinkedHashMap<String, String>(); protected Map<String, String> supportedLibraries = new LinkedHashMap<>();
protected String library; protected String library;
protected Boolean sortParamsByRequiredFlag = true; protected Boolean sortParamsByRequiredFlag = true;
protected Boolean sortModelPropertiesByRequiredFlag = false; protected Boolean sortModelPropertiesByRequiredFlag = false;
@ -222,7 +222,7 @@ public class DefaultCodegen implements CodegenConfig {
// How to encode special characters like $ // How to encode special characters like $
// They are translated to words like "Dollar" and prefixed with ' // They are translated to words like "Dollar" and prefixed with '
// Then translated back during JSON encoding and decoding // Then translated back during JSON encoding and decoding
protected Map<String, String> specialCharReplacements = new HashMap<String, String>(); protected Map<String, String> specialCharReplacements = new HashMap<>();
// When a model is an alias for a simple type // When a model is an alias for a simple type
protected Map<String, String> typeAliases = null; protected Map<String, String> typeAliases = null;
protected Boolean prependFormOrBodyParameters = false; protected Boolean prependFormOrBodyParameters = false;
@ -236,7 +236,7 @@ public class DefaultCodegen implements CodegenConfig {
protected boolean useOneOfInterfaces = false; protected boolean useOneOfInterfaces = false;
// whether or not the oneOf imports machinery should add oneOf interfaces as imports in implementing classes // whether or not the oneOf imports machinery should add oneOf interfaces as imports in implementing classes
protected boolean addOneOfInterfaceImports = false; protected boolean addOneOfInterfaceImports = false;
protected List<CodegenModel> addOneOfInterfaces = new ArrayList<CodegenModel>(); protected List<CodegenModel> addOneOfInterfaces = new ArrayList<>();
// flag to indicate whether to only update files whose contents have changed // flag to indicate whether to only update files whose contents have changed
protected boolean enableMinimalUpdate = false; protected boolean enableMinimalUpdate = false;
@ -260,7 +260,7 @@ public class DefaultCodegen implements CodegenConfig {
private Map<String, Schema> modelNameToSchemaCache; private Map<String, Schema> modelNameToSchemaCache;
// A cache to efficiently lookup schema `toModelName()` based on the schema Key // A cache to efficiently lookup schema `toModelName()` based on the schema Key
private Map<String, String> schemaKeyToModelNameCache = new HashMap<>(); private final Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
@Override @Override
public List<CliOption> cliOptions() { public List<CliOption> cliOptions() {
@ -440,7 +440,7 @@ public class DefaultCodegen implements CodegenConfig {
// Gather data from all the models that contain oneOf into OneOfImplementorAdditionalData classes // Gather data from all the models that contain oneOf into OneOfImplementorAdditionalData classes
// (see docstring of that class to find out what information is gathered and why) // (see docstring of that class to find out what information is gathered and why)
Map<String, OneOfImplementorAdditionalData> additionalDataMap = new HashMap<String, OneOfImplementorAdditionalData>(); Map<String, OneOfImplementorAdditionalData> additionalDataMap = new HashMap<>();
for (Map.Entry<String, Object> modelsEntry : objs.entrySet()) { for (Map.Entry<String, Object> modelsEntry : objs.entrySet()) {
Map<String, Object> modelsAttrs = (Map<String, Object>) modelsEntry.getValue(); Map<String, Object> modelsAttrs = (Map<String, Object>) modelsEntry.getValue();
List<Object> models = (List<Object>) modelsAttrs.get("models"); List<Object> models = (List<Object>) modelsAttrs.get("models");
@ -503,7 +503,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return map of all models indexed by names * @return map of all models indexed by names
*/ */
public Map<String, CodegenModel> getAllModels(Map<String, Object> objs) { public Map<String, CodegenModel> getAllModels(Map<String, Object> objs) {
Map<String, CodegenModel> allModels = new HashMap<String, CodegenModel>(); Map<String, CodegenModel> allModels = new HashMap<>();
for (Entry<String, Object> entry : objs.entrySet()) { for (Entry<String, Object> entry : objs.entrySet()) {
String modelName = toModelName(entry.getKey()); String modelName = toModelName(entry.getKey());
Map<String, Object> inner = (Map<String, Object>) entry.getValue(); Map<String, Object> inner = (Map<String, Object>) entry.getValue();
@ -823,9 +823,9 @@ public class DefaultCodegen implements CodegenConfig {
public void preprocessOpenAPI(OpenAPI openAPI) { public void preprocessOpenAPI(OpenAPI openAPI) {
if (useOneOfInterfaces) { if (useOneOfInterfaces) {
// we process the openapi schema here to find oneOf schemas and create interface models for them // we process the openapi schema here to find oneOf schemas and create interface models for them
Map<String, Schema> schemas = new HashMap<String, Schema>(openAPI.getComponents().getSchemas()); Map<String, Schema> schemas = new HashMap<>(openAPI.getComponents().getSchemas());
if (schemas == null) { if (schemas == null) {
schemas = new HashMap<String, Schema>(); schemas = new HashMap<>();
} }
Map<String, PathItem> pathItems = openAPI.getPaths(); Map<String, PathItem> pathItems = openAPI.getPaths();
@ -858,12 +858,12 @@ public class DefaultCodegen implements CodegenConfig {
} }
// also add all properties of all schemas to be checked for oneOf // also add all properties of all schemas to be checked for oneOf
Map<String, Schema> propertySchemas = new HashMap<String, Schema>(); Map<String, Schema> propertySchemas = new HashMap<>();
for (Map.Entry<String, Schema> e : schemas.entrySet()) { for (Map.Entry<String, Schema> e : schemas.entrySet()) {
Schema s = e.getValue(); Schema s = e.getValue();
Map<String, Schema> props = s.getProperties(); Map<String, Schema> props = s.getProperties();
if (props == null) { if (props == null) {
props = new HashMap<String, Schema>(); props = new HashMap<>();
} }
for (Map.Entry<String, Schema> p : props.entrySet()) { for (Map.Entry<String, Schema> p : props.entrySet()) {
propertySchemas.put(e.getKey() + "/" + p.getKey(), p.getValue()); propertySchemas.put(e.getKey() + "/" + p.getKey(), p.getValue());
@ -1431,7 +1431,7 @@ public class DefaultCodegen implements CodegenConfig {
public String toVarName(final String name) { public String toVarName(final String name) {
if (reservedWords.contains(name)) { if (reservedWords.contains(name)) {
return escapeReservedWord(name); return escapeReservedWord(name);
} else if (name.chars().anyMatch(character -> specialCharReplacements.containsKey("" + ((char) character)))) { } else if (name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character)))) {
return escape(name, specialCharReplacements, null, null); return escape(name, specialCharReplacements, null, null);
} }
return name; return name;
@ -1449,7 +1449,7 @@ public class DefaultCodegen implements CodegenConfig {
name = removeNonNameElementToCamelCase(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. name = removeNonNameElementToCamelCase(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
if (reservedWords.contains(name)) { if (reservedWords.contains(name)) {
return escapeReservedWord(name); return escapeReservedWord(name);
} else if (name.chars().anyMatch(character -> specialCharReplacements.containsKey("" + ((char) character)))) { } else if (name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character)))) {
return escape(name, specialCharReplacements, null, null); return escape(name, specialCharReplacements, null, null);
} }
return name; return name;
@ -1547,7 +1547,7 @@ public class DefaultCodegen implements CodegenConfig {
.generationMessage(String.format(Locale.ROOT, "OpenAPI Generator: %s (%s)", getName(), codegenType.toValue())) .generationMessage(String.format(Locale.ROOT, "OpenAPI Generator: %s (%s)", getName(), codegenType.toValue()))
.build(); .build();
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList("double", Arrays.asList("double",
"int", "int",
"long", "long",
@ -1564,7 +1564,7 @@ public class DefaultCodegen implements CodegenConfig {
"Float") "Float")
); );
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("array", "List"); typeMapping.put("array", "List");
typeMapping.put("set", "Set"); typeMapping.put("set", "Set");
typeMapping.put("map", "Map"); typeMapping.put("map", "Map");
@ -1591,9 +1591,9 @@ public class DefaultCodegen implements CodegenConfig {
typeMapping.put("URI", "URI"); typeMapping.put("URI", "URI");
typeMapping.put("AnyType", "oas_any_type_not_mapped"); typeMapping.put("AnyType", "oas_any_type_not_mapped");
instantiationTypes = new HashMap<String, String>(); instantiationTypes = new HashMap<>();
reservedWords = new HashSet<String>(); reservedWords = new HashSet<>();
cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString())); CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
@ -1748,7 +1748,7 @@ public class DefaultCodegen implements CodegenConfig {
if (!param.getRequired()) { if (!param.getRequired()) {
paramPart.append("]"); paramPart.append("]");
} }
sb.append(paramPart.toString()); sb.append(paramPart);
} }
} }
} }
@ -2382,14 +2382,14 @@ public class DefaultCodegen implements CodegenConfig {
} }
} }
Map<NamedSchema, CodegenProperty> schemaCodegenPropertyCache = new HashMap<NamedSchema, CodegenProperty>(); Map<NamedSchema, CodegenProperty> schemaCodegenPropertyCache = new HashMap<>();
protected void updateModelForComposedSchema(CodegenModel m, Schema schema, Map<String, Schema> allDefinitions) { protected void updateModelForComposedSchema(CodegenModel m, Schema schema, Map<String, Schema> allDefinitions) {
final ComposedSchema composed = (ComposedSchema) schema; final ComposedSchema composed = (ComposedSchema) schema;
Map<String, Schema> properties = new LinkedHashMap<String, Schema>(); Map<String, Schema> properties = new LinkedHashMap<>();
List<String> required = new ArrayList<String>(); List<String> required = new ArrayList<>();
Map<String, Schema> allProperties = new LinkedHashMap<String, Schema>(); Map<String, Schema> allProperties = new LinkedHashMap<>();
List<String> allRequired = new ArrayList<String>(); List<String> allRequired = new ArrayList<>();
// if schema has properties outside of allOf/oneOf/anyOf also add them to m // if schema has properties outside of allOf/oneOf/anyOf also add them to m
if (composed.getProperties() != null && !composed.getProperties().isEmpty()) { if (composed.getProperties() != null && !composed.getProperties().isEmpty()) {
@ -2407,7 +2407,7 @@ public class DefaultCodegen implements CodegenConfig {
// TODO revise the logic below to set discriminator, xml attributes // TODO revise the logic below to set discriminator, xml attributes
if (supportsInheritance || supportsMixins) { if (supportsInheritance || supportsMixins) {
m.allVars = new ArrayList<CodegenProperty>(); m.allVars = new ArrayList<>();
if (composed.getAllOf() != null) { if (composed.getAllOf() != null) {
int modelImplCnt = 0; // only one inline object allowed in a ComposedModel int modelImplCnt = 0; // only one inline object allowed in a ComposedModel
int modelDiscriminators = 0; // only one discriminator allowed in a ComposedModel int modelDiscriminators = 0; // only one discriminator allowed in a ComposedModel
@ -2443,7 +2443,7 @@ public class DefaultCodegen implements CodegenConfig {
if (!interfaces.isEmpty()) { if (!interfaces.isEmpty()) {
// m.interfaces is for backward compatibility // m.interfaces is for backward compatibility
if (m.interfaces == null) if (m.interfaces == null)
m.interfaces = new ArrayList<String>(); m.interfaces = new ArrayList<>();
for (Schema interfaceSchema : interfaces) { for (Schema interfaceSchema : interfaces) {
interfaceSchema = unaliasSchema(interfaceSchema, importMapping); interfaceSchema = unaliasSchema(interfaceSchema, importMapping);
@ -2521,7 +2521,7 @@ public class DefaultCodegen implements CodegenConfig {
m.parent = toModelName(parentName); m.parent = toModelName(parentName);
if (supportsMultipleInheritance) { if (supportsMultipleInheritance) {
m.allParents = new ArrayList<String>(); m.allParents = new ArrayList<>();
for (String pname : allParents) { for (String pname : allParents) {
String pModelName = toModelName(pname); String pModelName = toModelName(pname);
m.allParents.add(pModelName); m.allParents.add(pModelName);
@ -2673,7 +2673,7 @@ public class DefaultCodegen implements CodegenConfig {
// TODO remove the anyType check here in the future ANyType models can have enums defined // TODO remove the anyType check here in the future ANyType models can have enums defined
m.isEnum = true; m.isEnum = true;
// comment out below as allowableValues is not set in post processing model enum // comment out below as allowableValues is not set in post processing model enum
m.allowableValues = new HashMap<String, Object>(); m.allowableValues = new HashMap<>();
m.allowableValues.put("values", schema.getEnum()); m.allowableValues.put("values", schema.getEnum());
} }
if (!ModelUtils.isArraySchema(schema)) { if (!ModelUtils.isArraySchema(schema)) {
@ -2742,7 +2742,7 @@ public class DefaultCodegen implements CodegenConfig {
// set isDiscriminator on the discriminator property // set isDiscriminator on the discriminator property
if (m.discriminator != null) { if (m.discriminator != null) {
String discPropName = m.discriminator.getPropertyBaseName(); String discPropName = m.discriminator.getPropertyBaseName();
List<List<CodegenProperty>> listOLists = new ArrayList<List<CodegenProperty>>(); List<List<CodegenProperty>> listOLists = new ArrayList<>();
listOLists.add(m.requiredVars); listOLists.add(m.requiredVars);
listOLists.add(m.vars); listOLists.add(m.vars);
listOLists.add(m.allVars); listOLists.add(m.allVars);
@ -3461,13 +3461,13 @@ public class DefaultCodegen implements CodegenConfig {
//Inline enum case: //Inline enum case:
if (p.getEnum() != null && !p.getEnum().isEmpty()) { if (p.getEnum() != null && !p.getEnum().isEmpty()) {
List<Object> _enum = p.getEnum(); List<Object> _enum = p.getEnum();
property._enum = new ArrayList<String>(); property._enum = new ArrayList<>();
for (Object i : _enum) { for (Object i : _enum) {
property._enum.add(String.valueOf(i)); property._enum.add(String.valueOf(i));
} }
property.isEnum = true; property.isEnum = true;
Map<String, Object> allowableValues = new HashMap<String, Object>(); Map<String, Object> allowableValues = new HashMap<>();
allowableValues.put("values", _enum); allowableValues.put("values", _enum);
if (allowableValues.size() > 0) { if (allowableValues.size() > 0) {
property.allowableValues = allowableValues; property.allowableValues = allowableValues;
@ -3480,7 +3480,7 @@ public class DefaultCodegen implements CodegenConfig {
if (referencedSchema.getEnum() != null && !referencedSchema.getEnum().isEmpty()) { if (referencedSchema.getEnum() != null && !referencedSchema.getEnum().isEmpty()) {
List<Object> _enum = referencedSchema.getEnum(); List<Object> _enum = referencedSchema.getEnum();
Map<String, Object> allowableValues = new HashMap<String, Object>(); Map<String, Object> allowableValues = new HashMap<>();
allowableValues.put("values", _enum); allowableValues.put("values", _enum);
if (allowableValues.size() > 0) { if (allowableValues.size() > 0) {
property.allowableValues = allowableValues; property.allowableValues = allowableValues;
@ -3783,7 +3783,7 @@ public class DefaultCodegen implements CodegenConfig {
Map<String, Schema> schemas, Map<String, Schema> schemas,
CodegenOperation op, CodegenOperation op,
ApiResponse methodResponse) { ApiResponse methodResponse) {
handleMethodResponse(operation, schemas, op, methodResponse, Collections.<String, String>emptyMap()); handleMethodResponse(operation, schemas, op, methodResponse, Collections.emptyMap());
} }
/** /**
@ -3888,7 +3888,7 @@ public class DefaultCodegen implements CodegenConfig {
Map<String, Schema> schemas = ModelUtils.getSchemas(this.openAPI); Map<String, Schema> schemas = ModelUtils.getSchemas(this.openAPI);
CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION); CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION);
Set<String> imports = new HashSet<String>(); Set<String> imports = new HashSet<>();
if (operation.getExtensions() != null && !operation.getExtensions().isEmpty()) { if (operation.getExtensions() != null && !operation.getExtensions().isEmpty()) {
op.vendorExtensions.putAll(operation.getExtensions()); op.vendorExtensions.putAll(operation.getExtensions());
@ -3986,15 +3986,15 @@ public class DefaultCodegen implements CodegenConfig {
} }
List<Parameter> parameters = operation.getParameters(); List<Parameter> parameters = operation.getParameters();
List<CodegenParameter> allParams = new ArrayList<CodegenParameter>(); List<CodegenParameter> allParams = new ArrayList<>();
List<CodegenParameter> bodyParams = new ArrayList<CodegenParameter>(); List<CodegenParameter> bodyParams = new ArrayList<>();
List<CodegenParameter> pathParams = new ArrayList<CodegenParameter>(); List<CodegenParameter> pathParams = new ArrayList<>();
List<CodegenParameter> queryParams = new ArrayList<CodegenParameter>(); List<CodegenParameter> queryParams = new ArrayList<>();
List<CodegenParameter> headerParams = new ArrayList<CodegenParameter>(); List<CodegenParameter> headerParams = new ArrayList<>();
List<CodegenParameter> cookieParams = new ArrayList<CodegenParameter>(); List<CodegenParameter> cookieParams = new ArrayList<>();
List<CodegenParameter> formParams = new ArrayList<CodegenParameter>(); List<CodegenParameter> formParams = new ArrayList<>();
List<CodegenParameter> requiredParams = new ArrayList<CodegenParameter>(); List<CodegenParameter> requiredParams = new ArrayList<>();
List<CodegenParameter> optionalParams = new ArrayList<CodegenParameter>(); List<CodegenParameter> optionalParams = new ArrayList<>();
CodegenParameter bodyParam = null; CodegenParameter bodyParam = null;
RequestBody requestBody = operation.getRequestBody(); RequestBody requestBody = operation.getRequestBody();
@ -4039,7 +4039,7 @@ public class DefaultCodegen implements CodegenConfig {
// add example // add example
if (schemas != null) { if (schemas != null) {
op.requestBodyExamples = new ExampleGenerator(schemas, this.openAPI).generate(null, new ArrayList<String>(getConsumesInfo(this.openAPI, operation)), bodyParam.baseType); op.requestBodyExamples = new ExampleGenerator(schemas, this.openAPI).generate(null, new ArrayList<>(getConsumesInfo(this.openAPI, operation)), bodyParam.baseType);
} }
} }
} }
@ -4531,7 +4531,7 @@ public class DefaultCodegen implements CodegenConfig {
return codegenParameter; return codegenParameter;
} }
parameterSchema = unaliasSchema(parameterSchema, Collections.<String, String>emptyMap()); parameterSchema = unaliasSchema(parameterSchema, Collections.emptyMap());
if (parameterSchema == null) { if (parameterSchema == null) {
LOGGER.warn("warning! Schema not found for parameter \" {} \", using String", parameter.getName()); LOGGER.warn("warning! Schema not found for parameter \" {} \", using String", parameter.getName());
parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition."); parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition.");
@ -4755,7 +4755,7 @@ public class DefaultCodegen implements CodegenConfig {
return Collections.emptyList(); return Collections.emptyList();
} }
List<CodegenSecurity> codegenSecurities = new ArrayList<CodegenSecurity>(securitySchemeMap.size()); List<CodegenSecurity> codegenSecurities = new ArrayList<>(securitySchemeMap.size());
for (String key : securitySchemeMap.keySet()) { for (String key : securitySchemeMap.keySet()) {
final SecurityScheme securityScheme = securitySchemeMap.get(key); final SecurityScheme securityScheme = securitySchemeMap.get(key);
if (SecurityScheme.Type.APIKEY.equals(securityScheme.getType())) { if (SecurityScheme.Type.APIKEY.equals(securityScheme.getType())) {
@ -4855,7 +4855,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
protected void setReservedWordsLowerCase(List<String> words) { protected void setReservedWordsLowerCase(List<String> words) {
reservedWords = new HashSet<String>(); reservedWords = new HashSet<>();
for (String word : words) { for (String word : words) {
reservedWords.add(word.toLowerCase(Locale.ROOT)); reservedWords.add(word.toLowerCase(Locale.ROOT));
} }
@ -4918,9 +4918,9 @@ public class DefaultCodegen implements CodegenConfig {
return null; return null;
} }
final List<Map<String, Object>> output = new ArrayList<Map<String, Object>>(examples.size()); final List<Map<String, Object>> output = new ArrayList<>(examples.size());
for (Map.Entry<String, Object> entry : examples.entrySet()) { for (Map.Entry<String, Object> entry : examples.entrySet()) {
final Map<String, Object> kv = new HashMap<String, Object>(); final Map<String, Object> kv = new HashMap<>();
kv.put("contentType", entry.getKey()); kv.put("contentType", entry.getKey());
kv.put("example", entry.getValue()); kv.put("example", entry.getValue());
output.add(kv); output.add(kv);
@ -4976,7 +4976,7 @@ public class DefaultCodegen implements CodegenConfig {
co, Map<String, List<CodegenOperation>> operations) { co, Map<String, List<CodegenOperation>> operations) {
List<CodegenOperation> opList = operations.get(tag); List<CodegenOperation> opList = operations.get(tag);
if (opList == null) { if (opList == null) {
opList = new ArrayList<CodegenOperation>(); opList = new ArrayList<>();
operations.put(tag, opList); operations.put(tag, opList);
} }
// check for operationId uniqueness // check for operationId uniqueness
@ -5084,8 +5084,8 @@ public class DefaultCodegen implements CodegenConfig {
m.hasVars = true; m.hasVars = true;
m.hasEnums = false; // TODO need to fix as its false in both cases m.hasEnums = false; // TODO need to fix as its false in both cases
Set<String> mandatory = required == null ? Collections.<String>emptySet() Set<String> mandatory = required == null ? Collections.emptySet()
: new TreeSet<String>(required); : new TreeSet<>(required);
// update "vars" without parent's properties (all, required) // update "vars" without parent's properties (all, required)
addVars(m, m.vars, properties, mandatory); addVars(m, m.vars, properties, mandatory);
@ -5097,8 +5097,8 @@ public class DefaultCodegen implements CodegenConfig {
} }
if (allProperties != null) { if (allProperties != null) {
Set<String> allMandatory = allRequired == null ? Collections.<String>emptySet() Set<String> allMandatory = allRequired == null ? Collections.emptySet()
: new TreeSet<String>(allRequired); : new TreeSet<>(allRequired);
// update "vars" with parent's properties (all, required) // update "vars" with parent's properties (all, required)
addVars(m, m.allVars, allProperties, allMandatory); addVars(m, m.allVars, allProperties, allMandatory);
m.allMandatory = allMandatory; m.allMandatory = allMandatory;
@ -5108,14 +5108,14 @@ public class DefaultCodegen implements CodegenConfig {
} }
// loop through list to update property name with toVarName // loop through list to update property name with toVarName
Set<String> renamedMandatory = new ConcurrentSkipListSet<String>(); Set<String> renamedMandatory = new ConcurrentSkipListSet<>();
Iterator<String> mandatoryIterator = m.mandatory.iterator(); Iterator<String> mandatoryIterator = m.mandatory.iterator();
while (mandatoryIterator.hasNext()) { while (mandatoryIterator.hasNext()) {
renamedMandatory.add(toVarName(mandatoryIterator.next())); renamedMandatory.add(toVarName(mandatoryIterator.next()));
} }
m.mandatory = renamedMandatory; m.mandatory = renamedMandatory;
Set<String> renamedAllMandatory = new ConcurrentSkipListSet<String>(); Set<String> renamedAllMandatory = new ConcurrentSkipListSet<>();
Iterator<String> allMandatoryIterator = m.allMandatory.iterator(); Iterator<String> allMandatoryIterator = m.allMandatory.iterator();
while (allMandatoryIterator.hasNext()) { while (allMandatoryIterator.hasNext()) {
renamedAllMandatory.add(toVarName(allMandatoryIterator.next())); renamedAllMandatory.add(toVarName(allMandatoryIterator.next()));
@ -5568,7 +5568,7 @@ public class DefaultCodegen implements CodegenConfig {
* @return sanitized string * @return sanitized string
*/ */
public String sanitizeName(String name, String removeCharRegEx) { public String sanitizeName(String name, String removeCharRegEx) {
return sanitizeName(name, removeCharRegEx, new ArrayList<String>()); return sanitizeName(name, removeCharRegEx, new ArrayList<>());
} }
/** /**
@ -5827,7 +5827,7 @@ public class DefaultCodegen implements CodegenConfig {
enumName = String.valueOf(value); enumName = String.valueOf(value);
} else { } else {
enumName = value.toString().substring(truncateIdx); enumName = value.toString().substring(truncateIdx);
if ("".equals(enumName)) { if (enumName.isEmpty()) {
enumName = value.toString(); enumName = value.toString();
} }
} }
@ -6057,7 +6057,7 @@ public class DefaultCodegen implements CodegenConfig {
return null; return null;
} }
Set<String> produces = new ConcurrentSkipListSet<String>(); Set<String> produces = new ConcurrentSkipListSet<>();
for (ApiResponse r : operation.getResponses().values()) { for (ApiResponse r : operation.getResponses().values()) {
ApiResponse response = ModelUtils.getReferencedApiResponse(openAPI, r); ApiResponse response = ModelUtils.getReferencedApiResponse(openAPI, r);
@ -6108,7 +6108,7 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.debug("debugging fromRequestBodyToFormParameters= {}", body); LOGGER.debug("debugging fromRequestBodyToFormParameters= {}", body);
Schema schema = ModelUtils.getSchemaFromRequestBody(body); Schema schema = ModelUtils.getSchemaFromRequestBody(body);
schema = ModelUtils.getReferencedSchema(this.openAPI, schema); schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
List<String> allRequired = new ArrayList<String>(); List<String> allRequired = new ArrayList<>();
Map<String, Schema> properties = new LinkedHashMap<>(); Map<String, Schema> properties = new LinkedHashMap<>();
// this traverses a composed schema and extracts all properties in each schema into properties // this traverses a composed schema and extracts all properties in each schema into properties
// TODO in the future have this return one codegenParameter of type object or composed which includes all definition // TODO in the future have this return one codegenParameter of type object or composed which includes all definition
@ -6953,7 +6953,7 @@ public class DefaultCodegen implements CodegenConfig {
cm.name = type; cm.name = type;
cm.classname = type; cm.classname = type;
cm.vendorExtensions.put("x-is-one-of-interface", true); cm.vendorExtensions.put("x-is-one-of-interface", true);
cm.interfaceModels = new ArrayList<CodegenModel>(); cm.interfaceModels = new ArrayList<>();
addOneOfInterfaces.add(cm); addOneOfInterfaces.add(cm);
} }
@ -7171,7 +7171,7 @@ public class DefaultCodegen implements CodegenConfig {
List<CodegenProperty> xOf = new ArrayList<>(); List<CodegenProperty> xOf = new ArrayList<>();
int i = 0; int i = 0;
for (Schema xOfSchema: xOfCollection) { for (Schema xOfSchema: xOfCollection) {
CodegenProperty cp = fromProperty(collectionName + "_" + String.valueOf(i), xOfSchema); CodegenProperty cp = fromProperty(collectionName + "_" + i, xOfSchema);
xOf.add(cp); xOf.add(cp);
i += 1; i += 1;
} }

View File

@ -129,6 +129,6 @@ public class SpecValidationException extends RuntimeException {
}); });
return super.getMessage() + " | " + return super.getMessage() + " | " +
"Error count: " + errorCount + ", Warning count: " + warningCount + sb.toString(); "Error count: " + errorCount + ", Warning count: " + warningCount + sb;
} }
} }

View File

@ -103,7 +103,7 @@ public class TemplateManager implements TemplatingExecutor, TemplateProcessor {
* @param name The location of the template * @param name The location of the template
* @return The raw template contents * @return The raw template contents
*/ */
@SuppressWarnings({"java:S112"}) @SuppressWarnings("java:S112")
// ignored rule java:S112 as RuntimeException is used to match previous exception type // ignored rule java:S112 as RuntimeException is used to match previous exception type
public String readTemplate(String name) { public String readTemplate(String name) {
if (name == null || name.contains("..")) { if (name == null || name.contains("..")) {

View File

@ -26,7 +26,7 @@ public class TemplatingEngineLoader {
throw new IllegalStateException("Utility class"); throw new IllegalStateException("Utility class");
} }
@SuppressWarnings({"java:S112"}) // ignore java:S112 as generic RuntimeException is acceptable here @SuppressWarnings("java:S112") // ignore java:S112 as generic RuntimeException is acceptable here
public static TemplatingEngineAdapter byIdentifier(String id) { public static TemplatingEngineAdapter byIdentifier(String id) {
ServiceLoader<TemplatingEngineAdapter> loader = ServiceLoader.load(TemplatingEngineAdapter.class, TemplatingEngineLoader.class.getClassLoader()); ServiceLoader<TemplatingEngineAdapter> loader = ServiceLoader.load(TemplatingEngineAdapter.class, TemplatingEngineLoader.class.getClassLoader());
@ -42,7 +42,7 @@ public class TemplatingEngineLoader {
// Attempt to load skipping SPI // Attempt to load skipping SPI
return (TemplatingEngineAdapter) Class.forName(id).getDeclaredConstructor().newInstance(); return (TemplatingEngineAdapter) Class.forName(id).getDeclaredConstructor().newInstance();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(String.format(Locale.ROOT, "Couldn't load template engine adapter %s. Available options: %n%s", id, sb.toString()), e); throw new RuntimeException(String.format(Locale.ROOT, "Couldn't load template engine adapter %s. Available options: %n%s", id, sb), e);
} }
} }
} }

View File

@ -535,9 +535,7 @@ public class CodegenConfigurator {
Set<String> warnings = new HashSet<>(); Set<String> warnings = new HashSet<>();
if (specification != null) { if (specification != null) {
List<String> unusedModels = ModelUtils.getUnusedSchemas(specification); List<String> unusedModels = ModelUtils.getUnusedSchemas(specification);
if (unusedModels != null) { unusedModels.forEach(name -> warnings.add("Unused model: " + name));
unusedModels.forEach(name -> warnings.add("Unused model: " + name));
}
} }
if (workflowSettings.isValidateSpec()) { if (workflowSettings.isValidateSpec()) {

View File

@ -165,7 +165,7 @@ public class ExampleGenerator {
} }
} else if (modelName != null && mediaType.startsWith(MIME_TYPE_XML)) { } else if (modelName != null && mediaType.startsWith(MIME_TYPE_XML)) {
final Schema schema = this.examples.get(modelName); final Schema schema = this.examples.get(modelName);
String example = new XmlExampleGenerator(this.examples).toXml(schema, 0, Collections.<String>emptySet()); String example = new XmlExampleGenerator(this.examples).toXml(schema, 0, Collections.emptySet());
if (example != null) { if (example != null) {
kv.put(EXAMPLE, example); kv.put(EXAMPLE, example);
output.add(kv); output.add(kv);

View File

@ -44,7 +44,7 @@ public class XmlExampleGenerator {
} }
public String toXml(Schema schema) { public String toXml(Schema schema) {
return toXml(null, schema, 0, Collections.<String>emptySet()); return toXml(null, schema, 0, Collections.emptySet());
} }
protected String toXml(Schema schema, int indent, Collection<String> path) { protected String toXml(Schema schema, int indent, Collection<String> path) {

View File

@ -41,7 +41,7 @@ public class RootedFileRule extends Rule {
} }
private String getExtensionPart(final String input, int stopIndex) { private String getExtensionPart(final String input, int stopIndex) {
return input.substring(stopIndex > 0 ? stopIndex+1: input.length(), input.length()); return input.substring(stopIndex > 0 ? stopIndex+1: input.length());
} }
@Override @Override

View File

@ -50,7 +50,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
protected List<Map<String, Object>> orderedModels; protected List<Map<String, Object>> orderedModels;
protected final Map<String, List<String>> modelDepends; protected final Map<String, List<String>> modelDepends;
protected final Map<String, String> nullableTypeMapping; protected final Map<String, String> nullableTypeMapping;
protected final HashMap<String, String> operationsScopes; protected final Map<String, String> operationsScopes;
protected int scopeIndex = 0; protected int scopeIndex = 0;
public AbstractAdaCodegen() { public AbstractAdaCodegen() {
@ -155,7 +155,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
"xor") "xor")
); );
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("date", "Swagger.Date"); typeMapping.put("date", "Swagger.Date");
typeMapping.put("DateTime", "Swagger.Datetime"); typeMapping.put("DateTime", "Swagger.Datetime");
typeMapping.put("string", "Swagger.UString"); typeMapping.put("string", "Swagger.UString");
@ -172,7 +172,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
typeMapping.put("binary", "Swagger.Binary"); typeMapping.put("binary", "Swagger.Binary");
// Mapping to convert an Ada required type to an optional type (nullable). // Mapping to convert an Ada required type to an optional type (nullable).
nullableTypeMapping = new HashMap<String, String>(); nullableTypeMapping = new HashMap<>();
nullableTypeMapping.put("Swagger.Date", "Swagger.Nullable_Date"); nullableTypeMapping.put("Swagger.Date", "Swagger.Nullable_Date");
nullableTypeMapping.put("Swagger.Datetime", "Swagger.Nullable_Date"); nullableTypeMapping.put("Swagger.Datetime", "Swagger.Nullable_Date");
nullableTypeMapping.put("Swagger.UString", "Swagger.Nullable_UString"); nullableTypeMapping.put("Swagger.UString", "Swagger.Nullable_UString");
@ -181,10 +181,10 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
nullableTypeMapping.put("Boolean", "Swagger.Nullable_Boolean"); nullableTypeMapping.put("Boolean", "Swagger.Nullable_Boolean");
nullableTypeMapping.put("Swagger.Object", "Swagger.Object"); nullableTypeMapping.put("Swagger.Object", "Swagger.Object");
modelDepends = new HashMap<String, List<String>>(); modelDepends = new HashMap<>();
orderedModels = new ArrayList<Map<String, Object>>(); orderedModels = new ArrayList<>();
operationsScopes = new HashMap<String, String>(); operationsScopes = new HashMap<>();
super.importMapping = new HashMap<String, String>(); super.importMapping = new HashMap<>();
// CLI options // CLI options
addOption(CodegenConstants.PROJECT_NAME, "GNAT project name", addOption(CodegenConstants.PROJECT_NAME, "GNAT project name",
@ -193,7 +193,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
modelNameSuffix = "Type"; modelNameSuffix = "Type";
embeddedTemplateDir = templateDir = "Ada"; embeddedTemplateDir = templateDir = "Ada";
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList("integer", "boolean", "number", "long", "float", Arrays.asList("integer", "boolean", "number", "long", "float",
"double", "object", "string", "date", "DateTime", "binary")); "double", "object", "string", "date", "DateTime", "binary"));
} }
@ -651,7 +651,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
Object v = model.get("model"); Object v = model.get("model");
if (v instanceof CodegenModel) { if (v instanceof CodegenModel) {
CodegenModel m = (CodegenModel) v; CodegenModel m = (CodegenModel) v;
List<String> d = new ArrayList<String>(); List<String> d = new ArrayList<>();
for (CodegenProperty p : m.vars) { for (CodegenProperty p : m.vars) {
boolean isModel = false; boolean isModel = false;
CodegenProperty item = p; CodegenProperty item = p;
@ -687,8 +687,8 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
// if I find a model that has no dependencies, or all of its dependencies are in revisedOrderedModels, consider it the independentModel // if I find a model that has no dependencies, or all of its dependencies are in revisedOrderedModels, consider it the independentModel
// put the independentModel at the end of revisedOrderedModels, and remove it from orderedModels // put the independentModel at the end of revisedOrderedModels, and remove it from orderedModels
// //
List<Map<String, Object>> revisedOrderedModels = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> revisedOrderedModels = new ArrayList<>();
List<String> collectedModelNames = new ArrayList<String>(); List<String> collectedModelNames = new ArrayList<>();
int sizeOrderedModels = orderedModels.size(); int sizeOrderedModels = orderedModels.size();
for (int i = 0; i < sizeOrderedModels; i++) { for (int i = 0; i < sizeOrderedModels; i++) {
Map<String, Object> independentModel = null; Map<String, Object> independentModel = null;
@ -760,7 +760,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
* @return the authMethods to be used by the operation with its required scopes. * @return the authMethods to be used by the operation with its required scopes.
*/ */
private List<CodegenSecurity> postProcessAuthMethod(List<CodegenSecurity> authMethods, Map<String, List<String>> scopes) { private List<CodegenSecurity> postProcessAuthMethod(List<CodegenSecurity> authMethods, Map<String, List<String>> scopes) {
List<CodegenSecurity> result = (scopes == null) ? null : new ArrayList<CodegenSecurity>(); List<CodegenSecurity> result = (scopes == null) ? null : new ArrayList<>();
if (authMethods != null) { if (authMethods != null) {
for (CodegenSecurity authMethod : authMethods) { for (CodegenSecurity authMethod : authMethods) {
if (authMethod.scopes != null) { if (authMethod.scopes != null) {
@ -803,7 +803,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
opSecurity.isKeyInQuery = authMethod.isKeyInQuery; opSecurity.isKeyInQuery = authMethod.isKeyInQuery;
opSecurity.flow = authMethod.flow; opSecurity.flow = authMethod.flow;
opSecurity.tokenUrl = authMethod.tokenUrl; opSecurity.tokenUrl = authMethod.tokenUrl;
List<Map<String, Object>> opAuthScopes = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> opAuthScopes = new ArrayList<>();
for (String opScopeName : opScopes) { for (String opScopeName : opScopes) {
for (Map<String, Object> scope : authMethod.scopes) { for (Map<String, Object> scope : authMethod.scopes) {
String name = (String) scope.get("scope"); String name = (String) scope.get("scope");

View File

@ -81,9 +81,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
protected boolean supportNullable = Boolean.FALSE; protected boolean supportNullable = Boolean.FALSE;
// nullable type // nullable type
protected Set<String> nullableType = new HashSet<String>(); protected Set<String> nullableType = new HashSet<>();
protected Set<String> valueTypes = new HashSet<String>(); protected Set<String> valueTypes = new HashSet<>();
private final Logger LOGGER = LoggerFactory.getLogger(AbstractCSharpCodegen.class); private final Logger LOGGER = LoggerFactory.getLogger(AbstractCSharpCodegen.class);
@ -104,14 +104,14 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
outputFolder = "generated-code" + File.separator + this.getName(); outputFolder = "generated-code" + File.separator + this.getName();
embeddedTemplateDir = templateDir = this.getName(); embeddedTemplateDir = templateDir = this.getName();
collectionTypes = new HashSet<String>( collectionTypes = new HashSet<>(
Arrays.asList( Arrays.asList(
"IList", "List", "IList", "List",
"ICollection", "Collection", "ICollection", "Collection",
"IEnumerable") "IEnumerable")
); );
mapTypes = new HashSet<String>( mapTypes = new HashSet<>(
Arrays.asList("IDictionary") Arrays.asList("IDictionary")
); );
@ -141,7 +141,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
); );
// TODO: Either include fully qualified names here or handle in DefaultCodegen via lastIndexOf(".") search // TODO: Either include fully qualified names here or handle in DefaultCodegen via lastIndexOf(".") search
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"String", "String",
"string", "string",
@ -184,7 +184,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// Nullable types here assume C# 2 support is not part of base // Nullable types here assume C# 2 support is not part of base
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("string", "string"); typeMapping.put("string", "string");
typeMapping.put("binary", "byte[]"); typeMapping.put("binary", "byte[]");
typeMapping.put("ByteArray", "byte[]"); typeMapping.put("ByteArray", "byte[]");
@ -207,11 +207,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("AnyType", "Object"); typeMapping.put("AnyType", "Object");
// nullable type // nullable type
nullableType = new HashSet<String>( nullableType = new HashSet<>(
Arrays.asList("decimal", "bool", "int", "float", "long", "double", "DateTime", "DateTimeOffset", "Guid") Arrays.asList("decimal", "bool", "int", "float", "long", "double", "DateTime", "DateTimeOffset", "Guid")
); );
// value Types // value Types
valueTypes = new HashSet<String>( valueTypes = new HashSet<>(
Arrays.asList("decimal", "bool", "int", "float", "long", "double") Arrays.asList("decimal", "bool", "int", "float", "long", "double")
); );
} }
@ -463,9 +463,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
* *
* @param models processed models to be further processed for enum references * @param models processed models to be further processed for enum references
*/ */
@SuppressWarnings({"unchecked"}) @SuppressWarnings("unchecked")
private void postProcessEnumRefs(final Map<String, Object> models) { private void postProcessEnumRefs(final Map<String, Object> models) {
Map<String, CodegenModel> enumRefs = new HashMap<String, CodegenModel>(); Map<String, CodegenModel> enumRefs = new HashMap<>();
for (Map.Entry<String, Object> entry : models.entrySet()) { for (Map.Entry<String, Object> entry : models.entrySet()) {
CodegenModel model = ModelUtils.getModelByName(entry.getKey(), models); CodegenModel model = ModelUtils.getModelByName(entry.getKey(), models);
if (model.isEnum) { if (model.isEnum) {
@ -1325,7 +1325,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// only process files with .cs extension // only process files with .cs extension
if ("cs".equals(FilenameUtils.getExtension(file.toString()))) { if ("cs".equals(FilenameUtils.getExtension(file.toString()))) {
String command = csharpPostProcessFile + " " + file.toString(); String command = csharpPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -323,7 +323,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
} }
// only process files with cpp extension // only process files with cpp extension
if ("cpp".equals(FilenameUtils.getExtension(file.toString())) || "h".equals(FilenameUtils.getExtension(file.toString()))) { if ("cpp".equals(FilenameUtils.getExtension(file.toString())) || "h".equals(FilenameUtils.getExtension(file.toString()))) {
String command = cppPostProcessFile + " " + file.toString(); String command = cppPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
p.waitFor(); p.waitFor();

View File

@ -340,7 +340,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
// replace all characters that have a mapping but ignore underscores // replace all characters that have a mapping but ignore underscores
// append an underscore to each replacement so that it can be camelized // append an underscore to each replacement so that it can be camelized
if (name.chars().anyMatch(character -> specialCharReplacements.containsKey("" + ((char) character)))) { if (name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character)))) {
name = escape(name, specialCharReplacements, Collections.singletonList("_"), "_"); name = escape(name, specialCharReplacements, Collections.singletonList("_"), "_");
} }
// remove the rest // remove the rest
@ -752,7 +752,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
// process all files with dart extension // process all files with dart extension
if ("dart".equals(FilenameUtils.getExtension(file.toString()))) { if ("dart".equals(FilenameUtils.getExtension(file.toString()))) {
// currently supported is "dartfmt -w" and "dart format" // currently supported is "dartfmt -w" and "dart format"
String command = dartPostProcessFile + " " + file.toString(); String command = dartPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -53,9 +53,9 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
"redefine", "rename", "require", "rescue", "Result", "retry", "select", "separate", "then", "True", "redefine", "rename", "require", "rescue", "Result", "retry", "select", "separate", "then", "True",
"TUPLE", "undefine", "until", "variant", "Void", "when", "xor")); "TUPLE", "undefine", "until", "variant", "Void", "when", "xor"));
defaultIncludes = new HashSet<String>(Arrays.asList("map", "array")); defaultIncludes = new HashSet<>(Arrays.asList("map", "array"));
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList("BOOLEAN", "INTEGER_8", "INTEGER_16", "INTEGER_32", "INTEGER_64", "NATURAL_8", Arrays.asList("BOOLEAN", "INTEGER_8", "INTEGER_16", "INTEGER_32", "INTEGER_64", "NATURAL_8",
"NATURAL_16", "NATURAL_32", "NATURAL_64", "REAL_32", "REAL_64")); "NATURAL_16", "NATURAL_32", "NATURAL_64", "REAL_32", "REAL_64"));
@ -559,7 +559,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
} }
public Map<String, String> createMapping(String key, String value) { public Map<String, String> createMapping(String key, String value) {
Map<String, String> customImport = new HashMap<String, String>(); Map<String, String> customImport = new HashMap<>();
customImport.put(key, value); customImport.put(key, value);
return customImport; return customImport;
@ -592,7 +592,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
public String toEiffelFeatureStyle(String operationId) { public String toEiffelFeatureStyle(String operationId) {
if (operationId.startsWith("get_")) { if (operationId.startsWith("get_")) {
return operationId.substring(4, operationId.length()); return operationId.substring(4);
} else { } else {
return operationId; return operationId;
} }

View File

@ -73,7 +73,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
// true if nullable types will be supported (as option) // true if nullable types will be supported (as option)
protected boolean supportNullable = Boolean.TRUE; protected boolean supportNullable = Boolean.TRUE;
protected Set<String> nullableType = new HashSet<String>(); protected Set<String> nullableType = new HashSet<>();
private final Logger LOGGER = LoggerFactory.getLogger(AbstractFSharpCodegen.class); private final Logger LOGGER = LoggerFactory.getLogger(AbstractFSharpCodegen.class);
@ -89,9 +89,9 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
outputFolder = this.getName(); outputFolder = this.getName();
embeddedTemplateDir = templateDir = this.getName(); embeddedTemplateDir = templateDir = this.getName();
collectionTypes = new HashSet<String>(Arrays.asList("list", "seq")); collectionTypes = new HashSet<>(Arrays.asList("list", "seq"));
mapTypes = new HashSet<String>( mapTypes = new HashSet<>(
Arrays.asList("IDictionary") Arrays.asList("IDictionary")
); );
@ -114,7 +114,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
); );
// TODO - these are based on C# generator, do we need to add any more? // TODO - these are based on C# generator, do we need to add any more?
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"String", "String",
"string", "string",
@ -156,7 +156,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
instantiationTypes.put("map", "IDictionary"); instantiationTypes.put("map", "IDictionary");
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("string", "string"); typeMapping.put("string", "string");
typeMapping.put("binary", "byte[]"); typeMapping.put("binary", "byte[]");
typeMapping.put("ByteArray", "byte[]"); typeMapping.put("ByteArray", "byte[]");
@ -177,7 +177,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("URI", "string"); typeMapping.put("URI", "string");
// nullable type // nullable type
nullableType = new HashSet<String>( nullableType = new HashSet<>(
Arrays.asList("decimal", "bool", "int", "float", "long", "double", "string", "Guid", "apiKey") Arrays.asList("decimal", "bool", "int", "float", "long", "double", "string", "Guid", "apiKey")
); );
} }
@ -349,12 +349,12 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
* Output of CodeGen models must therefore be in dependency order (rather than alphabetical order, which seems to be the default). * Output of CodeGen models must therefore be in dependency order (rather than alphabetical order, which seems to be the default).
* This could probably be made more efficient if absolutely needed. * This could probably be made more efficient if absolutely needed.
*/ */
@SuppressWarnings({"unchecked"}) @SuppressWarnings("unchecked")
public Map<String, Object> postProcessDependencyOrders(final Map<String, Object> objs) { public Map<String, Object> postProcessDependencyOrders(final Map<String, Object> objs) {
Map<String, Set<String>> dependencies = new HashMap<String, Set<String>>(); Map<String, Set<String>> dependencies = new HashMap<>();
List<String> classNames = new ArrayList<String>(); List<String> classNames = new ArrayList<>();
for (String k : objs.keySet()) { for (String k : objs.keySet()) {
CodegenModel model = ModelUtils.getModelByName(k, objs); CodegenModel model = ModelUtils.getModelByName(k, objs);
@ -381,7 +381,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
} }
} }
Map<String, Object> sorted = new LinkedHashMap<String, Object>(); Map<String, Object> sorted = new LinkedHashMap<>();
for (int i = sortedKeys.length - 1; i >= 0; i--) { for (int i = sortedKeys.length - 1; i >= 0; i--) {
Object k = sortedKeys[i]; Object k = sortedKeys[i];
sorted.put(k.toString(), objs.get(k)); sorted.put(k.toString(), objs.get(k));
@ -400,9 +400,9 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
* *
* @param models processed models to be further processed for enum references * @param models processed models to be further processed for enum references
*/ */
@SuppressWarnings({"unchecked"}) @SuppressWarnings("unchecked")
private void postProcessEnumRefs(final Map<String, Object> models) { private void postProcessEnumRefs(final Map<String, Object> models) {
Map<String, CodegenModel> enumRefs = new HashMap<String, CodegenModel>(); Map<String, CodegenModel> enumRefs = new HashMap<>();
for (Map.Entry<String, Object> entry : models.entrySet()) { for (Map.Entry<String, Object> entry : models.entrySet()) {
CodegenModel model = ModelUtils.getModelByName(entry.getKey(), models); CodegenModel model = ModelUtils.getModelByName(entry.getKey(), models);
if (model.isEnum) { if (model.isEnum) {
@ -455,10 +455,9 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
// Since we iterate enumVars for modelInnerEnum and enumClass templates, and CodegenModel is missing some of CodegenProperty's properties, // Since we iterate enumVars for modelInnerEnum and enumClass templates, and CodegenModel is missing some of CodegenProperty's properties,
// we can take advantage of Mustache's contextual lookup to add the same "properties" to the model's enumVars scope rather than CodegenProperty's scope. // we can take advantage of Mustache's contextual lookup to add the same "properties" to the model's enumVars scope rather than CodegenProperty's scope.
List<Map<String, String>> enumVars = (ArrayList<Map<String, String>>) model.allowableValues.get("enumVars"); List<Map<String, String>> enumVars = (ArrayList<Map<String, String>>) model.allowableValues.get("enumVars");
List<Map<String, Object>> newEnumVars = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> newEnumVars = new ArrayList<>();
for (Map<String, String> enumVar : enumVars) { for (Map<String, String> enumVar : enumVars) {
Map<String, Object> mixedVars = new HashMap<String, Object>(); Map<String, Object> mixedVars = new HashMap<>(enumVar);
mixedVars.putAll(enumVar);
mixedVars.put("isString", isString); mixedVars.put("isString", isString);
mixedVars.put("isLong", isLong); mixedVars.put("isLong", isLong);
@ -473,7 +472,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
} }
} }
} else { } else {
LOGGER.warn("Expected to retrieve model %s by name, but no model was found. Check your -Dmodels inclusions.", openAPIName); LOGGER.warn("Expected to retrieve model {} by name, but no model was found. Check your -Dmodels inclusions.", openAPIName);
} }
} }
} }
@ -1115,7 +1114,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
// only process files with .fs extension // only process files with .fs extension
if ("fs".equals(FilenameUtils.getExtension(file.toString()))) { if ("fs".equals(FilenameUtils.getExtension(file.toString()))) {
String command = fsharpPostProcessFile + " " + file.toString(); String command = fsharpPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -56,7 +56,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
supportsInheritance = true; supportsInheritance = true;
hideGenerationTimestamp = Boolean.FALSE; hideGenerationTimestamp = Boolean.FALSE;
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"map", "map",
"array") "array")
@ -77,7 +77,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
// Added "error" as it's used so frequently that it may as well be a keyword // Added "error" as it's used so frequently that it may as well be a keyword
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"string", "string",
"bool", "bool",
@ -133,14 +133,14 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
typeMapping.put("object", "map[string]interface{}"); typeMapping.put("object", "map[string]interface{}");
typeMapping.put("AnyType", "interface{}"); typeMapping.put("AnyType", "interface{}");
numberTypes = new HashSet<String>( numberTypes = new HashSet<>(
Arrays.asList( Arrays.asList(
"uint", "uint8", "uint16", "uint32", "uint64", "uint", "uint8", "uint16", "uint32", "uint64",
"int", "int8", "int16", "int32", "int64", "int", "int8", "int16", "int32", "int64",
"float32", "float64") "float32", "float64")
); );
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
cliOptions.clear(); cliOptions.clear();
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).") cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).")
@ -252,7 +252,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
String[] parts = name.split("_"); String[] parts = name.split("_");
String suffix = parts[parts.length - 1]; String suffix = parts[parts.length - 1];
Set<String> reservedSuffixes = new HashSet<String>(Arrays.asList( Set<String> reservedSuffixes = new HashSet<>(Arrays.asList(
// Test // Test
"test", "test",
// $GOOS // $GOOS
@ -699,7 +699,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
} }
public Map<String, String> createMapping(String key, String value) { public Map<String, String> createMapping(String key, String value) {
Map<String, String> customImport = new HashMap<String, String>(); Map<String, String> customImport = new HashMap<>();
customImport.put(key, value); customImport.put(key, value);
return customImport; return customImport;
@ -813,7 +813,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
} }
// only process the following type (or we can simply rely on the file extension to check if it's a Go file) // only process the following type (or we can simply rely on the file extension to check if it's a Go file)
Set<String> supportedFileType = new HashSet<String>( Set<String> supportedFileType = new HashSet<>(
Arrays.asList( Arrays.asList(
"supporting-mustache", "supporting-mustache",
"model-test", "model-test",
@ -828,7 +828,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
if ("go".equals(FilenameUtils.getExtension(file.toString()))) { if ("go".equals(FilenameUtils.getExtension(file.toString()))) {
// e.g. "gofmt -w yourcode.go" // e.g. "gofmt -w yourcode.go"
// e.g. "go fmt path/to/your/package" // e.g. "go fmt path/to/your/package"
String command = goPostProcessFile + " " + file.toString(); String command = goPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -55,13 +55,13 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
) )
); );
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"map", "map",
"array") "array")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"null", "null",
"ID", "ID",
@ -344,7 +344,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
} }
public Map<String, String> createMapping(String key, String value) { public Map<String, String> createMapping(String key, String value) {
Map<String, String> customImport = new HashMap<String, String>(); Map<String, String> customImport = new HashMap<>();
customImport.put(key, value); customImport.put(key, value);
return customImport; return customImport;

View File

@ -18,6 +18,7 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.PathItem;
@ -164,9 +165,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
"native", "super", "while", "null") "native", "super", "while", "null")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = Sets.newHashSet("String",
Arrays.asList(
"String",
"boolean", "boolean",
"Boolean", "Boolean",
"Double", "Double",
@ -174,7 +173,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
"Long", "Long",
"Float", "Float",
"Object", "Object",
"byte[]") "byte[]"
); );
instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("set", "LinkedHashSet"); instantiationTypes.put("set", "LinkedHashSet");
@ -713,7 +712,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} }
// If name contains special chars -> replace them. // If name contains special chars -> replace them.
if ((((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains("" + ((char) character))))) { if ((((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character))))) {
List<String> allowedCharacters = new ArrayList<>(); List<String> allowedCharacters = new ArrayList<>();
allowedCharacters.add("_"); allowedCharacters.add("_");
allowedCharacters.add("$"); allowedCharacters.add("$");
@ -996,7 +995,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
*/ */
@Override @Override
public void setParameterExampleValue(CodegenParameter codegenParameter, RequestBody requestBody) { public void setParameterExampleValue(CodegenParameter codegenParameter, RequestBody requestBody) {
Boolean isModel = (codegenParameter.isModel || (codegenParameter.isContainer && codegenParameter.getItems().isModel)); boolean isModel = (codegenParameter.isModel || (codegenParameter.isContainer && codegenParameter.getItems().isModel));
Content content = requestBody.getContent(); Content content = requestBody.getContent();
@ -1260,7 +1259,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// if the import package happens to be found in the importMapping (key) // if the import package happens to be found in the importMapping (key)
// add the corresponding import package to the list // add the corresponding import package to the list
if (importMapping.containsKey(_import)) { if (importMapping.containsKey(_import)) {
Map<String, String> newImportMap = new HashMap<String, String>(); Map<String, String> newImportMap = new HashMap<>();
newImportMap.put("import", importMapping.get(_import)); newImportMap.put("import", importMapping.get(_import));
listIterator.add(newImportMap); listIterator.add(newImportMap);
} }
@ -1285,7 +1284,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
Map<String, Object> operations = (Map<String, Object>) objs.get("operations"); Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation"); List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) { for (CodegenOperation op : operationList) {
Collection<String> operationImports = new ConcurrentSkipListSet<String>(); Collection<String> operationImports = new ConcurrentSkipListSet<>();
for (CodegenParameter p : op.allParams) { for (CodegenParameter p : op.allParams) {
if (importMapping.containsKey(p.dataType)) { if (importMapping.containsKey(p.dataType)) {
operationImports.add(importMapping.get(p.dataType)); operationImports.add(importMapping.get(p.dataType));
@ -1314,7 +1313,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
if (hasBodyParameter(openAPI, operation) || hasFormParameter(openAPI, operation)) { if (hasBodyParameter(openAPI, operation) || hasFormParameter(openAPI, operation)) {
String defaultContentType = hasFormParameter(openAPI, operation) ? "application/x-www-form-urlencoded" : "application/json"; String defaultContentType = hasFormParameter(openAPI, operation) ? "application/x-www-form-urlencoded" : "application/json";
List<String> consumes = new ArrayList<>(getConsumesInfo(openAPI, operation)); List<String> consumes = new ArrayList<>(getConsumesInfo(openAPI, operation));
String contentType = consumes == null || consumes.isEmpty() ? defaultContentType : consumes.get(0); String contentType = consumes.isEmpty() ? defaultContentType : consumes.get(0);
operation.addExtension("x-contentType", contentType); operation.addExtension("x-contentType", contentType);
} }
String accepts = getAccept(openAPI, operation); String accepts = getAccept(openAPI, operation);
@ -1865,7 +1864,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// only process files with java extension // only process files with java extension
if ("java".equals(FilenameUtils.getExtension(file.toString()))) { if ("java".equals(FilenameUtils.getExtension(file.toString()))) {
String command = javaPostProcessFile + " " + file.toString(); String command = javaPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
p.waitFor(); p.waitFor();

View File

@ -66,7 +66,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId()); updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
updateOption(CodegenConstants.API_PACKAGE, apiPackage); updateOption(CodegenConstants.API_PACKAGE, apiPackage);
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage); updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
updateOption(this.DATE_LIBRARY, this.getDateLibrary()); updateOption(DATE_LIBRARY, this.getDateLibrary());
additionalProperties.put("title", title); additionalProperties.put("title", title);
// java inflector uses the jackson lib // java inflector uses the jackson lib

View File

@ -78,7 +78,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
supportsInheritance = true; supportsInheritance = true;
setSortModelPropertiesByRequiredFlag(true); setSortModelPropertiesByRequiredFlag(true);
languageSpecificPrimitives = new HashSet<String>(Arrays.asList( languageSpecificPrimitives = new HashSet<>(Arrays.asList(
"kotlin.Byte", "kotlin.Byte",
"kotlin.ByteArray", "kotlin.ByteArray",
"kotlin.Short", "kotlin.Short",
@ -97,7 +97,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// this includes hard reserved words defined by https://github.com/JetBrains/kotlin/blob/master/core/descriptors/src/org/jetbrains/kotlin/renderer/KeywordStringsGenerated.java // this includes hard reserved words defined by https://github.com/JetBrains/kotlin/blob/master/core/descriptors/src/org/jetbrains/kotlin/renderer/KeywordStringsGenerated.java
// as well as keywords from https://kotlinlang.org/docs/reference/keyword-reference.html // as well as keywords from https://kotlinlang.org/docs/reference/keyword-reference.html
reservedWords = new HashSet<String>(Arrays.asList( reservedWords = new HashSet<>(Arrays.asList(
"abstract", "abstract",
"actual", "actual",
"annotation", "annotation",
@ -171,7 +171,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
"while" "while"
)); ));
defaultIncludes = new HashSet<String>(Arrays.asList( defaultIncludes = new HashSet<>(Arrays.asList(
"kotlin.Byte", "kotlin.Byte",
"kotlin.ByteArray", "kotlin.ByteArray",
"kotlin.Short", "kotlin.Short",
@ -187,7 +187,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
"kotlin.collections.Map" "kotlin.collections.Map"
)); ));
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("string", "kotlin.String"); typeMapping.put("string", "kotlin.String");
typeMapping.put("boolean", "kotlin.Boolean"); typeMapping.put("boolean", "kotlin.Boolean");
typeMapping.put("integer", "kotlin.Int"); typeMapping.put("integer", "kotlin.Int");
@ -214,7 +214,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
instantiationTypes.put("list", "kotlin.collections.ArrayList"); instantiationTypes.put("list", "kotlin.collections.ArrayList");
instantiationTypes.put("map", "kotlin.collections.HashMap"); instantiationTypes.put("map", "kotlin.collections.HashMap");
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
importMapping.put("BigDecimal", "java.math.BigDecimal"); importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID"); importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI"); importMapping.put("URI", "java.net.URI");
@ -896,7 +896,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
} }
// If name contains special chars -> replace them. // If name contains special chars -> replace them.
if ((name.chars().anyMatch(character -> specialCharReplacements.keySet().contains("" + ((char) character))))) { if ((name.chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character))))) {
List<String> allowedCharacters = new ArrayList<>(); List<String> allowedCharacters = new ArrayList<>();
allowedCharacters.add("_"); allowedCharacters.add("_");
allowedCharacters.add("$"); allowedCharacters.add("$");
@ -941,7 +941,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// only process files with kt extension // only process files with kt extension
if ("kt".equals(FilenameUtils.getExtension(file.toString()))) { if ("kt".equals(FilenameUtils.getExtension(file.toString()))) {
String command = kotlinPostProcessFile + " " + file.toString(); String command = kotlinPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
p.waitFor(); p.waitFor();

View File

@ -79,7 +79,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
); );
// ref: http://php.net/manual/en/language.types.intro.php // ref: http://php.net/manual/en/language.types.intro.php
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"boolean", "boolean",
@ -107,7 +107,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
additionalProperties.put("primitives", primitives); additionalProperties.put("primitives", primitives);
// ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types // ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("integer", "int"); typeMapping.put("integer", "int");
typeMapping.put("long", "int"); typeMapping.put("long", "int");
typeMapping.put("number", "float"); typeMapping.put("number", "float");
@ -769,7 +769,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
} }
// only process files with php extension // only process files with php extension
if ("php".equals(FilenameUtils.getExtension(file.toString()))) { if ("php".equals(FilenameUtils.getExtension(file.toString()))) {
String command = phpPostProcessFile + " " + file.toString(); String command = phpPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
p.waitFor(); p.waitFor();

View File

@ -270,7 +270,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
// only process files with py extension // only process files with py extension
if ("py".equals(FilenameUtils.getExtension(file.toString()))) { if ("py".equals(FilenameUtils.getExtension(file.toString()))) {
String command = pythonPostProcessFile + " " + file.toString(); String command = pythonPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -238,7 +238,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
} }
// only process files with rb extension // only process files with rb extension
if ("rb".equals(FilenameUtils.getExtension(file.toString()))) { if ("rb".equals(FilenameUtils.getExtension(file.toString()))) {
String command = rubyPostProcessFile + " " + file.toString(); String command = rubyPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();
@ -250,7 +250,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
sb.append(line); sb.append(line);
} }
LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb.toString()); LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb);
} }
} else { } else {
LOGGER.info("Successfully executed: `{}`", command); LOGGER.info("Successfully executed: `{}`", command);

View File

@ -529,7 +529,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
// only process files with scala extension // only process files with scala extension
if ("scala".equals(FilenameUtils.getExtension(file.toString()))) { if ("scala".equals(FilenameUtils.getExtension(file.toString()))) {
String command = scalaPostProcessFile + " " + file.toString(); String command = scalaPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -181,7 +181,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
" Required to generate a full package")); " Required to generate a full package"));
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package. If not provided, using the version from the OpenAPI specification file.").defaultValue(this.getNpmVersion())); this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package. If not provided, using the version from the OpenAPI specification file.").defaultValue(this.getNpmVersion()));
this.cliOptions.add(CliOption.newBoolean(SNAPSHOT, this.cliOptions.add(CliOption.newBoolean(SNAPSHOT,
"When setting this property to true, the version will be suffixed with -SNAPSHOT." + this.SNAPSHOT_SUFFIX_FORMAT.get().toPattern(), "When setting this property to true, the version will be suffixed with -SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.get().toPattern(),
false)); false));
this.cliOptions.add(new CliOption(NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_DESC).defaultValue(String.valueOf(this.getNullSafeAdditionalProps()))); this.cliOptions.add(new CliOption(NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_DESC).defaultValue(String.valueOf(this.getNullSafeAdditionalProps())));
} }
@ -896,7 +896,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
} }
// only process files with ts extension // only process files with ts extension
if ("ts".equals(FilenameUtils.getExtension(file.toString()))) { if ("ts".equals(FilenameUtils.getExtension(file.toString()))) {
String command = tsPostProcessFile + " " + file.toString(); String command = tsPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -117,7 +117,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
"native", "super", "while", "null") "native", "super", "while", "null")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"String", "String",
"boolean", "boolean",

View File

@ -49,7 +49,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
private String namedCredential; private String namedCredential;
private String srcPath = "force-app/main/default/"; private String srcPath = "force-app/main/default/";
private String sfdxConfigPath = "config/"; private String sfdxConfigPath = "config/";
private HashMap<String, Object> primitiveDefaults = new HashMap<String, Object>(); private HashMap<String, Object> primitiveDefaults = new HashMap<>();
public ApexClientCodegen() { public ApexClientCodegen() {
super(); super();
@ -113,7 +113,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
"virtual", "void", "webservice", "when", "where", "while" "virtual", "void", "webservice", "when", "where", "while"
)); ));
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList("Blob", "Boolean", "Date", "Datetime", "Decimal", "Double", "ID", Arrays.asList("Blob", "Boolean", "Date", "Datetime", "Decimal", "Double", "ID",
"Integer", "Long", "Object", "String", "Time" "Integer", "Long", "Object", "String", "Time"
)); ));
@ -233,7 +233,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
out = String.valueOf(p.getDefault()); out = String.valueOf(p.getDefault());
} else if (ModelUtils.isLongSchema(p)) { } else if (ModelUtils.isLongSchema(p)) {
Long def = (Long) p.getDefault(); Long def = (Long) p.getDefault();
out = def == null ? out : def.toString() + "L"; out = def == null ? out : def + "L";
} else if (ModelUtils.isMapSchema(p)) { } else if (ModelUtils.isMapSchema(p)) {
Schema inner = getAdditionalProperties(p); Schema inner = getAdditionalProperties(p);
String s = inner == null ? "Object" : getTypeDeclaration(inner); String s = inner == null ? "Object" : getTypeDeclaration(inner);

View File

@ -89,10 +89,10 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
String includeStatement = "include::{" + attributePathReference + "}" + escapeCurlyBrackets(relativeFileName) + "[opts=optional]"; String includeStatement = "include::{" + attributePathReference + "}" + escapeCurlyBrackets(relativeFileName) + "[opts=optional]";
if (Files.isRegularFile(filePathToInclude)) { if (Files.isRegularFile(filePathToInclude)) {
LOGGER.debug("including {}. file into markup from: {}", ++includeCount, filePathToInclude.toString()); LOGGER.debug("including {}. file into markup from: {}", ++includeCount, filePathToInclude);
out.write("\n" + includeStatement + "\n"); out.write("\n" + includeStatement + "\n");
} else { } else {
LOGGER.debug("{}. file not found, skip include for: {}", ++notFoundCount, filePathToInclude.toString()); LOGGER.debug("{}. file not found, skip include for: {}", ++notFoundCount, filePathToInclude);
out.write("\n// markup not found, no " + includeStatement + "\n"); out.write("\n// markup not found, no " + includeStatement + "\n");
} }
} }
@ -140,10 +140,10 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
final Path filePathToLinkTo = Paths.get(basePath, relativeFileName).toAbsolutePath(); final Path filePathToLinkTo = Paths.get(basePath, relativeFileName).toAbsolutePath();
if (Files.isRegularFile(filePathToLinkTo)) { if (Files.isRegularFile(filePathToLinkTo)) {
LOGGER.debug("linking {}. file into markup from: {}", ++linkedCount, filePathToLinkTo.toString()); LOGGER.debug("linking {}. file into markup from: {}", ++linkedCount, filePathToLinkTo);
out.write("\n" + linkName + " link:" + relativeFileName + "[]\n"); out.write("\n" + linkName + " link:" + relativeFileName + "[]\n");
} else { } else {
LOGGER.debug("{}. file not found, skip link for: {}", ++notFoundLinkCount, filePathToLinkTo.toString()); LOGGER.debug("{}. file not found, skip link for: {}", ++notFoundLinkCount, filePathToLinkTo);
out.write("\n// file not found, no " + linkName + " link :" + relativeFileName + "[]\n"); out.write("\n// file not found, no " + linkName + " link :" + relativeFileName + "[]\n");
} }
} }
@ -217,7 +217,7 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
outputFolder = "generated-code" + File.separator + "asciidoc"; outputFolder = "generated-code" + File.separator + "asciidoc";
embeddedTemplateDir = templateDir = "asciidoc-documentation"; embeddedTemplateDir = templateDir = "asciidoc-documentation";
defaultIncludes = new HashSet<String>(); defaultIncludes = new HashSet<>();
cliOptions.add(new CliOption("appName", "short name of the application")); cliOptions.add(new CliOption("appName", "short name of the application"));
cliOptions.add(new CliOption("appDescription", "description of the application")); cliOptions.add(new CliOption("appDescription", "description of the application"));
@ -264,10 +264,10 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
supportingFiles.add(new SupportingFile("index.mustache", "", "index.adoc")); supportingFiles.add(new SupportingFile("index.mustache", "", "index.adoc"));
reservedWords = new HashSet<String>(); reservedWords = new HashSet<>();
languageSpecificPrimitives = new HashSet<String>(); languageSpecificPrimitives = new HashSet<>();
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
} }
@ -325,7 +325,7 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
public void processOpts() { public void processOpts() {
super.processOpts(); super.processOpts();
String specDir = this.additionalProperties.get(SPEC_DIR) + ""; String specDir = String.valueOf(this.additionalProperties.get(SPEC_DIR));
if (!Files.isDirectory(Paths.get(specDir))) { if (!Files.isDirectory(Paths.get(specDir))) {
LOGGER.warn("base part for include markup lambda not found: {} as {}", specDir, Paths.get(specDir).toAbsolutePath()); LOGGER.warn("base part for include markup lambda not found: {} as {}", specDir, Paths.get(specDir).toAbsolutePath());
} }
@ -333,7 +333,7 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
this.includeSpecMarkupLambda = new IncludeMarkupLambda(SPEC_DIR,specDir); this.includeSpecMarkupLambda = new IncludeMarkupLambda(SPEC_DIR,specDir);
additionalProperties.put("specinclude", this.includeSpecMarkupLambda); additionalProperties.put("specinclude", this.includeSpecMarkupLambda);
String snippetDir = this.additionalProperties.get(SNIPPET_DIR) + ""; String snippetDir = String.valueOf(this.additionalProperties.get(SNIPPET_DIR));
if (!Files.isDirectory(Paths.get(snippetDir))) { if (!Files.isDirectory(Paths.get(snippetDir))) {
LOGGER.warn("base part for include markup lambda not found: {} as {}", snippetDir, Paths.get(snippetDir).toAbsolutePath()); LOGGER.warn("base part for include markup lambda not found: {} as {}", snippetDir, Paths.get(snippetDir).toAbsolutePath());
} }

View File

@ -444,7 +444,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
} }
// Converts, for example, PUT to HttpPut for controller attributes // Converts, for example, PUT to HttpPut for controller attributes
operation.httpMethod = "Http" + operation.httpMethod.substring(0, 1) + operation.httpMethod.substring(1).toLowerCase(Locale.ROOT); operation.httpMethod = "Http" + operation.httpMethod.charAt(0) + operation.httpMethod.substring(1).toLowerCase(Locale.ROOT);
} }
@Override @Override
@ -472,7 +472,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
continue; continue;
} }
if(consumesString.toString().equals("")) { if(consumesString.toString().isEmpty()) {
consumesString = new StringBuilder("\"" + consume.get("mediaType") + "\""); consumesString = new StringBuilder("\"" + consume.get("mediaType") + "\"");
} }
else { else {
@ -500,7 +500,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
} }
} }
if(!consumesString.toString().equals("")) { if(!consumesString.toString().isEmpty()) {
operation.vendorExtensions.put("x-aspnetcore-consumes", consumesString.toString()); operation.vendorExtensions.put("x-aspnetcore-consumes", consumesString.toString());
} }
} }

View File

@ -209,7 +209,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
/** /**
* Bash reserved words. * Bash reserved words.
*/ */
reservedWords = new HashSet<String>( reservedWords = new HashSet<>(
Arrays.asList( Arrays.asList(
"case", "case",
"do", "do",

View File

@ -874,7 +874,7 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
} }
// only process the following type (or we can simply rely on the file extension to check if it's a .c or .h file) // only process the following type (or we can simply rely on the file extension to check if it's a .c or .h file)
Set<String> supportedFileType = new HashSet<String>( Set<String> supportedFileType = new HashSet<>(
Arrays.asList( Arrays.asList(
"supporting-mustache", "supporting-mustache",
"model-test", "model-test",
@ -888,7 +888,7 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
// only process files with .c or .h extension // only process files with .c or .h extension
if ("c".equals(FilenameUtils.getExtension(file.toString())) || if ("c".equals(FilenameUtils.getExtension(file.toString())) ||
"h".equals(FilenameUtils.getExtension(file.toString()))) { "h".equals(FilenameUtils.getExtension(file.toString()))) {
String command = cPostProcessFile + " " + file.toString(); String command = cPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -35,7 +35,7 @@ import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;
public class CSharpClientCodegen extends AbstractCSharpCodegen { public class CSharpClientCodegen extends AbstractCSharpCodegen {
@SuppressWarnings({"hiding"}) @SuppressWarnings("hiding")
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class); private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
private static final String NUNIT = "nunit"; private static final String NUNIT = "nunit";
private static final String RESTSHARP = "restsharp"; private static final String RESTSHARP = "restsharp";

View File

@ -56,7 +56,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
// Project Variable, determined from target framework. Not intended to be user-settable. // Project Variable, determined from target framework. Not intended to be user-settable.
protected static final String TARGET_FRAMEWORK_VERSION = "targetFrameworkVersion"; protected static final String TARGET_FRAMEWORK_VERSION = "targetFrameworkVersion";
@SuppressWarnings({"hiding"}) @SuppressWarnings("hiding")
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class); private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
private static final List<FrameworkStrategy> frameworkStrategies = Arrays.asList( private static final List<FrameworkStrategy> frameworkStrategies = Arrays.asList(
FrameworkStrategy.NETSTANDARD_1_3, FrameworkStrategy.NETSTANDARD_1_3,

View File

@ -55,7 +55,7 @@ public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConf
outputFolder = "docs"; outputFolder = "docs";
embeddedTemplateDir = templateDir = "confluenceWikiDocs"; embeddedTemplateDir = templateDir = "confluenceWikiDocs";
defaultIncludes = new HashSet<String>(); defaultIncludes = new HashSet<>();
cliOptions.add(new CliOption("appName", "short name of the application")); cliOptions.add(new CliOption("appName", "short name of the application"));
cliOptions.add(new CliOption("appDescription", "description of the application")); cliOptions.add(new CliOption("appDescription", "description of the application"));
@ -80,10 +80,10 @@ public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConf
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
supportingFiles.add(new SupportingFile("index.mustache", "", "confluence-markup.txt")); supportingFiles.add(new SupportingFile("index.mustache", "", "confluence-markup.txt"));
reservedWords = new HashSet<String>(); reservedWords = new HashSet<>();
languageSpecificPrimitives = new HashSet<String>(); languageSpecificPrimitives = new HashSet<>();
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
} }
@Override @Override

View File

@ -116,10 +116,10 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
supportingFiles.add(new SupportingFile("cmake.mustache", "", "CMakeLists.txt")); supportingFiles.add(new SupportingFile("cmake.mustache", "", "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t")); Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t"));
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("date", "std::string"); typeMapping.put("date", "std::string");
typeMapping.put("DateTime", "std::string"); typeMapping.put("DateTime", "std::string");
typeMapping.put("string", "std::string"); typeMapping.put("string", "std::string");
@ -137,7 +137,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
typeMapping.put("URI", "std::string"); typeMapping.put("URI", "std::string");
typeMapping.put("ByteArray", "std::string"); typeMapping.put("ByteArray", "std::string");
super.importMapping = new HashMap<String, String>(); super.importMapping = new HashMap<>();
importMapping.put("std::vector", "#include <vector>"); importMapping.put("std::vector", "#include <vector>");
importMapping.put("std::map", "#include <map>"); importMapping.put("std::map", "#include <map>");
importMapping.put("std::string", "#include <string>"); importMapping.put("std::string", "#include <string>");

View File

@ -22,13 +22,13 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
protected static final String CPP_NAMESPACE_DESC = "C++ namespace (convention: name::space::for::api)."; protected static final String CPP_NAMESPACE_DESC = "C++ namespace (convention: name::space::for::api).";
protected static final String CONTENT_COMPRESSION_ENABLED = "contentCompression"; protected static final String CONTENT_COMPRESSION_ENABLED = "contentCompression";
protected static final String CONTENT_COMPRESSION_ENABLED_DESC = "Enable Compressed Content Encoding for requests and responses"; protected static final String CONTENT_COMPRESSION_ENABLED_DESC = "Enable Compressed Content Encoding for requests and responses";
protected Set<String> foundationClasses = new HashSet<String>(); protected Set<String> foundationClasses = new HashSet<>();
protected String cppNamespace = "OpenAPI"; protected String cppNamespace = "OpenAPI";
protected Map<String, String> namespaces = new HashMap<String, String>(); protected Map<String, String> namespaces = new HashMap<>();
protected Set<String> systemIncludes = new HashSet<String>(); protected Set<String> systemIncludes = new HashSet<>();
protected boolean isContentCompressionEnabled = false; protected boolean isContentCompressionEnabled = false;
protected Set<String> nonFrameworkPrimitives = new HashSet<String>(); protected Set<String> nonFrameworkPrimitives = new HashSet<>();
public CppQtAbstractCodegen() { public CppQtAbstractCodegen() {
super(); super();
@ -75,7 +75,7 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
* Language Specific Primitives. These types will not trigger imports by * Language Specific Primitives. These types will not trigger imports by
* the client generator * the client generator
*/ */
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"qint32", "qint32",
@ -93,7 +93,7 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
"QByteArray") "QByteArray")
); );
languageSpecificPrimitives.addAll(foundationClasses); languageSpecificPrimitives.addAll(foundationClasses);
super.typeMapping = new HashMap<String, String>(); super.typeMapping = new HashMap<>();
typeMapping.put("date", "QDate"); typeMapping.put("date", "QDate");
typeMapping.put("DateTime", "QDateTime"); typeMapping.put("DateTime", "QDateTime");
@ -116,8 +116,8 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
typeMapping.put("URI", "QString"); typeMapping.put("URI", "QString");
typeMapping.put("file", "QByteArray"); typeMapping.put("file", "QByteArray");
typeMapping.put("binary", "QByteArray"); typeMapping.put("binary", "QByteArray");
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
namespaces = new HashMap<String, String>(); namespaces = new HashMap<>();
systemIncludes.add("QString"); systemIncludes.add("QString");
systemIncludes.add("QList"); systemIncludes.add("QList");
@ -315,7 +315,7 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation"); List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports"); List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
Map<String, CodegenModel> codegenModels = new HashMap<String, CodegenModel>(); Map<String, CodegenModel> codegenModels = new HashMap<>();
for (Object moObj : allModels) { for (Object moObj : allModels) {
CodegenModel mo = ((Map<String, CodegenModel>) moObj).get("model"); CodegenModel mo = ((Map<String, CodegenModel>) moObj).get("model");
@ -336,7 +336,7 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
imports.add(createMapping("import", operation.returnBaseType)); imports.add(createMapping("import", operation.returnBaseType));
} }
} }
List<CodegenParameter> params = new ArrayList<CodegenParameter>(); List<CodegenParameter> params = new ArrayList<>();
if (operation.allParams != null) params.addAll(operation.allParams); if (operation.allParams != null) params.addAll(operation.allParams);
// Check all parameter baseType if there is a necessity to include, include it if not // Check all parameter baseType if there is a necessity to include, include it if not
@ -375,7 +375,7 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
} }
private Map<String, String> createMapping(String key, String value) { private Map<String, String> createMapping(String key, String value) {
Map<String, String> customImport = new HashMap<String, String>(); Map<String, String> customImport = new HashMap<>();
customImport.put(key, toModelImport(value)); customImport.put(key, toModelImport(value));
return customImport; return customImport;
} }

View File

@ -166,10 +166,10 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
supportingFiles.add(new SupportingFile("cmake-config.mustache", "", "Config.cmake.in")); supportingFiles.add(new SupportingFile("cmake-config.mustache", "", "Config.cmake.in"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t")); Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t"));
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("date", "utility::datetime"); typeMapping.put("date", "utility::datetime");
typeMapping.put("DateTime", "utility::datetime"); typeMapping.put("DateTime", "utility::datetime");
typeMapping.put("string", "utility::string_t"); typeMapping.put("string", "utility::string_t");
@ -186,7 +186,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
typeMapping.put("URI", "utility::string_t"); typeMapping.put("URI", "utility::string_t");
typeMapping.put("ByteArray", "utility::string_t"); typeMapping.put("ByteArray", "utility::string_t");
super.importMapping = new HashMap<String, String>(); super.importMapping = new HashMap<>();
importMapping.put("std::vector", "#include <vector>"); importMapping.put("std::vector", "#include <vector>");
importMapping.put("std::map", "#include <map>"); importMapping.put("std::map", "#include <map>");
importMapping.put("std::string", "#include <string>"); importMapping.put("std::string", "#include <string>");
@ -263,7 +263,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
CodegenModel codegenModel = super.fromModel(name, model); CodegenModel codegenModel = super.fromModel(name, model);
Set<String> oldImports = codegenModel.imports; Set<String> oldImports = codegenModel.imports;
codegenModel.imports = new HashSet<String>(); codegenModel.imports = new HashSet<>();
for (String imp : oldImports) { for (String imp : oldImports) {
String newImp = toModelImport(imp); String newImp = toModelImport(imp);
if (!newImp.isEmpty()) { if (!newImp.isEmpty()) {

View File

@ -93,10 +93,10 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t")); Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t"));
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("date", "std::string"); typeMapping.put("date", "std::string");
typeMapping.put("DateTime", "std::string"); typeMapping.put("DateTime", "std::string");
typeMapping.put("string", "std::string"); typeMapping.put("string", "std::string");
@ -113,7 +113,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
typeMapping.put("URI", "std::string"); typeMapping.put("URI", "std::string");
typeMapping.put("ByteArray", "std::string"); typeMapping.put("ByteArray", "std::string");
super.importMapping = new HashMap<String, String>(); super.importMapping = new HashMap<>();
importMapping.put("std::vector", "#include <vector>"); importMapping.put("std::vector", "#include <vector>");
importMapping.put("std::map", "#include <map>"); importMapping.put("std::map", "#include <map>");
importMapping.put("std::string", "#include <string>"); importMapping.put("std::string", "#include <string>");
@ -129,7 +129,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
// Clean interfaces of ambiguity // Clean interfaces of ambiguity
for (Entry<String, CodegenModel> cm : allModels.entrySet()) { for (Entry<String, CodegenModel> cm : allModels.entrySet()) {
if (cm.getValue().getInterfaces() != null && !cm.getValue().getInterfaces().isEmpty()) { if (cm.getValue().getInterfaces() != null && !cm.getValue().getInterfaces().isEmpty()) {
List<String> newIntf = new ArrayList<String>(cm.getValue().getInterfaces()); List<String> newIntf = new ArrayList<>(cm.getValue().getInterfaces());
for (String intf : allModels.get(cm.getKey()).getInterfaces()) { for (String intf : allModels.get(cm.getKey()).getInterfaces()) {
if (allModels.get(intf).getInterfaces() != null && !allModels.get(intf).getInterfaces().isEmpty()) { if (allModels.get(intf).getInterfaces() != null && !allModels.get(intf).getInterfaces().isEmpty()) {
@ -256,7 +256,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
CodegenModel codegenModel = super.fromModel(name, model); CodegenModel codegenModel = super.fromModel(name, model);
Set<String> oldImports = codegenModel.imports; Set<String> oldImports = codegenModel.imports;
codegenModel.imports = new HashSet<String>(); codegenModel.imports = new HashSet<>();
for (String imp : oldImports) { for (String imp : oldImports) {
String newImp = toModelImport(imp); String newImp = toModelImport(imp);
if (!newImp.isEmpty()) { if (!newImp.isEmpty()) {
@ -285,7 +285,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) { public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations"); Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation"); List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>(); List<CodegenOperation> newOpList = new ArrayList<>();
for (CodegenOperation op : operationList) { for (CodegenOperation op : operationList) {
String path = op.path; String path = op.path;
@ -318,7 +318,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
final String X_CODEGEN_OTHER_METHODS = "x-codegen-other-methods"; final String X_CODEGEN_OTHER_METHODS = "x-codegen-other-methods";
List<CodegenOperation> currentOtherMethodList = (List<CodegenOperation>) op1.vendorExtensions.get(X_CODEGEN_OTHER_METHODS); List<CodegenOperation> currentOtherMethodList = (List<CodegenOperation>) op1.vendorExtensions.get(X_CODEGEN_OTHER_METHODS);
if (currentOtherMethodList == null) { if (currentOtherMethodList == null) {
currentOtherMethodList = new ArrayList<CodegenOperation>(); currentOtherMethodList = new ArrayList<>();
} }
op.operationIdCamelCase = op1.operationIdCamelCase; op.operationIdCamelCase = op1.operationIdCamelCase;
currentOtherMethodList.add(op); currentOtherMethodList.add(op);

View File

@ -71,7 +71,7 @@ public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenC
} }
public void addControllerToAdditionalProperties() { public void addControllerToAdditionalProperties() {
Map<String, String> supportedControllers = new HashMap<String, String>(); Map<String, String> supportedControllers = new HashMap<>();
supportedControllers.put("esp32", "isESP32"); supportedControllers.put("esp32", "isESP32");
supportedControllers.put("esp8266", "isESP8266"); supportedControllers.put("esp8266", "isESP8266");
if (supportedControllers.containsKey(controller)) { if (supportedControllers.containsKey(controller)) {
@ -164,7 +164,7 @@ public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenC
supportingFiles.add(new SupportingFile("root.cert.mustache", rootFolder, "root.cert")); // TODO no overwrite supportingFiles.add(new SupportingFile("root.cert.mustache", rootFolder, "root.cert")); // TODO no overwrite
supportingFiles.add(new SupportingFile("pre_compiling_bourne.py.mustache", rootFolder, "pre_compiling_bourne.py")); supportingFiles.add(new SupportingFile("pre_compiling_bourne.py.mustache", rootFolder, "pre_compiling_bourne.py"));
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"int", "int",
@ -172,7 +172,7 @@ public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenC
"double", "double",
"float") "float")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"int", "int",
@ -182,7 +182,7 @@ public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenC
"std::string") "std::string")
); );
super.typeMapping = new HashMap<String, String>(); super.typeMapping = new HashMap<>();
typeMapping.put("string", "std::string"); typeMapping.put("string", "std::string");
typeMapping.put("integer", "int"); typeMapping.put("integer", "int");
typeMapping.put("boolean", "bool"); typeMapping.put("boolean", "bool");
@ -257,7 +257,7 @@ public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenC
if (languageSpecificPrimitives.contains(openAPIType)) { if (languageSpecificPrimitives.contains(openAPIType)) {
return toModelName(openAPIType); return toModelName(openAPIType);
} else { } else {
return openAPIType + ""; return openAPIType;
} }
} }
@ -314,7 +314,7 @@ public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenC
if (isReservedWord(paramName)) { if (isReservedWord(paramName)) {
return escapeReservedWord(paramName); return escapeReservedWord(paramName);
} }
return "" + paramName; return paramName;
} }
@Override @Override

View File

@ -71,7 +71,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
embeddedTemplateDir = templateDir = "cpp-tizen-client"; embeddedTemplateDir = templateDir = "cpp-tizen-client";
modelPackage = ""; modelPackage = "";
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"int", "int",
@ -79,7 +79,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
"double", "double",
"float") "float")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"int", "int",
@ -105,7 +105,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
"unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"
)); ));
super.typeMapping = new HashMap<String, String>(); super.typeMapping = new HashMap<>();
//typeMapping.put("Date", "DateTime"); //typeMapping.put("Date", "DateTime");
//typeMapping.put("DateTime", "DateTime"); //typeMapping.put("DateTime", "DateTime");
@ -128,7 +128,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
typeMapping.put("UUID", "std::string"); typeMapping.put("UUID", "std::string");
typeMapping.put("URI", "std::string"); typeMapping.put("URI", "std::string");
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
supportingFiles.clear(); supportingFiles.clear();
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, "Helpers.h")); supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, "Helpers.h"));
@ -175,7 +175,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
if (languageSpecificPrimitives.contains(name)) { if (languageSpecificPrimitives.contains(name)) {
return name; return name;
} else { } else {
return name + ""; return name;
} }
} }
@ -200,7 +200,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
if (languageSpecificPrimitives.contains(openAPIType)) { if (languageSpecificPrimitives.contains(openAPIType)) {
return toModelName(openAPIType); return toModelName(openAPIType);
} else { } else {
return openAPIType + ""; return openAPIType;
} }
} }
@ -295,7 +295,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
if (isReservedWord(paramName)) { if (isReservedWord(paramName)) {
return escapeReservedWord(paramName); return escapeReservedWord(paramName);
} }
return "" + paramName; return paramName;
} }
@Override @Override

View File

@ -39,14 +39,14 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
protected String unrealModuleName = "OpenAPI"; protected String unrealModuleName = "OpenAPI";
// Will be treated as pointer // Will be treated as pointer
protected Set<String> pointerClasses = new HashSet<String>(); protected Set<String> pointerClasses = new HashSet<>();
// source folder where to write the files // source folder where to write the files
protected String privateFolder = "Private"; protected String privateFolder = "Private";
protected String publicFolder = "Public"; protected String publicFolder = "Public";
protected String apiVersion = "1.0.0"; protected String apiVersion = "1.0.0";
protected Map<String, String> namespaces = new HashMap<String, String>(); protected Map<String, String> namespaces = new HashMap<>();
// Will be included using the <> syntax, not used in Unreal's coding convention // Will be included using the <> syntax, not used in Unreal's coding convention
protected Set<String> systemIncludes = new HashSet<String>(); protected Set<String> systemIncludes = new HashSet<>();
protected String cppNamespace = unrealModuleName; protected String cppNamespace = unrealModuleName;
protected boolean optionalProjectFileFlag = true; protected boolean optionalProjectFileFlag = true;
@ -132,7 +132,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
* Language Specific Primitives. These types will not trigger imports by * Language Specific Primitives. These types will not trigger imports by
* the client generator * the client generator
*/ */
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"int32", "int32",
@ -159,7 +159,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
supportingFiles.add(new SupportingFile("module-source.mustache", privateFolder, unrealModuleName + "Module.cpp")); supportingFiles.add(new SupportingFile("module-source.mustache", privateFolder, unrealModuleName + "Module.cpp"));
} }
super.typeMapping = new HashMap<String, String>(); super.typeMapping = new HashMap<>();
// Maps C++ types during call to getSchemaType, see DefaultCodegen.getSchemaType and not the types/formats // Maps C++ types during call to getSchemaType, see DefaultCodegen.getSchemaType and not the types/formats
// defined in openapi specification "array" is also used explicitly in the generator for containers // defined in openapi specification "array" is also used explicitly in the generator for containers
@ -188,10 +188,10 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
typeMapping.put("UUID", "FGuid"); typeMapping.put("UUID", "FGuid");
typeMapping.put("AnyType", "TSharedPtr<FJsonValue>"); typeMapping.put("AnyType", "TSharedPtr<FJsonValue>");
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
importMapping.put("HttpFileInput", "#include \"" + modelNamePrefix + "Helpers.h\""); importMapping.put("HttpFileInput", "#include \"" + modelNamePrefix + "Helpers.h\"");
namespaces = new HashMap<String, String>(); namespaces = new HashMap<>();
} }
@Override @Override

View File

@ -130,7 +130,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
hideGenerationTimestamp = Boolean.TRUE; hideGenerationTimestamp = Boolean.TRUE;
// reserved word. Ref: https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists#available-keywords // reserved word. Ref: https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists#available-keywords
reservedWords = new HashSet<String>( reservedWords = new HashSet<>(
Arrays.asList( Arrays.asList(
"abstract", "do", "if", "nil?", "select", "union", "abstract", "do", "if", "nil?", "select", "union",
"alias", "else", "in", "of", "self", "unless", "alias", "else", "in", "of", "self", "unless",
@ -557,8 +557,8 @@ public class CrystalClientCodegen extends DefaultCodegen {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) { public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
objs = super.postProcessOperationsWithModels(objs, allModels); objs = super.postProcessOperationsWithModels(objs, allModels);
Map<String, Object> operations = (Map<String, Object>) objs.get("operations"); Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>(); HashMap<String, CodegenModel> modelMaps = new HashMap<>();
HashMap<String, Integer> processedModelMaps = new HashMap<String, Integer>(); HashMap<String, Integer> processedModelMaps = new HashMap<>();
for (Object o : allModels) { for (Object o : allModels) {
HashMap<String, Object> h = (HashMap<String, Object>) o; HashMap<String, Object> h = (HashMap<String, Object>) o;
@ -870,7 +870,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
} }
// only process files with cr extension // only process files with cr extension
if ("cr".equals(FilenameUtils.getExtension(file.toString()))) { if ("cr".equals(FilenameUtils.getExtension(file.toString()))) {
String command = crystalPostProcessFile + " " + file.toString(); String command = crystalPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();
@ -882,7 +882,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
sb.append(line); sb.append(line);
} }
LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb.toString()); LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb);
} }
} else { } else {
LOGGER.info("Successfully executed: {}", command); LOGGER.info("Successfully executed: {}", command);

View File

@ -116,7 +116,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
* Reserved words. Override this with reserved words specific to your language * Reserved words. Override this with reserved words specific to your language
* Ref: https://github.com/itsgreggreg/elixir_quick_reference#reserved-words * Ref: https://github.com/itsgreggreg/elixir_quick_reference#reserved-words
*/ */
reservedWords = new HashSet<String>( reservedWords = new HashSet<>(
Arrays.asList( Arrays.asList(
"nil", "nil",
"true", "true",
@ -164,7 +164,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
* Language Specific Primitives. These types will not trigger imports by * Language Specific Primitives. These types will not trigger imports by
* the client generator * the client generator
*/ */
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"Integer", "Integer",
"Float", "Float",
@ -182,7 +182,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
); );
// ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types // ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("integer", "Integer"); typeMapping.put("integer", "Integer");
typeMapping.put("long", "Integer"); typeMapping.put("long", "Integer");
typeMapping.put("number", "Float"); typeMapping.put("number", "Float");
@ -727,10 +727,10 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
} }
sb.append("keyword()) :: "); sb.append("keyword()) :: ");
HashSet<String> uniqueResponseTypes = new HashSet<String>(); HashSet<String> uniqueResponseTypes = new HashSet<>();
for (CodegenResponse response : this.responses) { for (CodegenResponse response : this.responses) {
ExtendedCodegenResponse exResponse = (ExtendedCodegenResponse) response; ExtendedCodegenResponse exResponse = (ExtendedCodegenResponse) response;
StringBuilder returnEntry = new StringBuilder(""); StringBuilder returnEntry = new StringBuilder();
if (exResponse.baseType == null) { if (exResponse.baseType == null) {
returnEntry.append("nil"); returnEntry.append("nil");
} else if (exResponse.simpleType) { } else if (exResponse.simpleType) {

View File

@ -328,19 +328,17 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
private boolean anyVarMatches(final List<Map<String, Object>> models, final Predicate<CodegenProperty> predicate) { private boolean anyVarMatches(final List<Map<String, Object>> models, final Predicate<CodegenProperty> predicate) {
return models.stream() return models.stream()
.map(obj -> (CodegenModel) obj.get("model")) .map(obj -> (CodegenModel) obj.get("model"))
.flatMap(model -> model.vars.stream()) .flatMap(model -> model.vars.stream()).anyMatch(var -> {
.filter(var -> { CodegenProperty prop = var;
CodegenProperty prop = var; while (prop != null) {
while (prop != null) { if (predicate.test(prop)) {
if (predicate.test(prop)) { return true;
return true; }
prop = prop.items;
} }
prop = prop.items; return false;
} });
return false;
})
.count() > 0;
} }
@Override @Override

View File

@ -267,7 +267,7 @@ public class FsharpGiraffeServerCodegen extends AbstractFSharpCodegen {
} }
// Converts, for example, PUT to HttpPut for controller attributes // Converts, for example, PUT to HttpPut for controller attributes
operation.httpMethod = "Http" + operation.httpMethod.substring(0, 1) + operation.httpMethod.substring(1).toLowerCase(Locale.ROOT); operation.httpMethod = "Http" + operation.httpMethod.charAt(0) + operation.httpMethod.substring(1).toLowerCase(Locale.ROOT);
} }
@Override @Override

View File

@ -136,8 +136,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
protected Map<String, Map<String, Object>> uniqueParamNameTypes = new HashMap<>(); protected Map<String, Map<String, Object>> uniqueParamNameTypes = new HashMap<>();
protected Map<String, Set<String>> modelMimeTypes = new HashMap<>(); protected Map<String, Set<String>> modelMimeTypes = new HashMap<>();
protected Map<String, String> knownMimeDataTypes = new HashMap<>(); protected Map<String, String> knownMimeDataTypes = new HashMap<>();
protected Set<String> typeNames = new HashSet<String>(); protected Set<String> typeNames = new HashSet<>();
protected Set<String> modelTypeNames = new HashSet<String>(); protected Set<String> modelTypeNames = new HashSet<>();
final private static Pattern CONTAINS_JSON_MIME_PATTERN = Pattern.compile("(?i)application/.*json(;.*)?"); final private static Pattern CONTAINS_JSON_MIME_PATTERN = Pattern.compile("(?i)application/.*json(;.*)?");
@ -235,7 +235,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
supportingFiles.add(new SupportingFile("tests/PropMime.mustache", "tests", "PropMime.hs")); supportingFiles.add(new SupportingFile("tests/PropMime.mustache", "tests", "PropMime.hs"));
supportingFiles.add(new SupportingFile("tests/Test.mustache", "tests", "Test.hs")); supportingFiles.add(new SupportingFile("tests/Test.mustache", "tests", "Test.hs"));
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"Bool", "Bool",
"String", "String",
@ -555,7 +555,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
} }
if (!additionalProperties.containsKey(PROP_BASE_MODULE)) { if (!additionalProperties.containsKey(PROP_BASE_MODULE)) {
List<String> wordsCaps = new ArrayList<String>(); List<String> wordsCaps = new ArrayList<>();
for (String word : baseTitle.split(" ")) { for (String word : baseTitle.split(" ")) {
wordsCaps.add(firstLetterToUpper(word)); wordsCaps.add(firstLetterToUpper(word));
} }
@ -684,7 +684,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation op, Map<String, List<CodegenOperation>> operations) { public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation op, Map<String, List<CodegenOperation>> operations) {
List<CodegenOperation> opList = operations.get(tag); List<CodegenOperation> opList = operations.get(tag);
if (opList == null || opList.isEmpty()) { if (opList == null || opList.isEmpty()) {
opList = new ArrayList<CodegenOperation>(); opList = new ArrayList<>();
operations.put(tag, opList); operations.put(tag, opList);
} }
// check for operationId uniqueness // check for operationId uniqueness
@ -1454,7 +1454,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
// only process files with hs extension // only process files with hs extension
if ("hs".equals(FilenameUtils.getExtension(file.toString()))) { if ("hs".equals(FilenameUtils.getExtension(file.toString()))) {
String command = haskellPostProcessFile + " " + file.toString(); String command = haskellPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -169,7 +169,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
* Language Specific Primitives. These types will not trigger imports by * Language Specific Primitives. These types will not trigger imports by
* the client generator * the client generator
*/ */
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"Bool", "Bool",
"String", "String",
@ -286,14 +286,14 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
String[] words = title.split(" "); String[] words = title.split(" ");
// The package name is made by appending the lowercased words of the title interspersed with dashes // The package name is made by appending the lowercased words of the title interspersed with dashes
List<String> wordsLower = new ArrayList<String>(); List<String> wordsLower = new ArrayList<>();
for (String word : words) { for (String word : words) {
wordsLower.add(word.toLowerCase(Locale.ROOT)); wordsLower.add(word.toLowerCase(Locale.ROOT));
} }
String cabalName = joinStrings("-", wordsLower); String cabalName = joinStrings("-", wordsLower);
// The API name is made by appending the capitalized words of the title // The API name is made by appending the capitalized words of the title
List<String> wordsCaps = new ArrayList<String>(); List<String> wordsCaps = new ArrayList<>();
for (String word : words) { for (String word : words) {
wordsCaps.add(firstLetterToUpper(word)); wordsCaps.add(firstLetterToUpper(word));
} }
@ -446,7 +446,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// IdType is provided by the capture params. // IdType is provided by the capture params.
private List<String> pathToServantRoute(String path, List<CodegenParameter> pathParams) { private List<String> pathToServantRoute(String path, List<CodegenParameter> pathParams) {
// Map the capture params by their names. // Map the capture params by their names.
HashMap<String, String> captureTypes = new HashMap<String, String>(); HashMap<String, String> captureTypes = new HashMap<>();
for (CodegenParameter param : pathParams) { for (CodegenParameter param : pathParams) {
captureTypes.put(param.baseName, param.dataType); captureTypes.put(param.baseName, param.dataType);
} }
@ -462,7 +462,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
} }
// Convert the path into a list of servant route components. // Convert the path into a list of servant route components.
List<String> pathComponents = new ArrayList<String>(); List<String> pathComponents = new ArrayList<>();
for (String piece : path.split("/")) { for (String piece : path.split("/")) {
if (piece.startsWith("{") && piece.endsWith("}")) { if (piece.startsWith("{") && piece.endsWith("}")) {
String name = piece.substring(1, piece.length() - 1); String name = piece.substring(1, piece.length() - 1);
@ -479,7 +479,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// Extract the arguments that are passed in the route path parameters // Extract the arguments that are passed in the route path parameters
private List<String> pathToClientType(String path, List<CodegenParameter> pathParams) { private List<String> pathToClientType(String path, List<CodegenParameter> pathParams) {
// Map the capture params by their names. // Map the capture params by their names.
HashMap<String, String> captureTypes = new HashMap<String, String>(); HashMap<String, String> captureTypes = new HashMap<>();
for (CodegenParameter param : pathParams) { for (CodegenParameter param : pathParams) {
captureTypes.put(param.baseName, param.dataType); captureTypes.put(param.baseName, param.dataType);
} }
@ -490,7 +490,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
} }
// Convert the path into a list of servant route components. // Convert the path into a list of servant route components.
List<String> type = new ArrayList<String>(); List<String> type = new ArrayList<>();
for (String piece : path.split("/")) { for (String piece : path.split("/")) {
if (piece.startsWith("{") && piece.endsWith("}")) { if (piece.startsWith("{") && piece.endsWith("}")) {
String name = piece.substring(1, piece.length() - 1); String name = piece.substring(1, piece.length() - 1);
@ -605,8 +605,8 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
String name = string; String name = string;
//Check if it is a reserved word, in which case the underscore is added when property name is generated. //Check if it is a reserved word, in which case the underscore is added when property name is generated.
if (string.startsWith("_")) { if (string.startsWith("_")) {
if (reservedWords.contains(string.substring(1, string.length()))) { if (reservedWords.contains(string.substring(1))) {
name = string.substring(1, string.length()); name = string.substring(1);
} else if (reservedWordsMappings.containsValue(string)) { } else if (reservedWordsMappings.containsValue(string)) {
name = LEADING_UNDERSCORE.matcher(string).replaceFirst(""); name = LEADING_UNDERSCORE.matcher(string).replaceFirst("");
} }
@ -685,7 +685,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// only process files with hs extension // only process files with hs extension
if ("hs".equals(FilenameUtils.getExtension(file.toString()))) { if ("hs".equals(FilenameUtils.getExtension(file.toString()))) {
String command = haskellPostProcessFile + " " + file.toString(); String command = haskellPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -136,7 +136,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
) )
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"Bool", "Bool",
"Int", "Int",
@ -359,7 +359,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
private List<String> pathToComponents(String path, List<CodegenParameter> pathParams) { private List<String> pathToComponents(String path, List<CodegenParameter> pathParams) {
// Map the capture params by their names. // Map the capture params by their names.
HashMap<String, String> captureTypes = new HashMap<String, String>(); HashMap<String, String> captureTypes = new HashMap<>();
for (CodegenParameter param : pathParams) { for (CodegenParameter param : pathParams) {
captureTypes.put(param.baseName, param.dataType); captureTypes.put(param.baseName, param.dataType);
} }
@ -370,7 +370,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
} }
// Convert the path into a list of yesod path components. // Convert the path into a list of yesod path components.
List<String> components = new ArrayList<String>(); List<String> components = new ArrayList<>();
for (String piece : path.split("/")) { for (String piece : path.split("/")) {
if (piece.startsWith("{") && piece.endsWith("}")) { if (piece.startsWith("{") && piece.endsWith("}")) {
String name = piece.substring(1, piece.length() - 1); String name = piece.substring(1, piece.length() - 1);
@ -412,7 +412,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
List<Map<String, Object>> routes = (List<Map<String, Object>>) additionalProperties.get("routes"); List<Map<String, Object>> routes = (List<Map<String, Object>>) additionalProperties.get("routes");
if (routes == null) { if (routes == null) {
routes = new ArrayList<Map<String, Object>>(); routes = new ArrayList<>();
additionalProperties.put("routes", routes); additionalProperties.put("routes", routes);
} }
@ -432,10 +432,10 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
} }
if (!found) { if (!found) {
Map<String, Object> route = new HashMap<String, Object>(); Map<String, Object> route = new HashMap<>();
route.put("path", path); route.put("path", path);
route.put("resource", resource); route.put("resource", resource);
List<String> methods = new ArrayList<String>(); List<String> methods = new ArrayList<>();
methods.add(op.httpMethod); methods.add(op.httpMethod);
route.put("methods", methods); route.put("methods", methods);
routes.add(route); routes.add(route);
@ -534,8 +534,8 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
String name = string; String name = string;
//Check if it is a reserved word, in which case the underscore is added when property name is generated. //Check if it is a reserved word, in which case the underscore is added when property name is generated.
if (string.startsWith("_")) { if (string.startsWith("_")) {
if (reservedWords.contains(string.substring(1, string.length()))) { if (reservedWords.contains(string.substring(1))) {
name = string.substring(1, string.length()); name = string.substring(1);
} else if (reservedWordsMappings.containsValue(string)) { } else if (reservedWordsMappings.containsValue(string)) {
name = LEADING_UNDERSCORE.matcher(string).replaceFirst(""); name = LEADING_UNDERSCORE.matcher(string).replaceFirst("");
} }
@ -614,7 +614,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
// only process files with hs extension // only process files with hs extension
if ("hs".equals(FilenameUtils.getExtension(file.toString()))) { if ("hs".equals(FilenameUtils.getExtension(file.toString()))) {
String command = haskellPostProcessFile + " " + file.toString(); String command = haskellPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -133,7 +133,7 @@ public class JMeterClientCodegen extends DefaultCodegen implements CodegenConfig
/* /*
* Reserved words. Override this with reserved words specific to your language * Reserved words. Override this with reserved words specific to your language
*/ */
reservedWords = new HashSet<String>( reservedWords = new HashSet<>(
Arrays.asList( Arrays.asList(
"sample1", // replace with static values "sample1", // replace with static values
"sample2") "sample2")

View File

@ -70,7 +70,7 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId()); updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
updateOption(CodegenConstants.API_PACKAGE, apiPackage); updateOption(CodegenConstants.API_PACKAGE, apiPackage);
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage); updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
updateOption(this.DATE_LIBRARY, this.getDateLibrary()); updateOption(DATE_LIBRARY, this.getDateLibrary());
// clear model and api doc template as this codegen // clear model and api doc template as this codegen
// does not support auto-generated markdown doc at the moment // does not support auto-generated markdown doc at the moment

View File

@ -655,7 +655,7 @@ public class JavaCXFExtServerCodegen extends JavaCXFServerCodegen implements CXF
var.addTestData(randomBigDecimal); var.addTestData(randomBigDecimal);
} }
} else { } else {
buffer.append(randomBigDecimal.toString()).append('D'); buffer.append(randomBigDecimal).append('D');
} }
} }
} }
@ -1294,7 +1294,7 @@ public class JavaCXFExtServerCodegen extends JavaCXFServerCodegen implements CXF
if (testDataCache.root().isDirty()) { if (testDataCache.root().isDirty()) {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
testDataCache.root().flush(out); testDataCache.root().flush(out);
String testDataJson = new String(out.toByteArray(), "UTF-8"); String testDataJson = out.toString("UTF-8");
objs.put("test-data.json", testDataJson); objs.put("test-data.json", testDataJson);
supportingFiles.add(new SupportingFile("testData.mustache", testDataFile.getAbsolutePath())); supportingFiles.add(new SupportingFile("testData.mustache", testDataFile.getAbsolutePath()));
} }
@ -1306,7 +1306,7 @@ public class JavaCXFExtServerCodegen extends JavaCXFServerCodegen implements CXF
if (testDataControlCache.root().isDirty()) { if (testDataControlCache.root().isDirty()) {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
testDataControlCache.root().flush(out); testDataControlCache.root().flush(out);
String testDataControlJson = new String(out.toByteArray(), "UTF-8"); String testDataControlJson = out.toString("UTF-8");
objs.put("test-data-control.json", testDataControlJson); objs.put("test-data-control.json", testDataControlJson);
supportingFiles supportingFiles
.add(new SupportingFile("testDataControl.mustache", testDataControlFile.getAbsolutePath())); .add(new SupportingFile("testDataControl.mustache", testDataControlFile.getAbsolutePath()));

View File

@ -65,7 +65,7 @@ public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId()); updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
updateOption(CodegenConstants.API_PACKAGE, apiPackage); updateOption(CodegenConstants.API_PACKAGE, apiPackage);
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage); updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
updateOption(this.DATE_LIBRARY, this.getDateLibrary()); updateOption(DATE_LIBRARY, this.getDateLibrary());
additionalProperties.put("title", title); additionalProperties.put("title", title);
// java inflector uses the jackson lib // java inflector uses the jackson lib

View File

@ -116,7 +116,7 @@ public class JavaMicronautClientCodegen extends AbstractJavaCodegen implements B
.ifPresent(v -> cliOptions.remove(v)); .ifPresent(v -> cliOptions.remove(v));
// Add reserved words // Add reserved words
String[] reservedWordsArray = new String[]{ String[] reservedWordsArray = {
"client", "format", "queryvalue", "queryparam", "pathvariable", "header", "cookie", "client", "format", "queryvalue", "queryparam", "pathvariable", "header", "cookie",
"authorization", "body", "application" "authorization", "body", "application"
}; };

View File

@ -471,7 +471,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
// get vendor extensions // get vendor extensions
Map<String, Object> vendorExt = openAPI.getInfo().getExtensions(); Map<String, Object> vendorExt = openAPI.getInfo().getExtensions();
if (vendorExt != null && !vendorExt.toString().equals("")) { if (vendorExt != null && !vendorExt.toString().isEmpty()) {
if (vendorExt.containsKey("x-codegen")) { if (vendorExt.containsKey("x-codegen")) {
Map<String, String> uris = (Map<String, String>) vendorExt.get("x-codegen"); Map<String, String> uris = (Map<String, String>) vendorExt.get("x-codegen");

View File

@ -52,7 +52,7 @@ public class JavaUndertowServerCodegen extends AbstractJavaCodegen {
// clioOptions default redefinition need to be updated // clioOptions default redefinition need to be updated
updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage()); updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage());
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId()); updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
updateOption(this.DATE_LIBRARY, this.getDateLibrary()); updateOption(DATE_LIBRARY, this.getDateLibrary());
apiTestTemplateFiles.clear(); // TODO: add test template apiTestTemplateFiles.clear(); // TODO: add test template

View File

@ -95,7 +95,7 @@ public class JavaVertXServerCodegen extends AbstractJavaCodegen {
updateOption(CodegenConstants.ARTIFACT_VERSION, this.getArtifactVersion()); updateOption(CodegenConstants.ARTIFACT_VERSION, this.getArtifactVersion());
updateOption(CodegenConstants.API_PACKAGE, apiPackage); updateOption(CodegenConstants.API_PACKAGE, apiPackage);
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage); updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
updateOption(this.DATE_LIBRARY, this.getDateLibrary()); updateOption(DATE_LIBRARY, this.getDateLibrary());
additionalProperties.put(ROOT_PACKAGE, rootPackage); additionalProperties.put(ROOT_PACKAGE, rootPackage);

View File

@ -49,7 +49,7 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
public static final String EMIT_JS_DOC = "emitJSDoc"; public static final String EMIT_JS_DOC = "emitJSDoc";
public static final String NPM_REPOSITORY = "npmRepository"; public static final String NPM_REPOSITORY = "npmRepository";
final String[][] JAVASCRIPT_SUPPORTING_FILES = new String[][]{ final String[][] JAVASCRIPT_SUPPORTING_FILES = {
new String[]{"package.mustache", "package.json"}, new String[]{"package.mustache", "package.json"},
// new String[]{"index.mustache", "src/index.js", }, // new String[]{"index.mustache", "src/index.js", },
// new String[]{"ApiClient.mustache", "src/ApiClient.js"}, // new String[]{"ApiClient.mustache", "src/ApiClient.js"},
@ -59,7 +59,7 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
new String[]{"travis.yml", ".travis.yml"} new String[]{"travis.yml", ".travis.yml"}
}; };
final String[][] JAVASCRIPT_ES6_SUPPORTING_FILES = new String[][]{ final String[][] JAVASCRIPT_ES6_SUPPORTING_FILES = {
new String[]{"package.mustache", "package.json"}, new String[]{"package.mustache", "package.json"},
// new String[]{"index.mustache", "src/index.js"}, // new String[]{"index.mustache", "src/index.js"},
// new String[]{"ApiClient.mustache", "src/ApiClient.js"}, // new String[]{"ApiClient.mustache", "src/ApiClient.js"},
@ -132,10 +132,10 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
"prototype", "String", "toString", "undefined", "valueOf") "prototype", "String", "toString", "undefined", "valueOf")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList("String", "Boolean", "Number", "Array", "Object", "Date", "File", "Blob") Arrays.asList("String", "Boolean", "Number", "Array", "Object", "Date", "File", "Blob")
); );
defaultIncludes = new HashSet<String>(languageSpecificPrimitives); defaultIncludes = new HashSet<>(languageSpecificPrimitives);
instantiationTypes.put("array", "Array"); instantiationTypes.put("array", "Array");
instantiationTypes.put("list", "Array"); instantiationTypes.put("list", "Array");
@ -1127,7 +1127,7 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
// only process files with js extension // only process files with js extension
if ("js".equals(FilenameUtils.getExtension(file.toString()))) { if ("js".equals(FilenameUtils.getExtension(file.toString()))) {
String command = jsPostProcessFile + " " + file.toString(); String command = jsPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
p.waitFor(); p.waitFor();

View File

@ -51,7 +51,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
public static final String USE_ES6 = "useES6"; public static final String USE_ES6 = "useES6";
public static final String NPM_REPOSITORY = "npmRepository"; public static final String NPM_REPOSITORY = "npmRepository";
final String[][] JAVASCRIPT_SUPPORTING_FILES = new String[][]{ final String[][] JAVASCRIPT_SUPPORTING_FILES = {
new String[]{"package.mustache", "package.json"}, new String[]{"package.mustache", "package.json"},
// new String[]{"index.mustache", "src/index.js", }, // new String[]{"index.mustache", "src/index.js", },
// new String[]{"ApiClient.mustache", "src/ApiClient.js"}, // new String[]{"ApiClient.mustache", "src/ApiClient.js"},
@ -62,7 +62,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
new String[]{"gitignore.mustache", ".gitignore"} new String[]{"gitignore.mustache", ".gitignore"}
}; };
final String[][] JAVASCRIPT_ES6_SUPPORTING_FILES = new String[][]{ final String[][] JAVASCRIPT_ES6_SUPPORTING_FILES = {
new String[]{"package.mustache", "package.json"}, new String[]{"package.mustache", "package.json"},
// new String[]{"index.mustache", "src/index.js"}, // new String[]{"index.mustache", "src/index.js"},
// new String[]{"ApiClient.mustache", "src/ApiClient.js"}, // new String[]{"ApiClient.mustache", "src/ApiClient.js"},
@ -135,10 +135,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
"prototype", "String", "toString", "undefined", "valueOf") "prototype", "String", "toString", "undefined", "valueOf")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList("String", "Boolean", "Number", "Array", "Object", "Date", "File", "Blob") Arrays.asList("String", "Boolean", "Number", "Array", "Object", "Date", "File", "Blob")
); );
defaultIncludes = new HashSet<String>(languageSpecificPrimitives); defaultIncludes = new HashSet<>(languageSpecificPrimitives);
instantiationTypes.put("array", "Array"); instantiationTypes.put("array", "Array");
instantiationTypes.put("set", "Array"); instantiationTypes.put("set", "Array");
@ -1212,7 +1212,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
// only process files with js extension // only process files with js extension
if ("js".equals(FilenameUtils.getExtension(file.toString()))) { if ("js".equals(FilenameUtils.getExtension(file.toString()))) {
String command = jsPostProcessFile + " " + file.toString(); String command = jsPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
p.waitFor(); p.waitFor();

View File

@ -55,16 +55,16 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
"short", "try", "char", "final", "interface", "static", "void", "short", "try", "char", "final", "interface", "static", "void",
"class", "finally", "const", "super", "while")); "class", "finally", "const", "super", "while"));
languageSpecificPrimitives = new HashSet<String>(Arrays.asList( languageSpecificPrimitives = new HashSet<>(Arrays.asList(
"string", "string",
"boolean", "boolean",
"number", "number",
"Object", "Object",
"Blob", "Blob",
"Date")); "Date"));
instantiationTypes.put("array", "Array"); instantiationTypes.put("array", "Array");
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("Array", "Array"); typeMapping.put("Array", "Array");
typeMapping.put("array", "Array"); typeMapping.put("array", "Array");
typeMapping.put("List", "Array"); typeMapping.put("List", "Array");
@ -86,11 +86,11 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
typeMapping.put("map", "Object"); typeMapping.put("map", "Object");
typeMapping.put("DateTime", "Date"); typeMapping.put("DateTime", "Date");
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
defaultIncludes = new HashSet<String>(Arrays.asList( defaultIncludes = new HashSet<>(Arrays.asList(
"Object", "Object",
"Array", "Array",
"Blob" "Blob"
)); ));
typeMapping.put("binary", "string"); typeMapping.put("binary", "string");

View File

@ -64,7 +64,7 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
"Math", "NaN", "Number", "Object", "Math", "NaN", "Number", "Object",
"prototype", "String", "toString", "undefined", "valueOf")); "prototype", "String", "toString", "undefined", "valueOf"));
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList("string", "boolean", "number", "Array", "Object", "Date", "File", "Blob") Arrays.asList("string", "boolean", "number", "Array", "Object", "Date", "File", "Blob")
); );
@ -95,7 +95,7 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
typeMapping.put("UUID", "string"); typeMapping.put("UUID", "string");
typeMapping.put("URI", "string"); typeMapping.put("URI", "string");
defaultIncludes = new HashSet<String>(languageSpecificPrimitives); defaultIncludes = new HashSet<>(languageSpecificPrimitives);
outputFolder = "generated-code/javascript-flowtyped"; outputFolder = "generated-code/javascript-flowtyped";
embeddedTemplateDir = templateDir = "Javascript-Flowtyped"; embeddedTemplateDir = templateDir = "Javascript-Flowtyped";
@ -173,14 +173,14 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
// name enum with model name, e.g. StatusEnum => Pet.StatusEnum // name enum with model name, e.g. StatusEnum => Pet.StatusEnum
for (CodegenProperty var : cm.vars) { for (CodegenProperty var : cm.vars) {
if (Boolean.TRUE.equals(var.isEnum)) { if (Boolean.TRUE.equals(var.isEnum)) {
var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "" + var.enumName); var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + var.enumName);
} }
} }
if (cm.parent != null) { if (cm.parent != null) {
for (CodegenProperty var : cm.allVars) { for (CodegenProperty var : cm.allVars) {
if (Boolean.TRUE.equals(var.isEnum)) { if (Boolean.TRUE.equals(var.isEnum)) {
var.datatypeWithEnum = var.datatypeWithEnum var.datatypeWithEnum = var.datatypeWithEnum
.replace(var.enumName, cm.classname + "" + var.enumName); .replace(var.enumName, cm.classname + var.enumName);
} }
} }
} }

View File

@ -141,7 +141,7 @@ public class K6ClientCodegen extends DefaultCodegen implements CodegenConfig {
.map(x -> quoteExample( .map(x -> quoteExample(
StringEscapeUtils.escapeEcmaScript( StringEscapeUtils.escapeEcmaScript(
String.valueOf(x.getValue())))) String.valueOf(x.getValue()))))
.collect(Collectors.toCollection(() -> new TreeSet<String>())); .collect(Collectors.toCollection(() -> new TreeSet<>()));
if (!exampleValues.isEmpty()) { if (!exampleValues.isEmpty()) {
@ -274,7 +274,7 @@ public class K6ClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String BASE_URL = "baseURL"; public static final String BASE_URL = "baseURL";
public static final String PRESERVE_LEADING_PARAM_CHAR = "preserveLeadingParamChar"; public static final String PRESERVE_LEADING_PARAM_CHAR = "preserveLeadingParamChar";
static final Collection<String> INVOKER_PKG_SUPPORTING_FILES = Arrays.asList("script.mustache", "README.mustache"); static final Collection<String> INVOKER_PKG_SUPPORTING_FILES = Arrays.asList("script.mustache", "README.mustache");
static final String[][] JAVASCRIPT_SUPPORTING_FILES = new String[][]{ static final String[][] JAVASCRIPT_SUPPORTING_FILES = {
new String[]{"script.mustache", "script.js"}, new String[]{"README.mustache", "README.md"}}; new String[]{"script.mustache", "script.js"}, new String[]{"README.mustache", "README.md"}};
protected String projectName; protected String projectName;
@ -412,7 +412,7 @@ public class K6ClientCodegen extends DefaultCodegen implements CodegenConfig {
List<Parameter> queryParams = new ArrayList<>(); List<Parameter> queryParams = new ArrayList<>();
List<Parameter> bodyOrFormParams = new ArrayList<>(); List<Parameter> bodyOrFormParams = new ArrayList<>();
List<k6Check> k6Checks = new ArrayList<>(); List<k6Check> k6Checks = new ArrayList<>();
Set<String> imports = new HashSet<String>(); Set<String> imports = new HashSet<>();
final Operation operation = methodOperation.getValue(); final Operation operation = methodOperation.getValue();
final PathItem.HttpMethod method = methodOperation.getKey(); final PathItem.HttpMethod method = methodOperation.getKey();

View File

@ -454,7 +454,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
basePath = basePath.substring(0, pos); basePath = basePath.substring(0, pos);
} }
if (basePath.equals("")) { if (basePath.isEmpty()) {
basePath = "default"; basePath = "default";
} else { } else {
co.subresourceOperation = !co.path.isEmpty(); co.subresourceOperation = !co.path.isEmpty();

View File

@ -1055,7 +1055,7 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
// identifier name cannot be empty // identifier name cannot be empty
if (escapedName.isEmpty()) { if (escapedName.isEmpty()) {
throw new RuntimeException("Empty database/table/column name for property '" + name.toString() + "' not allowed"); throw new RuntimeException("Empty database/table/column name for property '" + name + "' not allowed");
} }
return escapedName; return escapedName;
} }

View File

@ -111,13 +111,13 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
) )
); );
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"map", "map",
"array") "array")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"nil", "nil",
"string", "string",
@ -150,7 +150,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("ByteArray", "string"); typeMapping.put("ByteArray", "string");
typeMapping.put("object", "TODO_OBJECT_MAPPING"); typeMapping.put("object", "TODO_OBJECT_MAPPING");
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
importMapping.put("time.Time", "time"); importMapping.put("time.Time", "time");
importMapping.put("*os.File", "os"); importMapping.put("*os.File", "os");
importMapping.put("os", "io/ioutil"); importMapping.put("os", "io/ioutil");
@ -508,7 +508,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
} }
public Map<String, String> createMapping(String key, String value) { public Map<String, String> createMapping(String key, String value) {
Map<String, String> customImport = new HashMap<String, String>(); Map<String, String> customImport = new HashMap<>();
customImport.put(key, value); customImport.put(key, value);
return customImport; return customImport;

View File

@ -97,7 +97,7 @@ public class MarkdownDocumentationCodegen extends DefaultCodegen implements Code
public String toParamName(String name) { public String toParamName(String name) {
if (reservedWords.contains(name)) { if (reservedWords.contains(name)) {
return escapeReservedWord(name); return escapeReservedWord(name);
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains("" + ((char) character)))) { } else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character)))) {
return escape(name, specialCharReplacements, null, null); return escape(name, specialCharReplacements, null, null);
} }
return name; return name;

View File

@ -41,19 +41,19 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
public static final Integer ENUM_MAX_ELEMENTS = 65535; public static final Integer ENUM_MAX_ELEMENTS = 65535;
public static final Integer IDENTIFIER_MAX_LENGTH = 64; public static final Integer IDENTIFIER_MAX_LENGTH = 64;
protected Vector<String> mysqlNumericTypes = new Vector<String>(Arrays.asList( protected Vector<String> mysqlNumericTypes = new Vector<>(Arrays.asList(
"BIGINT", "BIT", "BOOL", "BOOLEAN", "DEC", "DECIMAL", "DOUBLE", "DOUBLE PRECISION", "FIXED", "FLOAT", "INT", "INTEGER", "MEDIUMINT", "NUMERIC", "REAL", "SMALLINT", "TINYINT" "BIGINT", "BIT", "BOOL", "BOOLEAN", "DEC", "DECIMAL", "DOUBLE", "DOUBLE PRECISION", "FIXED", "FLOAT", "INT", "INTEGER", "MEDIUMINT", "NUMERIC", "REAL", "SMALLINT", "TINYINT"
)); ));
protected Vector<String> mysqlDateAndTimeTypes = new Vector<String>(Arrays.asList( protected Vector<String> mysqlDateAndTimeTypes = new Vector<>(Arrays.asList(
"DATE", "DATETIME", "TIME", "TIMESTAMP", "YEAR" "DATE", "DATETIME", "TIME", "TIMESTAMP", "YEAR"
)); ));
protected Vector<String> mysqlStringTypes = new Vector<String>(Arrays.asList( protected Vector<String> mysqlStringTypes = new Vector<>(Arrays.asList(
"BINARY", "BLOB", "CHAR", "CHAR BYTE", "CHARACTER", "ENUM", "LONGBLOB", "LONGTEXT", "MEDIUMBLOB", "MEDIUMTEXT", "SET", "TEXT", "TINYBLOB", "TINYTEXT", "VARBINARY", "VARCHAR" "BINARY", "BLOB", "CHAR", "CHAR BYTE", "CHARACTER", "ENUM", "LONGBLOB", "LONGTEXT", "MEDIUMBLOB", "MEDIUMTEXT", "SET", "TEXT", "TINYBLOB", "TINYTEXT", "VARBINARY", "VARCHAR"
)); ));
protected Vector<String> mysqlSpatialTypes = new Vector<String>(Arrays.asList( protected Vector<String> mysqlSpatialTypes = new Vector<>(Arrays.asList(
"GEOMETRY", "GEOMETRYCOLLECTION", "LINESTRING", "MULTILINESTRING", "MULTIPOINT", "MULTIPOLYGON", "POINT", "POLYGON" "GEOMETRY", "GEOMETRYCOLLECTION", "LINESTRING", "MULTILINESTRING", "MULTIPOINT", "MULTIPOLYGON", "POINT", "POLYGON"
)); ));
@ -125,7 +125,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
); );
// all types can be threaded as primitives except array, object and refs // all types can be threaded as primitives except array, object and refs
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"boolean", "boolean",
@ -263,8 +263,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
String tableName = this.toTableName(modelName); String tableName = this.toTableName(modelName);
String modelDescription = model.getDescription(); String modelDescription = model.getDescription();
Map<String, Object> modelVendorExtensions = model.getVendorExtensions(); Map<String, Object> modelVendorExtensions = model.getVendorExtensions();
Map<String, Object> mysqlSchema = new HashMap<String, Object>(); Map<String, Object> mysqlSchema = new HashMap<>();
Map<String, Object> tableDefinition = new HashMap<String, Object>(); Map<String, Object> tableDefinition = new HashMap<>();
if (this.getIdentifierNamingConvention().equals("snake_case") && !modelName.equals(tableName)) { if (this.getIdentifierNamingConvention().equals("snake_case") && !modelName.equals(tableName)) {
// add original name in table comment // add original name in table comment
@ -325,8 +325,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
*/ */
public void processIntegerTypeProperty(CodegenModel model, CodegenProperty property) { public void processIntegerTypeProperty(CodegenModel model, CodegenProperty property) {
Map<String, Object> vendorExtensions = property.getVendorExtensions(); Map<String, Object> vendorExtensions = property.getVendorExtensions();
Map<String, Object> mysqlSchema = new HashMap<String, Object>(); Map<String, Object> mysqlSchema = new HashMap<>();
Map<String, Object> columnDefinition = new HashMap<String, Object>(); Map<String, Object> columnDefinition = new HashMap<>();
ArrayList columnDataTypeArguments = new ArrayList(); ArrayList columnDataTypeArguments = new ArrayList();
String baseName = property.getBaseName(); String baseName = property.getBaseName();
String colName = this.toColumnName(baseName); String colName = this.toColumnName(baseName);
@ -366,7 +366,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
if (i > ENUM_MAX_ELEMENTS - 1) { if (i > ENUM_MAX_ELEMENTS - 1) {
LOGGER.warn( LOGGER.warn(
"ENUM column can have maximum of {} distinct elements, following value will be skipped: {}", "ENUM column can have maximum of {} distinct elements, following value will be skipped: {}",
ENUM_MAX_ELEMENTS.toString(), (String) enumValues.get(i)); ENUM_MAX_ELEMENTS, (String) enumValues.get(i));
break; break;
} }
String value = String.valueOf(enumValues.get(i)); String value = String.valueOf(enumValues.get(i));
@ -417,8 +417,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
*/ */
public void processDecimalTypeProperty(CodegenModel model, CodegenProperty property) { public void processDecimalTypeProperty(CodegenModel model, CodegenProperty property) {
Map<String, Object> vendorExtensions = property.getVendorExtensions(); Map<String, Object> vendorExtensions = property.getVendorExtensions();
Map<String, Object> mysqlSchema = new HashMap<String, Object>(); Map<String, Object> mysqlSchema = new HashMap<>();
Map<String, Object> columnDefinition = new HashMap<String, Object>(); Map<String, Object> columnDefinition = new HashMap<>();
ArrayList columnDataTypeArguments = new ArrayList(); ArrayList columnDataTypeArguments = new ArrayList();
String baseName = property.getBaseName(); String baseName = property.getBaseName();
String colName = this.toColumnName(baseName); String colName = this.toColumnName(baseName);
@ -457,7 +457,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
if (i > ENUM_MAX_ELEMENTS - 1) { if (i > ENUM_MAX_ELEMENTS - 1) {
LOGGER.warn( LOGGER.warn(
"ENUM column can have maximum of {} distinct elements, following value will be skipped: {}", "ENUM column can have maximum of {} distinct elements, following value will be skipped: {}",
ENUM_MAX_ELEMENTS.toString(), (String) enumValues.get(i)); ENUM_MAX_ELEMENTS, (String) enumValues.get(i));
break; break;
} }
String value = String.valueOf(enumValues.get(i)); String value = String.valueOf(enumValues.get(i));
@ -507,8 +507,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
*/ */
public void processBooleanTypeProperty(CodegenModel model, CodegenProperty property) { public void processBooleanTypeProperty(CodegenModel model, CodegenProperty property) {
Map<String, Object> vendorExtensions = property.getVendorExtensions(); Map<String, Object> vendorExtensions = property.getVendorExtensions();
Map<String, Object> mysqlSchema = new HashMap<String, Object>(); Map<String, Object> mysqlSchema = new HashMap<>();
Map<String, Object> columnDefinition = new HashMap<String, Object>(); Map<String, Object> columnDefinition = new HashMap<>();
ArrayList columnDataTypeArguments = new ArrayList(); ArrayList columnDataTypeArguments = new ArrayList();
String baseName = property.getBaseName(); String baseName = property.getBaseName();
String colName = this.toColumnName(baseName); String colName = this.toColumnName(baseName);
@ -562,8 +562,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
*/ */
public void processStringTypeProperty(CodegenModel model, CodegenProperty property) { public void processStringTypeProperty(CodegenModel model, CodegenProperty property) {
Map<String, Object> vendorExtensions = property.getVendorExtensions(); Map<String, Object> vendorExtensions = property.getVendorExtensions();
Map<String, Object> mysqlSchema = new HashMap<String, Object>(); Map<String, Object> mysqlSchema = new HashMap<>();
Map<String, Object> columnDefinition = new HashMap<String, Object>(); Map<String, Object> columnDefinition = new HashMap<>();
ArrayList columnDataTypeArguments = new ArrayList(); ArrayList columnDataTypeArguments = new ArrayList();
String baseName = property.getBaseName(); String baseName = property.getBaseName();
String colName = this.toColumnName(baseName); String colName = this.toColumnName(baseName);
@ -601,7 +601,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
if (i > ENUM_MAX_ELEMENTS - 1) { if (i > ENUM_MAX_ELEMENTS - 1) {
LOGGER.warn( LOGGER.warn(
"ENUM column can have maximum of {} distinct elements, following value will be skipped: {}", "ENUM column can have maximum of {} distinct elements, following value will be skipped: {}",
ENUM_MAX_ELEMENTS.toString(), (String) enumValues.get(i)); ENUM_MAX_ELEMENTS, (String) enumValues.get(i));
break; break;
} }
String value = String.valueOf(enumValues.get(i)); String value = String.valueOf(enumValues.get(i));
@ -645,8 +645,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
*/ */
public void processDateTypeProperty(CodegenModel model, CodegenProperty property) { public void processDateTypeProperty(CodegenModel model, CodegenProperty property) {
Map<String, Object> vendorExtensions = property.getVendorExtensions(); Map<String, Object> vendorExtensions = property.getVendorExtensions();
Map<String, Object> mysqlSchema = new HashMap<String, Object>(); Map<String, Object> mysqlSchema = new HashMap<>();
Map<String, Object> columnDefinition = new HashMap<String, Object>(); Map<String, Object> columnDefinition = new HashMap<>();
String baseName = property.getBaseName(); String baseName = property.getBaseName();
String colName = this.toColumnName(baseName); String colName = this.toColumnName(baseName);
String dataType = property.getDataType(); String dataType = property.getDataType();
@ -698,8 +698,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
*/ */
public void processJsonTypeProperty(CodegenModel model, CodegenProperty property) { public void processJsonTypeProperty(CodegenModel model, CodegenProperty property) {
Map<String, Object> vendorExtensions = property.getVendorExtensions(); Map<String, Object> vendorExtensions = property.getVendorExtensions();
Map<String, Object> mysqlSchema = new HashMap<String, Object>(); Map<String, Object> mysqlSchema = new HashMap<>();
Map<String, Object> columnDefinition = new HashMap<String, Object>(); Map<String, Object> columnDefinition = new HashMap<>();
String baseName = property.getBaseName(); String baseName = property.getBaseName();
String colName = this.toColumnName(baseName); String colName = this.toColumnName(baseName);
String dataType = property.getDataType(); String dataType = property.getDataType();
@ -755,8 +755,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
*/ */
public void processUnknownTypeProperty(CodegenModel model, CodegenProperty property) { public void processUnknownTypeProperty(CodegenModel model, CodegenProperty property) {
Map<String, Object> vendorExtensions = property.getVendorExtensions(); Map<String, Object> vendorExtensions = property.getVendorExtensions();
Map<String, Object> mysqlSchema = new HashMap<String, Object>(); Map<String, Object> mysqlSchema = new HashMap<>();
Map<String, Object> columnDefinition = new HashMap<String, Object>(); Map<String, Object> columnDefinition = new HashMap<>();
String baseName = property.getBaseName(); String baseName = property.getBaseName();
String colName = this.toColumnName(baseName); String colName = this.toColumnName(baseName);
Boolean required = property.getRequired(); Boolean required = property.getRequired();
@ -806,7 +806,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
* @return generated codegen property * @return generated codegen property
*/ */
public HashMap<String, Object> toCodegenMysqlDataTypeArgument(Object value) { public HashMap<String, Object> toCodegenMysqlDataTypeArgument(Object value) {
HashMap<String, Object> arg = new HashMap<String, Object>(); HashMap<String, Object> arg = new HashMap<>();
if (value instanceof String) { if (value instanceof String) {
arg.put("isString", true); arg.put("isString", true);
arg.put("isFloat", false); arg.put("isFloat", false);
@ -838,7 +838,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
* @return generated codegen property * @return generated codegen property
*/ */
public HashMap<String, Object> toCodegenMysqlDataTypeDefault(String defaultValue, String mysqlDataType) { public HashMap<String, Object> toCodegenMysqlDataTypeDefault(String defaultValue, String mysqlDataType) {
HashMap<String, Object> defaultMap = new HashMap<String, Object>(); HashMap<String, Object> defaultMap = new HashMap<>();
if (defaultValue == null || defaultValue.toUpperCase(Locale.ROOT).equals("NULL")) { if (defaultValue == null || defaultValue.toUpperCase(Locale.ROOT).equals("NULL")) {
defaultMap.put("defaultValue", "NULL"); defaultMap.put("defaultValue", "NULL");
defaultMap.put("isString", false); defaultMap.put("isString", false);
@ -1076,7 +1076,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
// identifier name cannot be empty // identifier name cannot be empty
if (escapedName.isEmpty()) { if (escapedName.isEmpty()) {
throw new RuntimeException("Empty database/table/column name for property '" + name.toString() + "' not allowed"); throw new RuntimeException("Empty database/table/column name for property '" + name + "' not allowed");
} }
return escapedName; return escapedName;
} }

View File

@ -117,13 +117,13 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
) )
); );
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"array" "array"
) )
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"int", "int",
"int8", "int8",

View File

@ -439,7 +439,7 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
// only process files with js extension // only process files with js extension
if ("js".equals(FilenameUtils.getExtension(file.toString()))) { if ("js".equals(FilenameUtils.getExtension(file.toString()))) {
String command = jsPostProcessFile + " " + file.toString(); String command = jsPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
p.waitFor(); p.waitFor();

View File

@ -672,7 +672,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
public String toEnumValueName(String name) { public String toEnumValueName(String name) {
if (reservedWords.contains(name)) { if (reservedWords.contains(name)) {
return escapeReservedWord(name); return escapeReservedWord(name);
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains("" + ((char) character)))) { } else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character)))) {
return escape(name, specialCharReplacements, Collections.singletonList("_"), null); return escape(name, specialCharReplacements, Collections.singletonList("_"), null);
} else { } else {
return name; return name;
@ -812,7 +812,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
} }
// only process files with ml or mli extension // only process files with ml or mli extension
if ("ml".equals(FilenameUtils.getExtension(file.toString())) || "mli".equals(FilenameUtils.getExtension(file.toString()))) { if ("ml".equals(FilenameUtils.getExtension(file.toString())) || "mli".equals(FilenameUtils.getExtension(file.toString()))) {
String command = ocamlPostProcessFile + " " + file.toString(); String command = ocamlPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -43,7 +43,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String DEFAULT_LICENSE = "Proprietary"; public static final String DEFAULT_LICENSE = "Proprietary";
public static final String CORE_DATA = "coreData"; public static final String CORE_DATA = "coreData";
protected Set<String> foundationClasses = new HashSet<String>(); protected Set<String> foundationClasses = new HashSet<>();
protected String podName = "OpenAPIClient"; protected String podName = "OpenAPIClient";
protected String podVersion = "1.0.0"; protected String podVersion = "1.0.0";
protected String classPrefix = "OAI"; protected String classPrefix = "OAI";
@ -60,7 +60,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
protected boolean generateCoreData = false; protected boolean generateCoreData = false;
protected Set<String> advancedMappingTypes = new HashSet<String>(); protected Set<String> advancedMappingTypes = new HashSet<>();
public ObjcClientCodegen() { public ObjcClientCodegen() {
super(); super();
@ -185,9 +185,9 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
"description", "class" "description", "class"
)); ));
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
foundationClasses = new HashSet<String>( foundationClasses = new HashSet<>(
Arrays.asList( Arrays.asList(
"NSNumber", "NSNumber",
"NSObject", "NSObject",

View File

@ -614,7 +614,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
if ("t".equals(FilenameUtils.getExtension(file.toString())) || if ("t".equals(FilenameUtils.getExtension(file.toString())) ||
"pm".equals(FilenameUtils.getExtension(file.toString())) || "pm".equals(FilenameUtils.getExtension(file.toString())) ||
"pl".equals(FilenameUtils.getExtension(file.toString()))) { "pl".equals(FilenameUtils.getExtension(file.toString()))) {
String command = perlTidyPath + " -b -bext='/' " + file.toString(); String command = perlTidyPath + " -b -bext='/' " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -90,7 +90,7 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
// ref: http://php.net/manual/en/language.types.intro.php // ref: http://php.net/manual/en/language.types.intro.php
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"boolean", "boolean",
"int", "int",
@ -108,7 +108,7 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
instantiationTypes.put("map", "map"); instantiationTypes.put("map", "map");
// ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types // ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("integer", "int"); typeMapping.put("integer", "int");
typeMapping.put("long", "int"); typeMapping.put("long", "int");
typeMapping.put("float", "float"); typeMapping.put("float", "float");

View File

@ -113,7 +113,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
outputFolder = "generated-code" + File.separator + "php"; outputFolder = "generated-code" + File.separator + "php";
apiTemplateFiles.put("api_controller.mustache", ".php"); apiTemplateFiles.put("api_controller.mustache", ".php");
modelTestTemplateFiles.put("testing/model_test.mustache", ".php"); modelTestTemplateFiles.put("testing/model_test.mustache", ".php");
apiTestTemplateFiles = new HashMap<String, String>(); apiTestTemplateFiles = new HashMap<>();
apiTestTemplateFiles.put("testing/api_test.mustache", ".php"); apiTestTemplateFiles.put("testing/api_test.mustache", ".php");
embeddedTemplateDir = templateDir = "php-symfony"; embeddedTemplateDir = templateDir = "php-symfony";
@ -139,7 +139,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
); );
// ref: http://php.net/manual/en/language.types.intro.php // ref: http://php.net/manual/en/language.types.intro.php
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"int", "int",
@ -157,7 +157,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
) )
); );
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"\\DateTime", "\\DateTime",
"UploadedFile" "UploadedFile"
@ -167,13 +167,13 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
variableNamingConvention = "camelCase"; variableNamingConvention = "camelCase";
// provide primitives to mustache template // provide primitives to mustache template
List sortedLanguageSpecificPrimitives = new ArrayList(languageSpecificPrimitives); List<String> sortedLanguageSpecificPrimitives = new ArrayList<>(languageSpecificPrimitives);
Collections.sort(sortedLanguageSpecificPrimitives); Collections.sort(sortedLanguageSpecificPrimitives);
String primitives = "'" + StringUtils.join(sortedLanguageSpecificPrimitives, "', '") + "'"; String primitives = "'" + StringUtils.join(sortedLanguageSpecificPrimitives, "', '") + "'";
additionalProperties.put("primitives", primitives); additionalProperties.put("primitives", primitives);
// ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types // ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("integer", "int"); typeMapping.put("integer", "int");
typeMapping.put("long", "int"); typeMapping.put("long", "int");
typeMapping.put("decimal", "float"); typeMapping.put("decimal", "float");
@ -370,13 +370,13 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
// Type-hintable primitive types // Type-hintable primitive types
// ref: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration // ref: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
if (phpLegacySupport) { if (phpLegacySupport) {
typeHintable = new HashSet<String>( typeHintable = new HashSet<>(
Arrays.asList( Arrays.asList(
"array" "array"
) )
); );
} else { } else {
typeHintable = new HashSet<String>( typeHintable = new HashSet<>(
Arrays.asList( Arrays.asList(
"array", "array",
"bool", "bool",
@ -396,7 +396,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
operations.put("controllerName", toControllerName((String) operations.get("pathPrefix"))); operations.put("controllerName", toControllerName((String) operations.get("pathPrefix")));
operations.put("symfonyService", toSymfonyService((String) operations.get("pathPrefix"))); operations.put("symfonyService", toSymfonyService((String) operations.get("pathPrefix")));
List<CodegenSecurity> authMethods = new ArrayList<CodegenSecurity>(); List<CodegenSecurity> authMethods = new ArrayList<>();
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation"); List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) { for (CodegenOperation op : operationList) {

View File

@ -109,7 +109,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
modelPackage = packageName + File.separator + "Model"; modelPackage = packageName + File.separator + "Model";
// https://blogs.msdn.microsoft.com/powershell/2010/01/07/how-objects-are-sent-to-and-from-remote-sessions/ // https://blogs.msdn.microsoft.com/powershell/2010/01/07/how-objects-are-sent-to-and-from-remote-sessions/
languageSpecificPrimitives = new HashSet<String>(Arrays.asList( languageSpecificPrimitives = new HashSet<>(Arrays.asList(
"Byte", "Byte",
"SByte", "SByte",
"Byte[]", "Byte[]",
@ -136,9 +136,9 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
"Version" "Version"
)); ));
commonVerbs = new HashMap<String, String>(); commonVerbs = new HashMap<>();
Map<String, List<String>> verbMappings = new HashMap<String, List<String>>(); Map<String, List<String>> verbMappings = new HashMap<>();
// common // common
verbMappings.put("Add", Arrays.asList("Append", "Attach", "Concatenate", "Insert")); verbMappings.put("Add", Arrays.asList("Append", "Attach", "Concatenate", "Insert"));
@ -266,7 +266,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
} }
} }
powershellVerbs = new HashSet<String>(Arrays.asList( powershellVerbs = new HashSet<>(Arrays.asList(
"Add", "Add",
"Clear", "Clear",
"Close", "Close",
@ -368,9 +368,9 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
"Use" "Use"
)); ));
methodNames = new HashSet<String>(); methodNames = new HashSet<>();
nullablePrimitives = new HashSet<String>(Arrays.asList( nullablePrimitives = new HashSet<>(Arrays.asList(
"System.Nullable[Byte]", "System.Nullable[Byte]",
"System.Nullable[SByte]", "System.Nullable[SByte]",
"System.Nullable[Int16]", "System.Nullable[Int16]",
@ -386,7 +386,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
)); ));
// list of reserved words - must be in lower case // list of reserved words - must be in lower case
reservedWords = new HashSet<String>(Arrays.asList( reservedWords = new HashSet<>(Arrays.asList(
// https://richardspowershellblog.wordpress.com/2009/05/02/powershell-reserved-words/ // https://richardspowershellblog.wordpress.com/2009/05/02/powershell-reserved-words/
"begin", "begin",
"break", "break",
@ -456,7 +456,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
"true" "true"
)); ));
paramNameReservedWords = new HashSet<String>(Arrays.asList( paramNameReservedWords = new HashSet<>(Arrays.asList(
"args", "args",
"error", "error",
"executioncontext", "executioncontext",
@ -480,7 +480,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
"true" "true"
)); ));
defaultIncludes = new HashSet<String>(Arrays.asList( defaultIncludes = new HashSet<>(Arrays.asList(
"Byte", "Byte",
"SByte", "SByte",
"Byte[]", "Byte[]",
@ -507,7 +507,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
"Version" "Version"
)); ));
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("string", "String"); typeMapping.put("string", "String");
typeMapping.put("boolean", "Boolean"); typeMapping.put("boolean", "Boolean");
typeMapping.put("integer", "Int32"); typeMapping.put("integer", "Int32");
@ -1012,8 +1012,8 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
@Override @Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) { public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations"); Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>(); HashMap<String, CodegenModel> modelMaps = new HashMap<>();
HashMap<String, Integer> processedModelMaps = new HashMap<String, Integer>(); HashMap<String, Integer> processedModelMaps = new HashMap<>();
for (Object o : allModels) { for (Object o : allModels) {
HashMap<String, Object> h = (HashMap<String, Object>) o; HashMap<String, Object> h = (HashMap<String, Object>) o;
@ -1185,10 +1185,10 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
if (codegenParameter.items.isModel) { if (codegenParameter.items.isModel) {
String modelExample = constructExampleCode(codegenParameter.items, modelMaps, processedModelMap, requiredOnly); String modelExample = constructExampleCode(codegenParameter.items, modelMaps, processedModelMap, requiredOnly);
if (!StringUtils.isEmpty(modelExample)) { if (!StringUtils.isEmpty(modelExample)) {
example.append(modelExample + "\n"); example.append(modelExample).append("\n");
} }
example.append("$" + codegenParameter.paramName + " = @{ key_example = $" + codegenParameter.items.dataType + " }"); example.append("$").append(codegenParameter.paramName).append(" = @{ key_example = $").append(codegenParameter.items.dataType).append(" }");
} else { } else {
example.append("@{ key_example = "); example.append("@{ key_example = ");
example.append(constructExampleCode(codegenParameter.items, modelMaps, processedModelMap, requiredOnly)); example.append(constructExampleCode(codegenParameter.items, modelMaps, processedModelMap, requiredOnly));
@ -1280,7 +1280,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
if (codegenProperty.isModel) { if (codegenProperty.isModel) {
String modelExample = constructExampleCode(codegenProperty, modelMaps, processedModelMap, requiredOnly); String modelExample = constructExampleCode(codegenProperty, modelMaps, processedModelMap, requiredOnly);
if (!StringUtils.isEmpty(modelExample)) { if (!StringUtils.isEmpty(modelExample)) {
example.append(modelExample + "\n"); example.append(modelExample).append("\n");
} }
propertyExamples.add("-" + codegenProperty.name + " " + "$" + codegenProperty.dataType); propertyExamples.add("-" + codegenProperty.name + " " + "$" + codegenProperty.dataType);
@ -1293,26 +1293,26 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
} }
if (!StringUtils.isEmpty(modelExample)) { if (!StringUtils.isEmpty(modelExample)) {
example.append(modelExample + "\n"); example.append(modelExample).append("\n");
} }
propertyExamples.add("-" + codegenProperty.name + " " + "$" + codegenProperty.complexType); propertyExamples.add("-" + codegenProperty.name + " " + "$" + codegenProperty.complexType);
} else if (codegenProperty.isArray && codegenProperty.items.isString) { } else if (codegenProperty.isArray && codegenProperty.items.isString) {
if (codegenProperty.items.isEnum || (codegenProperty.items.allowableValues != null && !codegenProperty.items.allowableValues.isEmpty())) { if (codegenProperty.items.isEnum || (codegenProperty.items.allowableValues != null && !codegenProperty.items.allowableValues.isEmpty())) {
example.append(constructEnumExample(codegenProperty.items.allowableValues)); example.append(constructEnumExample(codegenProperty.items.allowableValues));
propertyExamples.add("-" + codegenProperty.name + " " + example.toString()); propertyExamples.add("-" + codegenProperty.name + " " + example);
} else { } else {
StringBuilder stringArrayPropertyValue = new StringBuilder(); StringBuilder stringArrayPropertyValue = new StringBuilder();
String genericStringExample = codegenProperty.items.name + "_example"; String genericStringExample = codegenProperty.items.name + "_example";
stringArrayPropertyValue.append(constructStringExample(codegenProperty.name, codegenProperty.items.example, genericStringExample)); stringArrayPropertyValue.append(constructStringExample(codegenProperty.name, codegenProperty.items.example, genericStringExample));
propertyExamples.add("-" + codegenProperty.name + " " + stringArrayPropertyValue.toString()); propertyExamples.add("-" + codegenProperty.name + " " + stringArrayPropertyValue);
} }
} else if (codegenProperty.isMap && codegenProperty.items.isModel) { } else if (codegenProperty.isMap && codegenProperty.items.isModel) {
String modelExample = constructExampleCode(codegenProperty.items, modelMaps, processedModelMap, requiredOnly); String modelExample = constructExampleCode(codegenProperty.items, modelMaps, processedModelMap, requiredOnly);
if (!StringUtils.isEmpty(modelExample)) { if (!StringUtils.isEmpty(modelExample)) {
example.append(modelExample + "\n"); example.append(modelExample).append("\n");
} }
propertyExamples.add("-" + codegenProperty.name + " " + "@{ key_example = " + "$" + codegenProperty.complexType + " }"); propertyExamples.add("-" + codegenProperty.name + " " + "@{ key_example = " + "$" + codegenProperty.complexType + " }");
@ -1327,7 +1327,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
} else { } else {
example.append(codegenModel.name); example.append(codegenModel.name);
} }
example.append(" = " + this.modelsCmdletVerb + "-"); example.append(" = ").append(this.modelsCmdletVerb).append("-");
if (this.useClassNameInModelsExamples) { if (this.useClassNameInModelsExamples) {
example.append(codegenModel.classname); example.append(codegenModel.classname);
} else { } else {
@ -1353,7 +1353,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
codegenExample.equals("null") || codegenExample.equals("null") ||
codegenExample.equals(genericStringExample) codegenExample.equals(genericStringExample)
) { ) {
example.append("My" + codegenName); example.append("My").append(codegenName);
} else { } else {
example.append(codegenExample); example.append(codegenExample);
} }
@ -1369,7 +1369,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
example.append("\""); example.append("\"");
List<Object> enumValues = (List<Object>) allowableValues.get("values"); List<Object> enumValues = (List<Object>) allowableValues.get("values");
example.append(String.valueOf(enumValues.get(0))); example.append(enumValues.get(0));
example.append("\""); example.append("\"");
@ -1474,7 +1474,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
// only process files with ps extension // only process files with ps extension
if ("ps".equals(FilenameUtils.getExtension(file.toString()))) { if ("ps".equals(FilenameUtils.getExtension(file.toString()))) {
String command = powershellPostProcessFile + " " + file.toString(); String command = powershellPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -86,13 +86,13 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
modelPackage = "messages"; modelPackage = "messages";
apiPackage = "services"; apiPackage = "services";
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"map", "map",
"array") "array")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"map", "map",
"array", "array",

View File

@ -611,12 +611,12 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
ComposedSchema cs = (ComposedSchema) schema; ComposedSchema cs = (ComposedSchema) schema;
// these are the properties that are from properties in self cs or cs allOf // these are the properties that are from properties in self cs or cs allOf
Map<String, Schema> selfProperties = new LinkedHashMap<String, Schema>(); Map<String, Schema> selfProperties = new LinkedHashMap<>();
List<String> selfRequired = new ArrayList<String>(); List<String> selfRequired = new ArrayList<>();
// these are the properties that are from properties in cs oneOf or cs anyOf // these are the properties that are from properties in cs oneOf or cs anyOf
Map<String, Schema> otherProperties = new LinkedHashMap<String, Schema>(); Map<String, Schema> otherProperties = new LinkedHashMap<>();
List<String> otherRequired = new ArrayList<String>(); List<String> otherRequired = new ArrayList<>();
List<Schema> oneOfanyOfSchemas = new ArrayList<>(); List<Schema> oneOfanyOfSchemas = new ArrayList<>();
List<Schema> oneOf = cs.getOneOf(); List<Schema> oneOf = cs.getOneOf();
@ -631,7 +631,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
Schema refSchema = ModelUtils.getReferencedSchema(this.openAPI, sc); Schema refSchema = ModelUtils.getReferencedSchema(this.openAPI, sc);
addProperties(otherProperties, otherRequired, refSchema); addProperties(otherProperties, otherRequired, refSchema);
} }
Set<String> otherRequiredSet = new HashSet<String>(otherRequired); Set<String> otherRequiredSet = new HashSet<>(otherRequired);
List<Schema> allOf = cs.getAllOf(); List<Schema> allOf = cs.getAllOf();
if ((schema.getProperties() != null && !schema.getProperties().isEmpty()) || allOf != null) { if ((schema.getProperties() != null && !schema.getProperties().isEmpty()) || allOf != null) {
@ -641,7 +641,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
if (result.discriminator != null) { if (result.discriminator != null) {
selfRequired.add(result.discriminator.getPropertyBaseName()); selfRequired.add(result.discriminator.getPropertyBaseName());
} }
Set<String> selfRequiredSet = new HashSet<String>(selfRequired); Set<String> selfRequiredSet = new HashSet<>(selfRequired);
List<CodegenProperty> reqVars = result.getRequiredVars(); List<CodegenProperty> reqVars = result.getRequiredVars();
List<CodegenProperty> reqVarsThatMustBeOptional = new ArrayList<>(); List<CodegenProperty> reqVarsThatMustBeOptional = new ArrayList<>();
@ -668,7 +668,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
protected void addParentContainer(CodegenModel model, String name, Schema schema) { protected void addParentContainer(CodegenModel model, String name, Schema schema) {
super.addParentContainer(model, name, schema); super.addParentContainer(model, name, schema);
List<String> referencedModelNames = new ArrayList<String>(); List<String> referencedModelNames = new ArrayList<>();
model.dataType = getTypeString(schema, "", "", referencedModelNames); model.dataType = getTypeString(schema, "", "", referencedModelNames);
} }
@ -688,7 +688,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
if (cm.requiredVars.size() > 0 && (cm.oneOf.size() > 0 || cm.anyOf.size() > 0)) { if (cm.requiredVars.size() > 0 && (cm.oneOf.size() > 0 || cm.anyOf.size() > 0)) {
fixComposedSchemaRequiredVars(sc, cm); fixComposedSchemaRequiredVars(sc, cm);
} }
ArrayList<List<CodegenProperty>> listOfLists = new ArrayList<List<CodegenProperty>>(); ArrayList<List<CodegenProperty>> listOfLists = new ArrayList<>();
listOfLists.add(cm.requiredVars); listOfLists.add(cm.requiredVars);
listOfLists.add(cm.optionalVars); listOfLists.add(cm.optionalVars);
for (List<CodegenProperty> cpList : listOfLists) { for (List<CodegenProperty> cpList : listOfLists) {
@ -940,7 +940,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
// store it in codegenModel.additionalPropertiesType. // store it in codegenModel.additionalPropertiesType.
// The 'addProps' may be a reference, getTypeDeclaration will resolve // The 'addProps' may be a reference, getTypeDeclaration will resolve
// the reference. // the reference.
List<String> referencedModelNames = new ArrayList<String>(); List<String> referencedModelNames = new ArrayList<>();
getTypeString(addProps, "", "", referencedModelNames); getTypeString(addProps, "", "", referencedModelNames);
if (referencedModelNames.size() != 0) { if (referencedModelNames.size() != 0) {
// Models that are referenced in the 'additionalPropertiesType' keyword // Models that are referenced in the 'additionalPropertiesType' keyword
@ -1235,7 +1235,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
String itemModelName = getModelName(itemSchema); String itemModelName = getModelName(itemSchema);
if (objExample instanceof Iterable && itemModelName == null) { if (objExample instanceof Iterable && itemModelName == null) {
// If the example is already a list, return it directly instead of wrongly wrap it in another list // If the example is already a list, return it directly instead of wrongly wrap it in another list
return fullPrefix + objExample.toString() + closeChars; return fullPrefix + objExample + closeChars;
} }
Set<Schema> newSeenSchemas = new HashSet<>(seenSchemas); Set<Schema> newSeenSchemas = new HashSet<>(seenSchemas);
newSeenSchemas.add(schema); newSeenSchemas.add(schema);
@ -1493,7 +1493,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
protected Map<String, Schema> getModelNameToSchemaCache() { protected Map<String, Schema> getModelNameToSchemaCache() {
if (modelNameToSchemaCache == null) { if (modelNameToSchemaCache == null) {
// Create a cache to efficiently lookup schema based on model name. // Create a cache to efficiently lookup schema based on model name.
Map<String, Schema> m = new HashMap<String, Schema>(); Map<String, Schema> m = new HashMap<>();
ModelUtils.getSchemas(openAPI).forEach((key, schema) -> { ModelUtils.getSchemas(openAPI).forEach((key, schema) -> {
m.put(toModelName(key), schema); m.put(toModelName(key), schema);
}); });

View File

@ -738,7 +738,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
return "\"" + codegenProperty.example + "\""; return "\"" + codegenProperty.example + "\"";
} else { } else {
if (Boolean.TRUE.equals(codegenProperty.isEnum)) { // enum if (Boolean.TRUE.equals(codegenProperty.isEnum)) { // enum
return "\"" + String.valueOf(((List<Object>) codegenProperty.allowableValues.get("values")).get(0)) + "\""; return "\"" + ((List<Object>) codegenProperty.allowableValues.get("values")).get(0) + "\"";
} else { } else {
return "\"" + codegenProperty.name + "_example\""; return "\"" + codegenProperty.name + "_example\"";
} }

View File

@ -124,13 +124,13 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
) )
); );
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"map", "map",
"array") "array")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"i8", "i16", "i32", "i64", "i8", "i16", "i32", "i64",
"u8", "u16", "u32", "u64", "u8", "u16", "u32", "u64",

View File

@ -53,7 +53,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(RustServerCodegen.class); private final Logger LOGGER = LoggerFactory.getLogger(RustServerCodegen.class);
private HashMap<String, String> modelXmlNames = new HashMap<String, String>(); private Map<String, String> modelXmlNames = new HashMap<String, String>();
private static final String NO_FORMAT = "%%NO_FORMAT"; private static final String NO_FORMAT = "%%NO_FORMAT";
@ -160,13 +160,13 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
) )
); );
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList( Arrays.asList(
"map", "map",
"array") "array")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"bool", "bool",
"char", "char",
@ -341,7 +341,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("serverHost", url.getHost()); additionalProperties.put("serverHost", url.getHost());
additionalProperties.put("serverPort", URLPathUtils.getPort(url, serverPort)); additionalProperties.put("serverPort", URLPathUtils.getPort(url, serverPort));
if (packageVersion == null || "".equals(packageVersion)) { if (packageVersion == null || packageVersion.isEmpty()) {
List<String> versionComponents = new ArrayList<>(Arrays.asList(info.getVersion().split("[.]"))); List<String> versionComponents = new ArrayList<>(Arrays.asList(info.getVersion().split("[.]")));
if (versionComponents.size() < 1) { if (versionComponents.size() < 1) {
versionComponents.add("1"); versionComponents.add("1");
@ -1087,7 +1087,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public boolean isDataTypeFile(final String dataType) { public boolean isDataTypeFile(final String dataType) {
return dataType != null && dataType.equals(typeMapping.get("File").toString()); return dataType != null && dataType.equals(typeMapping.get("File"));
} }
/** /**
@ -1176,7 +1176,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
} }
return datatype; return datatype;
} else if (p instanceof FileSchema) { } else if (p instanceof FileSchema) {
return typeMapping.get("File").toString(); return typeMapping.get("File");
} }
return super.getTypeDeclaration(p); return super.getTypeDeclaration(p);
@ -1314,7 +1314,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
// If we have callbacks, add the callbacks module, otherwise remove it // If we have callbacks, add the callbacks module, otherwise remove it
boolean hasCallbacks = haveCallbacks(bundle); boolean hasCallbacks = haveCallbacks(bundle);
bundle.put("hasCallbacks", hasCallbacks); bundle.put("hasCallbacks", hasCallbacks);
SupportingFile[] callbackFiles = new SupportingFile[]{ SupportingFile[] callbackFiles = {
new SupportingFile("client-callbacks.mustache", "src/client", "callbacks.rs"), new SupportingFile("client-callbacks.mustache", "src/client", "callbacks.rs"),
new SupportingFile("server-callbacks.mustache", "src/server", "callbacks.rs"), new SupportingFile("server-callbacks.mustache", "src/server", "callbacks.rs"),
new SupportingFile("example-client-server.mustache", "examples/client", "server.rs") new SupportingFile("example-client-server.mustache", "examples/client", "server.rs")
@ -1674,12 +1674,12 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
Process p = Runtime.getRuntime().exec(new String[]{commandPrefix, file.toString()}); Process p = Runtime.getRuntime().exec(new String[]{commandPrefix, file.toString()});
int exitValue = p.waitFor(); int exitValue = p.waitFor();
if (exitValue != 0) { if (exitValue != 0) {
LOGGER.error("Error running the command ({} {}). Exit code: {}", commandPrefix, file.toString(), exitValue); LOGGER.error("Error running the command ({} {}). Exit code: {}", commandPrefix, file, exitValue);
} else { } else {
LOGGER.info("Successfully executed: {} {}", commandPrefix, file.toString()); LOGGER.info("Successfully executed: {} {}", commandPrefix, file);
} }
} catch (InterruptedException | IOException e) { } catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({} ()). Exception: {}", commandPrefix, file.toString(), e.getMessage()); LOGGER.error("Error running the command ({} ()). Exception: {}", commandPrefix, file, e.getMessage());
// Restore interrupted state // Restore interrupted state
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }

View File

@ -87,7 +87,7 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
"native") "native")
); );
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList("double", Arrays.asList("double",
"Int", "Int",
"Long", "Long",
@ -107,7 +107,7 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
"Map") "Map")
); );
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("string", "String"); typeMapping.put("string", "String");
typeMapping.put("boolean", "Boolean"); typeMapping.put("boolean", "Boolean");
typeMapping.put("integer", "Int"); typeMapping.put("integer", "Int");
@ -158,7 +158,7 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
supportingFiles.add(new SupportingFile("endpoint.mustache", sourceFolder, "endpoint.scala")); supportingFiles.add(new SupportingFile("endpoint.mustache", sourceFolder, "endpoint.scala"));
supportingFiles.add(new SupportingFile("errors.mustache", sourceFolder, "errors.scala")); supportingFiles.add(new SupportingFile("errors.mustache", sourceFolder, "errors.scala"));
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<>(
Arrays.asList( Arrays.asList(
"String", "String",
"Boolean", "Boolean",
@ -175,7 +175,7 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("map", "HashMap"); instantiationTypes.put("map", "HashMap");
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
importMapping.put("UUID", "java.util.UUID"); importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI"); importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File"); importMapping.put("File", "java.io.File");

View File

@ -246,7 +246,7 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
* *
* @param models processed models to be further processed * @param models processed models to be further processed
*/ */
@SuppressWarnings({"unchecked"}) @SuppressWarnings("unchecked")
private void postProcessUpdateImports(final Map<String, Object> models) { private void postProcessUpdateImports(final Map<String, Object> models) {
final String prefix = modelPackage() + "."; final String prefix = modelPackage() + ".";
Map<String, Object> enumRefs = new HashMap<String, Object>(); Map<String, Object> enumRefs = new HashMap<String, Object>();

View File

@ -57,7 +57,7 @@ public class ScalatraServerCodegen extends AbstractScalaCodegen implements Codeg
apiPackage = "org.openapitools.server.api"; apiPackage = "org.openapitools.server.api";
modelPackage = "org.openapitools.server.model"; modelPackage = "org.openapitools.server.model";
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<>(
Arrays.asList("double", Arrays.asList("double",
"Int", "Int",
"Long", "Long",
@ -118,7 +118,7 @@ public class ScalatraServerCodegen extends AbstractScalaCodegen implements Codeg
supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt")); supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
supportingFiles.add(new SupportingFile("sbt", "", "sbt")); supportingFiles.add(new SupportingFile("sbt", "", "sbt"));
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
importMapping.put("UUID", "java.util.UUID"); importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI"); importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File"); importMapping.put("File", "java.io.File");

View File

@ -575,7 +575,7 @@ public class SpringCodegen extends AbstractJavaCodegen
basePath = basePath.substring(0, pos); basePath = basePath.substring(0, pos);
} }
if ("".equals(basePath)) { if (basePath.isEmpty()) {
basePath = "default"; basePath = "default";
} else { } else {
co.subresourceOperation = !co.path.isEmpty(); co.subresourceOperation = !co.path.isEmpty();

View File

@ -67,7 +67,7 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
outputFolder = "docs"; outputFolder = "docs";
embeddedTemplateDir = templateDir = "htmlDocs2"; embeddedTemplateDir = templateDir = "htmlDocs2";
defaultIncludes = new HashSet<String>(); defaultIncludes = new HashSet<>();
cliOptions.add(new CliOption("appName", "short name of the application")); cliOptions.add(new CliOption("appName", "short name of the application"));
cliOptions.add(new CliOption("appDescription", "description of the application")); cliOptions.add(new CliOption("appDescription", "description of the application"));
@ -100,10 +100,10 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
supportingFiles.add(new SupportingFile("index.mustache", "", "index.html")); supportingFiles.add(new SupportingFile("index.mustache", "", "index.html"));
reservedWords = new HashSet<String>(); reservedWords = new HashSet<>();
languageSpecificPrimitives = new HashSet<String>(); languageSpecificPrimitives = new HashSet<>();
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
} }
@Override @Override

View File

@ -54,7 +54,7 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig
outputFolder = "docs"; outputFolder = "docs";
embeddedTemplateDir = templateDir = "htmlDocs"; embeddedTemplateDir = templateDir = "htmlDocs";
defaultIncludes = new HashSet<String>(); defaultIncludes = new HashSet<>();
cliOptions.add(new CliOption("appName", "short name of the application")); cliOptions.add(new CliOption("appName", "short name of the application"));
cliOptions.add(new CliOption("appDescription", "description of the application")); cliOptions.add(new CliOption("appDescription", "description of the application"));
@ -79,10 +79,10 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
supportingFiles.add(new SupportingFile("index.mustache", "", "index.html")); supportingFiles.add(new SupportingFile("index.mustache", "", "index.html"));
reservedWords = new HashSet<String>(); reservedWords = new HashSet<>();
languageSpecificPrimitives = new HashSet<String>(); languageSpecificPrimitives = new HashSet<>();
importMapping = new HashMap<String, String>(); importMapping = new HashMap<>();
} }
/** /**
@ -196,7 +196,7 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig
public String toVarName(String name) { public String toVarName(String name) {
if (reservedWords.contains(name)) { if (reservedWords.contains(name)) {
return escapeReservedWord(name); return escapeReservedWord(name);
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains("" + ((char) character)))) { } else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character)))) {
return escape(name, specialCharReplacements, Arrays.asList("_"), null); return escape(name, specialCharReplacements, Arrays.asList("_"), null);
} else { } else {
return name; return name;

View File

@ -790,7 +790,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
public String toEnumValue(String value, String datatype) { public String toEnumValue(String value, String datatype) {
// for string, array of string // for string, array of string
if ("String".equals(datatype) || "[String]".equals(datatype) || "[String:String]".equals(datatype)) { if ("String".equals(datatype) || "[String]".equals(datatype) || "[String:String]".equals(datatype)) {
return "\"" + String.valueOf(value) + "\""; return "\"" + value + "\"";
} else { } else {
return String.valueOf(value); return String.valueOf(value);
} }
@ -963,7 +963,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
} }
// only process files with swift extension // only process files with swift extension
if ("swift".equals(FilenameUtils.getExtension(file.toString()))) { if ("swift".equals(FilenameUtils.getExtension(file.toString()))) {
String command = swiftPostProcessFile + " " + file.toString(); String command = swiftPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();

View File

@ -735,7 +735,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
// In Java, we need to be creative to get the Timestamp in Microseconds as a long. // In Java, we need to be creative to get the Timestamp in Microseconds as a long.
Instant instant = ((OffsetDateTime) p.getDefault()).toInstant(); Instant instant = ((OffsetDateTime) p.getDefault()).toInstant();
long epochMicro = TimeUnit.SECONDS.toMicros(instant.getEpochSecond()) + (instant.get(ChronoField.MICRO_OF_SECOND)); long epochMicro = TimeUnit.SECONDS.toMicros(instant.getEpochSecond()) + (instant.get(ChronoField.MICRO_OF_SECOND));
return "Date(timeIntervalSince1970: " + String.valueOf(epochMicro) + ".0 / 1_000_000)"; return "Date(timeIntervalSince1970: " + epochMicro + ".0 / 1_000_000)";
} else if (ModelUtils.isStringSchema(p)) { } else if (ModelUtils.isStringSchema(p)) {
return "\"" + escapeText((String) p.getDefault()) + "\""; return "\"" + escapeText((String) p.getDefault()) + "\"";
} }
@ -955,7 +955,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
public String toEnumValue(String value, String datatype) { public String toEnumValue(String value, String datatype) {
// for string, array of string // for string, array of string
if ("String".equals(datatype) || "[String]".equals(datatype) || "[String: String]".equals(datatype)) { if ("String".equals(datatype) || "[String]".equals(datatype) || "[String: String]".equals(datatype)) {
return "\"" + String.valueOf(value) + "\""; return "\"" + value + "\"";
} else { } else {
return String.valueOf(value); return String.valueOf(value);
} }
@ -1115,7 +1115,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
} }
// only process files with swift extension // only process files with swift extension
if ("swift".equals(FilenameUtils.getExtension(file.toString()))) { if ("swift".equals(FilenameUtils.getExtension(file.toString()))) {
String command = swiftPostProcessFile + " " + file.toString(); String command = swiftPostProcessFile + " " + file;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor(); int exitValue = p.waitFor();
@ -1146,7 +1146,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation"); List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
for (CodegenOperation operation : operations) { for (CodegenOperation operation : operations) {
for (CodegenParameter cp : operation.allParams) { for (CodegenParameter cp : operation.allParams) {
cp.vendorExtensions.put("x-swift-example", constructExampleCode(cp, modelMaps, new HashSet<String>())); cp.vendorExtensions.put("x-swift-example", constructExampleCode(cp, modelMaps, new HashSet<>()));
} }
} }
return objs; return objs;

View File

@ -577,7 +577,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
* Parse imports * Parse imports
*/ */
private Set<String> parseImports(CodegenModel cm) { private Set<String> parseImports(CodegenModel cm) {
Set<String> newImports = new HashSet<String>(); Set<String> newImports = new HashSet<>();
if (cm.imports.size() > 0) { if (cm.imports.size() > 0) {
for (String name : cm.imports) { for (String name : cm.imports) {
if (name.indexOf(" | ") >= 0) { if (name.indexOf(" | ") >= 0) {

View File

@ -146,13 +146,13 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
"Map" "Map"
)); ));
languageGenericTypes = new HashSet<String>(Arrays.asList( languageGenericTypes = new HashSet<>(Arrays.asList(
"Array" "Array"
)); ));
instantiationTypes.put("array", "Array"); instantiationTypes.put("array", "Array");
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<>();
typeMapping.put("Array", "Array"); typeMapping.put("Array", "Array");
typeMapping.put("array", "Array"); typeMapping.put("array", "Array");
typeMapping.put("List", "Array"); typeMapping.put("List", "Array");
@ -185,7 +185,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package. If not provided, using the version from the OpenAPI specification file.").defaultValue(this.getNpmVersion())); cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package. If not provided, using the version from the OpenAPI specification file.").defaultValue(this.getNpmVersion()));
cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
cliOptions.add(CliOption.newBoolean(SNAPSHOT, cliOptions.add(CliOption.newBoolean(SNAPSHOT,
"When setting this property to true, the version will be suffixed with -SNAPSHOT." + this.SNAPSHOT_SUFFIX_FORMAT.get().toPattern(), "When setting this property to true, the version will be suffixed with -SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.get().toPattern(),
false)); false));
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase")); cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase"));
@ -339,7 +339,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
* @return TypeScript return type * @return TypeScript return type
*/ */
private String getReturnType(List<CodegenResponse> responses) { private String getReturnType(List<CodegenResponse> responses) {
Set<String> returnTypes = new HashSet<String>(); Set<String> returnTypes = new HashSet<>();
for (CodegenResponse response: responses) { for (CodegenResponse response: responses) {
if (response.is2xx) { if (response.is2xx) {
if (response.dataType != null) { if (response.dataType != null) {
@ -424,7 +424,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
} }
protected String toTypescriptTypeName(final String name, String safePrefix) { protected String toTypescriptTypeName(final String name, String safePrefix) {
ArrayList<String> exceptions = new ArrayList<String>(Arrays.asList("\\|", " ")); ArrayList<String> exceptions = new ArrayList<>(Arrays.asList("\\|", " "));
String sanName = sanitizeName(name, "(?![| ])\\W", exceptions); String sanName = sanitizeName(name, "(?![| ])\\W", exceptions);
sanName = camelize(sanName); sanName = camelize(sanName);
@ -507,7 +507,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
if (!isFirst) { if (!isFirst) {
b.append(" | "); b.append(" | ");
} }
b.append(toEnumValue(value.toString(), dataType)); b.append(toEnumValue(value, dataType));
isFirst = false; isFirst = false;
} }
return b.toString(); return b.toString();
@ -1220,7 +1220,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
String itemModelName = getModelName(itemSchema); String itemModelName = getModelName(itemSchema);
if (objExample instanceof Iterable && itemModelName == null) { if (objExample instanceof Iterable && itemModelName == null) {
// If the example is already a list, return it directly instead of wrongly wrap it in another list // If the example is already a list, return it directly instead of wrongly wrap it in another list
return fullPrefix + objExample.toString() + closeChars; return fullPrefix + objExample + closeChars;
} }
Set<Schema> newSeenSchemas = new HashSet<>(seenSchemas); Set<Schema> newSeenSchemas = new HashSet<>(seenSchemas);
newSeenSchemas.add(schema); newSeenSchemas.add(schema);

View File

@ -186,8 +186,8 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
} }
return "id".equals(name) || return "id".equals(name) ||
"ids".equals(name) || "ids".equals(name) ||
(name.length() >= 3 && name.substring(name.length() - 2).equals("Id")) || (name.length() >= 3 && name.endsWith("Id")) ||
(name.length() >= 4 && name.substring(name.length() - 3).equals("Ids")); (name.length() >= 4 && name.endsWith("Ids"));
} }
@Override @Override
@ -488,7 +488,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
op.returnPassthrough = null; op.returnPassthrough = null;
} }
} }
} else if (this.getDetectPassthroughModelsWithSuffixAndField() != null && op.returnBaseType.length() > this.getPassthroughSuffix().length() && op.returnBaseType.substring(op.returnBaseType.length() - this.getPassthroughSuffix().length()).equals(this.getPassthroughSuffix())) { } else if (this.getDetectPassthroughModelsWithSuffixAndField() != null && op.returnBaseType.length() > this.getPassthroughSuffix().length() && op.returnBaseType.endsWith(this.getPassthroughSuffix())) {
boolean foundMatch = false; boolean foundMatch = false;
for (CodegenProperty var : cm.vars) { for (CodegenProperty var : cm.vars) {
if (var.name.equals(this.getPassthroughField())) { if (var.name.equals(this.getPassthroughField())) {
@ -635,7 +635,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
cm.returnPassthrough = null; cm.returnPassthrough = null;
} }
} }
} else if (this.getDetectPassthroughModelsWithSuffixAndField() != null && cm.name.length() > this.getPassthroughSuffix().length() && cm.name.substring(cm.name.length() - this.getPassthroughSuffix().length()).equals(this.getPassthroughSuffix())) { } else if (this.getDetectPassthroughModelsWithSuffixAndField() != null && cm.name.length() > this.getPassthroughSuffix().length() && cm.name.endsWith(this.getPassthroughSuffix())) {
boolean foundMatch = false; boolean foundMatch = false;
for (CodegenProperty var : cm.vars) { for (CodegenProperty var : cm.vars) {
if (var.name.equals(this.getPassthroughField())) { if (var.name.equals(this.getPassthroughField())) {

View File

@ -387,14 +387,12 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
* Parse imports * Parse imports
*/ */
private Set<String> parseImports(CodegenModel cm) { private Set<String> parseImports(CodegenModel cm) {
Set<String> newImports = new HashSet<String>(); Set<String> newImports = new HashSet<>();
if (cm.imports.size() > 0) { if (cm.imports.size() > 0) {
for (String name : cm.imports) { for (String name : cm.imports) {
if (name.indexOf(" | ") >= 0) { if (name.indexOf(" | ") >= 0) {
String[] parts = name.split(" \\| "); String[] parts = name.split(" \\| ");
for (String s : parts) { newImports.addAll(Arrays.asList(parts));
newImports.add(s);
}
} else { } else {
newImports.add(name); newImports.add(name);
} }

View File

@ -103,7 +103,7 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
@Override @Override
protected void handleMethodResponse(Operation operation, Map<String, Schema> schemas, CodegenOperation op, protected void handleMethodResponse(Operation operation, Map<String, Schema> schemas, CodegenOperation op,
ApiResponse methodResponse) { ApiResponse methodResponse) {
handleMethodResponse(operation, schemas, op, methodResponse, Collections.<String, String>emptyMap()); handleMethodResponse(operation, schemas, op, methodResponse, Collections.emptyMap());
} }
@Override @Override

View File

@ -42,10 +42,10 @@ import java.util.Map;
public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter { public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
final Logger LOGGER = LoggerFactory.getLogger(HandlebarsEngineAdapter.class); final Logger LOGGER = LoggerFactory.getLogger(HandlebarsEngineAdapter.class);
private final String[] extensions = new String[]{"handlebars", "hbs"}; private final String[] extensions = {"handlebars", "hbs"};
// We use this as a simple lookup for valid file name extensions. This adapter will inspect .mustache (built-in) and infer the relevant handlebars filename // We use this as a simple lookup for valid file name extensions. This adapter will inspect .mustache (built-in) and infer the relevant handlebars filename
private final String[] canCompileFromExtensions = new String[]{".handlebars",".hbs",".mustache"}; private final String[] canCompileFromExtensions = {".handlebars",".hbs",".mustache"};
private boolean infiniteLoops = false; private boolean infiniteLoops = false;
private boolean prettyPrint = false; private boolean prettyPrint = false;
@ -92,7 +92,7 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
return tmpl.apply(context); return tmpl.apply(context);
} }
@SuppressWarnings({"java:S108"}) @SuppressWarnings("java:S108")
public TemplateSource findTemplate(TemplatingExecutor generator, String templateFile) { public TemplateSource findTemplate(TemplatingExecutor generator, String templateFile) {
String[] possibilities = getModifiedFileLocation(templateFile); String[] possibilities = getModifiedFileLocation(templateFile);
for (String file : possibilities) { for (String file : possibilities) {

View File

@ -43,7 +43,7 @@ public class MustacheEngineAdapter implements TemplatingEngineAdapter {
return "mustache"; return "mustache";
} }
private final String[] extensions = new String[]{"mustache"}; private final String[] extensions = {"mustache"};
Mustache.Compiler compiler = Mustache.compiler(); Mustache.Compiler compiler = Mustache.compiler();
/** /**
@ -65,7 +65,7 @@ public class MustacheEngineAdapter implements TemplatingEngineAdapter {
return tmpl.execute(bundle); return tmpl.execute(bundle);
} }
@SuppressWarnings({"java:S108"}) // catch-all is expected, and is later thrown @SuppressWarnings("java:S108") // catch-all is expected, and is later thrown
public Reader findTemplate(TemplatingExecutor generator, String name) { public Reader findTemplate(TemplatingExecutor generator, String name) {
for (String extension : extensions) { for (String extension : extensions) {
final String templateName = name + "." + extension; final String templateName = name + "." + extension;

View File

@ -1073,7 +1073,7 @@ public class ModelUtils {
*/ */
public static Schema unaliasSchema(OpenAPI openAPI, public static Schema unaliasSchema(OpenAPI openAPI,
Schema schema) { Schema schema) {
return unaliasSchema(openAPI, schema, Collections.<String, String>emptyMap()); return unaliasSchema(openAPI, schema, Collections.emptyMap());
} }
/** /**
@ -1258,7 +1258,7 @@ public class ModelUtils {
} else if (composed.getOneOf() != null && !composed.getOneOf().isEmpty()) { } else if (composed.getOneOf() != null && !composed.getOneOf().isEmpty()) {
return composed.getOneOf(); return composed.getOneOf();
} else { } else {
return Collections.<Schema>emptyList(); return Collections.emptyList();
} }
} }

View File

@ -119,10 +119,7 @@ public class OneOfImplementorAdditionalData {
} }
// Add oneOf-containing models properties - we need to properly set the hasMore values to make rendering correct // Add oneOf-containing models properties - we need to properly set the hasMore values to make rendering correct
for (int i = 0; i < additionalProps.size(); i++) { implcm.vars.addAll(additionalProps);
CodegenProperty var = additionalProps.get(i);
implcm.vars.add(var);
}
// Add imports // Add imports
for (Map<String, String> oneImport : additionalImports) { for (Map<String, String> oneImport : additionalImports) {

View File

@ -153,7 +153,7 @@ public class StringUtils {
m = camelizeSlashPattern.matcher(word); m = camelizeSlashPattern.matcher(word);
while (m.find()) { while (m.find()) {
word = m.replaceFirst("" + Character.toUpperCase(m.group(1).charAt(0)) + m.group(1).substring(1)/*.toUpperCase()*/); word = m.replaceFirst(Character.toUpperCase(m.group(1).charAt(0)) + m.group(1).substring(1)/*.toUpperCase()*/);
m = camelizeSlashPattern.matcher(word); m = camelizeSlashPattern.matcher(word);
} }
@ -256,7 +256,7 @@ public class StringUtils {
EscapedNameOptions ns = new EscapedNameOptions(name, replacementMap.keySet(), charactersToAllow, appendToReplacement); EscapedNameOptions ns = new EscapedNameOptions(name, replacementMap.keySet(), charactersToAllow, appendToReplacement);
return escapedWordsCache.get(ns, wordToEscape -> { return escapedWordsCache.get(ns, wordToEscape -> {
String result = name.chars().mapToObj(c -> { String result = name.chars().mapToObj(c -> {
String character = "" + (char) c; String character = String.valueOf((char) c);
if (charactersToAllow != null && charactersToAllow.contains(character)) { if (charactersToAllow != null && charactersToAllow.contains(character)) {
return character; return character;
} else if (replacementMap.containsKey(character)) { } else if (replacementMap.containsKey(character)) {
@ -264,7 +264,7 @@ public class StringUtils {
} else { } else {
return character; return character;
} }
}).reduce( (c1, c2) -> "" + c1 + c2).orElse(null); }).reduce( (c1, c2) -> c1 + c2).orElse(null);
if (result != null) return result; if (result != null) return result;
throw new RuntimeException("Word '" + name + "' could not be escaped."); throw new RuntimeException("Word '" + name + "' could not be escaped.");

View File

@ -2425,7 +2425,7 @@ public class DefaultCodegenTest {
Schema sc = openAPI.getComponents().getSchemas().get(modelName); Schema sc = openAPI.getComponents().getSchemas().get(modelName);
CodegenModel cm = codegen.fromModel(modelName, sc); CodegenModel cm = codegen.fromModel(modelName, sc);
final Set<CodegenDiscriminator.MappedModel> expectedMappedModels = new HashSet<>(Arrays.asList(new CodegenDiscriminator.MappedModel("UserSleep", "UserSleep"))); final Set<CodegenDiscriminator.MappedModel> expectedMappedModels = Sets.newHashSet(new CodegenDiscriminator.MappedModel("UserSleep", "UserSleep"));
final Set<CodegenDiscriminator.MappedModel> mappedModels = cm.getDiscriminator().getMappedModels(); final Set<CodegenDiscriminator.MappedModel> mappedModels = cm.getDiscriminator().getMappedModels();
assertEquals(mappedModels, expectedMappedModels); assertEquals(mappedModels, expectedMappedModels);

View File

@ -116,12 +116,12 @@ public class TestUtils {
public static void ensureContainsFile(List<File> generatedFiles, File root, String filename) { public static void ensureContainsFile(List<File> generatedFiles, File root, String filename) {
Path path = root.toPath().resolve(filename); Path path = root.toPath().resolve(filename);
assertTrue(generatedFiles.contains(path.toFile()), "File '" + path.toAbsolutePath().toString() + "' was not found in the list of generated files"); assertTrue(generatedFiles.contains(path.toFile()), "File '" + path.toAbsolutePath() + "' was not found in the list of generated files");
} }
public static void ensureDoesNotContainsFile(List<File> generatedFiles, File root, String filename) { public static void ensureDoesNotContainsFile(List<File> generatedFiles, File root, String filename) {
Path path = root.toPath().resolve(filename); Path path = root.toPath().resolve(filename);
assertFalse(generatedFiles.contains(path.toFile()), "File '" + path.toAbsolutePath().toString() + "' was found in the list of generated files"); assertFalse(generatedFiles.contains(path.toFile()), "File '" + path.toAbsolutePath() + "' was found in the list of generated files");
} }
public static void validateJavaSourceFiles(Map<String, String> fileMap) { public static void validateJavaSourceFiles(Map<String, String> fileMap) {
@ -167,7 +167,7 @@ public class TestUtils {
for (String line : lines) for (String line : lines)
assertTrue(file.contains(linearize(line)), "File does not contain line [" + line + "]"); assertTrue(file.contains(linearize(line)), "File does not contain line [" + line + "]");
} catch (IOException e) { } catch (IOException e) {
fail("Unable to evaluate file " + path.toString()); fail("Unable to evaluate file " + path);
} }
} }
@ -180,7 +180,7 @@ public class TestUtils {
try { try {
generatedFile = new String(Files.readAllBytes(path), StandardCharsets.UTF_8); generatedFile = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
} catch (IOException e) { } catch (IOException e) {
fail("Unable to evaluate file " + path.toString()); fail("Unable to evaluate file " + path);
} }
String file = linearize(generatedFile); String file = linearize(generatedFile);
assertNotNull(file); assertNotNull(file);

Some files were not shown because too many files have changed in this diff Show More