replace tab with 4-space in restbed class

This commit is contained in:
wing328 2017-07-11 21:57:00 +08:00
parent f2f303b2e8
commit 74b0c04b2f

View File

@ -227,52 +227,52 @@ public class RestbedCodegen extends AbstractCppCodegen {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) { public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
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<CodegenOperation>();
for (CodegenOperation op : operationList) { for (CodegenOperation op : operationList) {
String path = new String(op.path); String path = new String(op.path);
String[] items = path.split("/", -1); String[] items = path.split("/", -1);
String resourceNameCamelCase = ""; String resourceNameCamelCase = "";
op.path = ""; op.path = "";
for (String item: items) { for (String item: items) {
if (item.length() > 1) { if (item.length() > 1) {
if (item.matches("^\\{(.*)\\}$")) { if (item.matches("^\\{(.*)\\}$")) {
String tmpResourceName = item.substring(1, item.length()-1); String tmpResourceName = item.substring(1, item.length()-1);
resourceNameCamelCase += Character.toUpperCase(tmpResourceName.charAt(0)) + tmpResourceName.substring(1); resourceNameCamelCase += Character.toUpperCase(tmpResourceName.charAt(0)) + tmpResourceName.substring(1);
item = item.substring(0, item.length()-1); item = item.substring(0, item.length()-1);
item += ": .*}"; item += ": .*}";
} else { } else {
resourceNameCamelCase += Character.toUpperCase(item.charAt(0)) + item.substring(1); resourceNameCamelCase += Character.toUpperCase(item.charAt(0)) + item.substring(1);
}
} else if (item.length() == 1) {
resourceNameCamelCase += Character.toUpperCase(item.charAt(0));
}
op.path += item + "/";
} }
} else if (item.length() == 1) { op.vendorExtensions.put("x-codegen-resourceName", resourceNameCamelCase);
resourceNameCamelCase += Character.toUpperCase(item.charAt(0)); boolean foundInNewList = false;
} for (CodegenOperation op1 : newOpList) {
op.path += item + "/"; if (!foundInNewList) {
} if (op1.path.equals(op.path)) {
op.vendorExtensions.put("x-codegen-resourceName", resourceNameCamelCase); foundInNewList = true;
boolean foundInNewList = false; List<CodegenOperation> currentOtherMethodList = (List<CodegenOperation>) op1.vendorExtensions.get("x-codegen-otherMethods");
for (CodegenOperation op1 : newOpList) { if (currentOtherMethodList == null) {
if (!foundInNewList) { currentOtherMethodList = new ArrayList<CodegenOperation>();
if (op1.path.equals(op.path)) { }
foundInNewList = true; op.operationIdCamelCase = op1.operationIdCamelCase;
List<CodegenOperation> currentOtherMethodList = (List<CodegenOperation>) op1.vendorExtensions.get("x-codegen-otherMethods"); currentOtherMethodList.add(op);
if (currentOtherMethodList == null) { op1.vendorExtensions.put("x-codegen-otherMethods", currentOtherMethodList);
currentOtherMethodList = new ArrayList<CodegenOperation>(); }
} }
op.operationIdCamelCase = op1.operationIdCamelCase; }
currentOtherMethodList.add(op); if (!foundInNewList) {
op1.vendorExtensions.put("x-codegen-otherMethods", currentOtherMethodList); newOpList.add(op);
} }
}
} }
if (!foundInNewList) { operations.put("operation", newOpList);
newOpList.add(op); return objs;
}
}
operations.put("operation", newOpList);
return objs;
} }
/** /**