better symbol mapping for enum name

This commit is contained in:
wing328 2016-08-05 11:28:07 +08:00
parent 89fe3403a7
commit 122af80881
3 changed files with 6 additions and 6 deletions

View File

@ -804,10 +804,12 @@ public class DefaultCodegen {
specialCharReplacements.put(":", "Colon");
specialCharReplacements.put(">", "Greater_Than");
specialCharReplacements.put("<", "Less_Than");
specialCharReplacements.put(".", "Period");
specialCharReplacements.put("_", "Underscore");
specialCharReplacements.put("<=", "Less_Than_Or_Equal_To");
specialCharReplacements.put(">=", "Greater_Than_Or_Equal_To");
specialCharReplacements.put("!=", "Greater_Than_Or_Equal_To");
specialCharReplacements.put("!=", "Not_Equal");
}
/**

View File

@ -184,12 +184,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen {
model.imports.add("SerializedName");
}
} else { // enum class
//Needed imports for Jackson based libraries
//Needed imports for Jackson's JsonCreator
if(additionalProperties.containsKey("jackson")) {
model.imports.add("JsonCreator");
model.imports.add("JsonProperty");
}
model.imports.add("JsonCreator");
}
}

View File

@ -27,9 +27,9 @@ public class AbstractJavaCodegenTest {
@Test
public void toEnumVarNameShouldNotShortenUnderScore() throws Exception {
Assert.assertEquals("_", fakeJavaCodegen.toEnumVarName("_", "String"));
Assert.assertEquals("UNDERSCORE", fakeJavaCodegen.toEnumVarName("_", "String"));
Assert.assertEquals("__", fakeJavaCodegen.toEnumVarName("__", "String"));
Assert.assertEquals("__", fakeJavaCodegen.toEnumVarName("_,.", "String"));
}
}
}