Skip to content

Commit

Permalink
fix string comparison (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed May 9, 2018
1 parent 3608a14 commit 9ecd358
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
import java.io.IOException;
import java.io.Writer;

import org.apache.commons.lang3.StringUtils;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;


public class AdaCodegen extends AbstractAdaCodegen implements CodegenConfig {

Expand Down Expand Up @@ -54,7 +53,7 @@ public void processOpts() {
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
packageName = (String) additionalProperties.get(CodegenConstants.PACKAGE_NAME);
}
if (packageName == "") {
if (StringUtils.isEmpty(packageName)) {
packageName = modelPackage;
}
String srcPrefix = "src" + File.separator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
if (response != null) {
CodegenProperty cm = fromProperty("response", response);
op.vendorExtensions.put("x-codegen-response", cm);
if (cm.datatype == "HttpContent") {
if ("HttpContent".equals(cm.datatype)) {
op.vendorExtensions.put("x-codegen-response-ishttpcontent", true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public CppQt5ClientCodegen() {
outputFolder = "generated-code/qt5cpp";

// set modelNamePrefix as default for QT5CPP
if ("".equals(modelNamePrefix)) {
if (StringUtils.isEmpty(modelNamePrefix)) {
modelNamePrefix = PREFIX;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
if (response != null) {
CodegenProperty cm = fromProperty("response", response);
op.vendorExtensions.put("x-codegen-response", cm);
if (cm.datatype == "HttpContent") {
if ("HttpContent".equals(cm.datatype)) {
op.vendorExtensions.put("x-codegen-response-ishttpcontent", true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public String escapeReservedWord(String name) {
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if ("".equals(operationId)) {
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.swagger.v3.oas.models.Operation;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
Expand Down Expand Up @@ -107,7 +108,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
basePath = basePath.substring(0, pos);
}

if (basePath == "") {
if (StringUtils.isEmpty(basePath)) {
basePath = "default";
} else {
if (co.path.startsWith("/" + basePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import io.swagger.v3.oas.models.Operation;

import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
Expand Down Expand Up @@ -147,7 +148,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
basePath = basePath.substring(0, pos);
}

if (basePath == "") {
if (StringUtils.isEmpty(basePath)) {
basePath = "default";
} else {
if (co.path.startsWith("/" + basePath)) {
Expand All @@ -156,7 +157,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
co.subresourceOperation = !co.path.isEmpty();
}
List<CodegenOperation> opList = operations.get(basePath);
if (opList == null) {
if (opList == null || opList.isEmpty()) {
opList = new ArrayList<CodegenOperation>();
operations.put(basePath, opList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.openapitools.codegen.languages;

import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import io.swagger.v3.oas.models.*;

import java.util.*;
Expand Down Expand Up @@ -171,7 +170,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
basePath = basePath.substring(0, pos);
}

if (basePath == "") {
if (StringUtils.isEmpty(basePath)) {
basePath = "default";
} else {
if (co.path.startsWith("/" + basePath)) {
Expand All @@ -180,7 +179,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
co.subresourceOperation = !co.path.isEmpty();
}
List<CodegenOperation> opList = operations.get(basePath);
if (opList == null) {
if (opList == null || opList.isEmpty()) {
opList = new ArrayList<CodegenOperation>();
operations.put(basePath, opList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
basePath = basePath.substring(0, pos);
}

if (basePath == "") {
if (StringUtils.isEmpty(basePath)) {
basePath = "default";
} else {
if (co.path.startsWith("/" + basePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
basePath = basePath.substring(0, pos);
}

if (basePath == "") {
if (StringUtils.isEmpty("")) {
basePath = "default";
} else {
if (co.path.startsWith("/" + basePath)) {
Expand All @@ -135,7 +135,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
co.subresourceOperation = !co.path.isEmpty();
}
List<CodegenOperation> opList = operations.get(basePath);
if (opList == null) {
if (opList == null || opList.isEmpty()) {
opList = new ArrayList<CodegenOperation>();
operations.put(basePath, opList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.openapitools.codegen.languages;

import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.JbossFeature;
import io.swagger.v3.oas.models.*;
import org.apache.commons.lang3.BooleanUtils;
Expand Down Expand Up @@ -129,7 +128,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
basePath = basePath.substring(0, pos);
}

if (basePath == "") {
if (StringUtils.isEmpty(basePath)) {
basePath = "default";
} else {
if (co.path.startsWith("/" + basePath)) {
Expand All @@ -138,7 +137,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
co.subresourceOperation = !co.path.isEmpty();
}
List<CodegenOperation> opList = operations.get(basePath);
if (opList == null) {
if (opList == null || opList.isEmpty()) {
opList = new ArrayList<CodegenOperation>();
operations.put(basePath, opList);
}
Expand Down

0 comments on commit 9ecd358

Please sign in to comment.