include underscore when generating nodejs controller and service method

This commit is contained in:
kolyjjj 2016-04-20 18:32:14 +08:00
parent 2af29fa831
commit fe704eee1f
2 changed files with 14 additions and 5 deletions

View File

@ -2319,18 +2319,21 @@ public class DefaultCodegen {
*/ */
@SuppressWarnings("static-method") @SuppressWarnings("static-method")
public String removeNonNameElementToCamelCase(String name) { public String removeNonNameElementToCamelCase(String name) {
String nonNameElementPattern = "[-_:;#]"; return removeNonNameElementToCamelCase(name, "[-_:;#]");
name = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() { // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. }
protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) {
String result = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() {
@Nullable @Nullable
@Override @Override
public String apply(String input) { public String apply(String input) {
return StringUtils.capitalize(input); return StringUtils.capitalize(input);
} }
}), ""); }), "");
if (name.length() > 0) { if (result.length() > 0) {
name = name.substring(0, 1).toLowerCase() + name.substring(1); result = result.substring(0, 1).toLowerCase() + result.substring(1);
} }
return name; return result;
} }
/** /**

View File

@ -314,4 +314,10 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
} }
return super.postProcessSupportingFileData(objs); return super.postProcessSupportingFileData(objs);
} }
@Override
public String removeNonNameElementToCamelCase(String name) {
return removeNonNameElementToCamelCase(name, "[-:;#]");
}
} }