File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
openapi-processor-core/src
main/kotlin/io/openapiprocessor/core/writer/java
testInt/resources/tests/keyword-identifier/generated/model Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -219,7 +219,7 @@ class DataTypeWriterPojo(
219219 result + = ifDeprecated(propDataType)
220220
221221 result + = """
222- | public ${propDataType.getTypeName()} get${propertyName.capitalizeFirstChar()} () {
222+ | public ${propDataType.getTypeName()} get${toAccessor( propertyName.capitalizeFirstChar() )} () {
223223 | return ${toIdentifier(propertyName)} ;
224224 | }
225225 |
@@ -236,7 +236,7 @@ class DataTypeWriterPojo(
236236 val property = toIdentifier(propertyName)
237237
238238 result + = """
239- | public void set${propertyName.capitalizeFirstChar()} (${propDataType.getTypeName()} ${property} ) {
239+ | public void set${toAccessor( propertyName.capitalizeFirstChar() )} (${propDataType.getTypeName()} ${property} ) {
240240 | this.${property} = ${property} ;
241241 | }
242242 |
Original file line number Diff line number Diff line change @@ -51,6 +51,20 @@ fun toIdentifier(src: String): String {
5151 return identifier
5252}
5353
54+ /* *
55+ * convert an invalid property accessor to a valid property accessor by adding an "A" prefix.
56+ * This is used to avoid generating a getClass() method that conflicts with Object::getClass().
57+ *
58+ * @param src the source property name without get/set prefix
59+ * @return a valid accessor name without get/set prefix
60+ */
61+ fun toAccessor (src : String ): String {
62+ return when (src) {
63+ " Class" -> " AClass"
64+ else -> src
65+ }
66+ }
67+
5468/* *
5569 * converts a source string to a valid (camel case) java *class* identifier. One way, ie it is
5670 * not reversible.
@@ -82,7 +96,6 @@ fun toClass(src: String): String {
8296 * All words are converted to uppercase and joined by an underscore.
8397 *
8498 * @param src the source "string"
85- *
8699 * @return a valid upper case enum java identifier
87100 */
88101fun toEnum (src : String ): String {
Original file line number Diff line number Diff line change @@ -9,11 +9,11 @@ public class Class {
99 @ JsonProperty ("class" )
1010 private String aClass ;
1111
12- public String getClass () {
12+ public String getAClass () {
1313 return aClass ;
1414 }
1515
16- public void setClass (String aClass ) {
16+ public void setAClass (String aClass ) {
1717 this .aClass = aClass ;
1818 }
1919
You can’t perform that action at this time.
0 commit comments