[Java] fix bugs when property name, datatype are the same (#12581)

* fix bugs when property name, datatype are the same

* add null check

* add Locale.ROOT
This commit is contained in:
William Cheng
2022-06-12 22:36:10 +08:00
committed by GitHub
parent c2595335c3
commit cdc2d92609

View File

@@ -1330,6 +1330,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
if (property.isReadOnly) {
model.getVendorExtensions().put("x-has-readonly-properties", true);
}
// if data type happens to be the same as the property name and both are upper case
if (property.dataType != null && property.dataType.equals(property.name) && property.dataType.toUpperCase(Locale.ROOT).equals(property.name)) {
property.name = property.name.toLowerCase(Locale.ROOT);
}
}
@Override