Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid naming clashes in code generation #415

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/joda/beans/gen/BeanGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,9 @@ private void generateEquals() {
var prop = nonDerived.get(i);
var getter = equalsHashCodeFieldAccessor(prop);
data.ensureImport(JodaBeanUtils.class);
var equals = "JodaBeanUtils.equal(" + getter + ", other." + getter + ")";
var equals = "JodaBeanUtils.equal(this." + getter + ", other." + getter + ")";
if (PRIMITIVE_EQUALS.contains(prop.getData().getType())) {
equals = "(" + getter + " == other." + getter + ")";
equals = "(this." + getter + " == other." + getter + ")";
}
addLine(
0, (i == 0 ? "\t\t\treturn " : "\t\t\t\t\t") + equals +
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/joda/beans/gen/PropertyGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ List<String> generateMetaPropertyGetCase() {
if (data.getAlias() != null) {
list.add("\t\t\t\tcase " + data.getAlias().hashCode() + ": // " + data.getAlias() + " (alias)");
}
list.add("\t\t\t\t\treturn " + data.getMetaFieldName() + ";");
list.add("\t\t\t\t\treturn this." + data.getMetaFieldName() + ";");
return list;
}

Expand Down Expand Up @@ -204,7 +204,7 @@ List<String> generateBuilderFieldGet() {
if (data.getAlias() != null) {
list.add("\t\t\t\tcase " + data.getAlias().hashCode() + ": // " + data.getAlias() + " (alias)");
}
list.add("\t\t\t\t\treturn " + generateBuilderFieldName() + ";");
list.add("\t\t\t\t\treturn this." + generateBuilderFieldName() + ";");
return list;
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/joda/beans/sample/AbstractResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
AbstractResult<?> other = (AbstractResult<?>) obj;
return JodaBeanUtils.equal(getDocs(), other.getDocs());
return JodaBeanUtils.equal(this.getDocs(), other.getDocs());
}
return false;
}
Expand Down Expand Up @@ -196,9 +196,9 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 3088955: // docs
return docs;
return this.docs;
case -571837193: // resultType
return resultType;
return this.resultType;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/org/joda/beans/sample/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
Address other = (Address) obj;
return (getNumber() == other.getNumber()) &&
JodaBeanUtils.equal(getStreet(), other.getStreet()) &&
JodaBeanUtils.equal(getCity(), other.getCity()) &&
JodaBeanUtils.equal(getOwner(), other.getOwner());
return (this.getNumber() == other.getNumber()) &&
JodaBeanUtils.equal(this.getStreet(), other.getStreet()) &&
JodaBeanUtils.equal(this.getCity(), other.getCity()) &&
JodaBeanUtils.equal(this.getOwner(), other.getOwner());
}
return false;
}
Expand Down Expand Up @@ -281,13 +281,13 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -1034364087: // number
return number;
return this.number;
case -891990013: // street
return street;
return this.street;
case 3053931: // city
return city;
return this.city;
case 106164915: // owner
return owner;
return this.owner;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
32 changes: 16 additions & 16 deletions src/test/java/org/joda/beans/sample/ClonePerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,14 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
ClonePerson other = (ClonePerson) obj;
return JodaBeanUtils.equal(getFirstNames(), other.getFirstNames()) &&
JodaBeanUtils.equal(getMiddleNames(), other.getMiddleNames()) &&
JodaBeanUtils.equal(getSurname(), other.getSurname()) &&
JodaBeanUtils.equal(getDateOfBirth(), other.getDateOfBirth()) &&
JodaBeanUtils.equal(getDateOfDeath(), other.getDateOfDeath()) &&
JodaBeanUtils.equal(getAddresses(), other.getAddresses()) &&
JodaBeanUtils.equal(getCompanies(), other.getCompanies()) &&
JodaBeanUtils.equal(getAmounts(), other.getAmounts());
return JodaBeanUtils.equal(this.getFirstNames(), other.getFirstNames()) &&
JodaBeanUtils.equal(this.getMiddleNames(), other.getMiddleNames()) &&
JodaBeanUtils.equal(this.getSurname(), other.getSurname()) &&
JodaBeanUtils.equal(this.getDateOfBirth(), other.getDateOfBirth()) &&
JodaBeanUtils.equal(this.getDateOfDeath(), other.getDateOfDeath()) &&
JodaBeanUtils.equal(this.getAddresses(), other.getAddresses()) &&
JodaBeanUtils.equal(this.getCompanies(), other.getCompanies()) &&
JodaBeanUtils.equal(this.getAmounts(), other.getAmounts());
}
return false;
}
Expand Down Expand Up @@ -425,21 +425,21 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -177061256: // firstNames
return firstNames;
return this.firstNames;
case 404996787: // middleNames
return middleNames;
return this.middleNames;
case -1852993317: // surname
return surname;
return this.surname;
case -386871910: // dateOfBirth
return dateOfBirth;
return this.dateOfBirth;
case -385160369: // dateOfDeath
return dateOfDeath;
return this.dateOfDeath;
case 874544034: // addresses
return addresses;
return this.addresses;
case -1412832805: // companies
return companies;
return this.companies;
case -879772901: // amounts
return amounts;
return this.amounts;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/joda/beans/sample/Company.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
Company other = (Company) obj;
return JodaBeanUtils.equal(getCompanyName(), other.getCompanyName());
return JodaBeanUtils.equal(this.getCompanyName(), other.getCompanyName());
}
return false;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -508582744: // companyName
return companyName;
return this.companyName;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/joda/beans/sample/CompanyAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
CompanyAddress other = (CompanyAddress) obj;
return JodaBeanUtils.equal(companyName, other.companyName) &&
return JodaBeanUtils.equal(this.companyName, other.companyName) &&
super.equals(obj);
}
return false;
Expand Down Expand Up @@ -169,7 +169,7 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -508582744: // companyName
return companyName;
return this.companyName;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/joda/beans/sample/Documentation.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
Documentation<?> other = (Documentation<?>) obj;
return JodaBeanUtils.equal(getType(), other.getType()) &&
JodaBeanUtils.equal(getContent(), other.getContent()) &&
JodaBeanUtils.equal(getMap(), other.getMap());
return JodaBeanUtils.equal(this.getType(), other.getType()) &&
JodaBeanUtils.equal(this.getContent(), other.getContent()) &&
JodaBeanUtils.equal(this.getMap(), other.getMap());
}
return false;
}
Expand Down Expand Up @@ -250,11 +250,11 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 3575610: // type
return type;
return this.type;
case 951530617: // content
return content;
return this.content;
case 107868: // map
return map;
return this.map;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/joda/beans/sample/DocumentationHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
DocumentationHolder other = (DocumentationHolder) obj;
return JodaBeanUtils.equal(getDocumentation(), other.getDocumentation());
return JodaBeanUtils.equal(this.getDocumentation(), other.getDocumentation());
}
return false;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 1587405498: // documentation
return documentation;
return this.documentation;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
DoubleGenericsComplexExtendsSuperTwoGenerics<?, ?> other = (DoubleGenericsComplexExtendsSuperTwoGenerics<?, ?>) obj;
return JodaBeanUtils.equal(getNormalType(), other.getNormalType()) &&
JodaBeanUtils.equal(getTypeT(), other.getTypeT()) &&
JodaBeanUtils.equal(getTypeU(), other.getTypeU()) &&
JodaBeanUtils.equal(getTypeTList(), other.getTypeTList()) &&
JodaBeanUtils.equal(getTypeUList(), other.getTypeUList()) &&
JodaBeanUtils.equal(getTypeTArray(), other.getTypeTArray()) &&
JodaBeanUtils.equal(getTypeUArray(), other.getTypeUArray()) &&
return JodaBeanUtils.equal(this.getNormalType(), other.getNormalType()) &&
JodaBeanUtils.equal(this.getTypeT(), other.getTypeT()) &&
JodaBeanUtils.equal(this.getTypeU(), other.getTypeU()) &&
JodaBeanUtils.equal(this.getTypeTList(), other.getTypeTList()) &&
JodaBeanUtils.equal(this.getTypeUList(), other.getTypeUList()) &&
JodaBeanUtils.equal(this.getTypeTArray(), other.getTypeTArray()) &&
JodaBeanUtils.equal(this.getTypeUArray(), other.getTypeUArray()) &&
super.equals(obj);
}
return false;
Expand Down Expand Up @@ -414,19 +414,19 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -1255672639: // normalType
return normalType;
return this.normalType;
case 110843994: // typeT
return typeT;
return this.typeT;
case 110843995: // typeU
return typeU;
return this.typeU;
case 508018712: // typeTList
return typeTList;
return this.typeTList;
case 508942233: // typeUList
return typeUList;
return this.typeUList;
case -1441181153: // typeTArray
return typeTArray;
return this.typeTArray;
case -1412552002: // typeUArray
return typeUArray;
return this.typeUArray;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
DoubleGenericsNoExtendsNoSuper<?, ?> other = (DoubleGenericsNoExtendsNoSuper<?, ?>) obj;
return JodaBeanUtils.equal(getNormalType(), other.getNormalType()) &&
JodaBeanUtils.equal(getTypeT(), other.getTypeT()) &&
JodaBeanUtils.equal(getTypeU(), other.getTypeU()) &&
JodaBeanUtils.equal(getTypeTList(), other.getTypeTList()) &&
JodaBeanUtils.equal(getTypeUList(), other.getTypeUList()) &&
JodaBeanUtils.equal(getTypeTArray(), other.getTypeTArray()) &&
JodaBeanUtils.equal(getTypeUArray(), other.getTypeUArray());
return JodaBeanUtils.equal(this.getNormalType(), other.getNormalType()) &&
JodaBeanUtils.equal(this.getTypeT(), other.getTypeT()) &&
JodaBeanUtils.equal(this.getTypeU(), other.getTypeU()) &&
JodaBeanUtils.equal(this.getTypeTList(), other.getTypeTList()) &&
JodaBeanUtils.equal(this.getTypeUList(), other.getTypeUList()) &&
JodaBeanUtils.equal(this.getTypeTArray(), other.getTypeTArray()) &&
JodaBeanUtils.equal(this.getTypeUArray(), other.getTypeUArray());
}
return false;
}
Expand Down Expand Up @@ -413,19 +413,19 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -1255672639: // normalType
return normalType;
return this.normalType;
case 110843994: // typeT
return typeT;
return this.typeT;
case 110843995: // typeU
return typeU;
return this.typeU;
case 508018712: // typeTList
return typeTList;
return this.typeTList;
case 508942233: // typeUList
return typeUList;
return this.typeUList;
case -1441181153: // typeTArray
return typeTArray;
return this.typeTArray;
case -1412552002: // typeUArray
return typeUArray;
return this.typeUArray;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
DoubleGenericsSimpleSuper<?, ?> other = (DoubleGenericsSimpleSuper<?, ?>) obj;
return JodaBeanUtils.equal(getBaseType(), other.getBaseType()) &&
JodaBeanUtils.equal(getBaseT(), other.getBaseT()) &&
JodaBeanUtils.equal(getBaseU(), other.getBaseU());
return JodaBeanUtils.equal(this.getBaseType(), other.getBaseType()) &&
JodaBeanUtils.equal(this.getBaseT(), other.getBaseT()) &&
JodaBeanUtils.equal(this.getBaseU(), other.getBaseU());
}
return false;
}
Expand Down Expand Up @@ -260,11 +260,11 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -1721484885: // baseType
return baseType;
return this.baseType;
case 93508515: // baseT
return baseT;
return this.baseT;
case 93508516: // baseU
return baseU;
return this.baseU;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,13 @@ public boolean equals(Object obj) {
}
if (obj != null && obj.getClass() == this.getClass()) {
DoubleGenericsWithExtendsNoSuper<?, ?> other = (DoubleGenericsWithExtendsNoSuper<?, ?>) obj;
return JodaBeanUtils.equal(getNormalType(), other.getNormalType()) &&
JodaBeanUtils.equal(getTypeT(), other.getTypeT()) &&
JodaBeanUtils.equal(getTypeU(), other.getTypeU()) &&
JodaBeanUtils.equal(getTypeTList(), other.getTypeTList()) &&
JodaBeanUtils.equal(getTypeUList(), other.getTypeUList()) &&
JodaBeanUtils.equal(getTypeTArray(), other.getTypeTArray()) &&
JodaBeanUtils.equal(getTypeUArray(), other.getTypeUArray());
return JodaBeanUtils.equal(this.getNormalType(), other.getNormalType()) &&
JodaBeanUtils.equal(this.getTypeT(), other.getTypeT()) &&
JodaBeanUtils.equal(this.getTypeU(), other.getTypeU()) &&
JodaBeanUtils.equal(this.getTypeTList(), other.getTypeTList()) &&
JodaBeanUtils.equal(this.getTypeUList(), other.getTypeUList()) &&
JodaBeanUtils.equal(this.getTypeTArray(), other.getTypeTArray()) &&
JodaBeanUtils.equal(this.getTypeUArray(), other.getTypeUArray());
}
return false;
}
Expand Down Expand Up @@ -414,19 +414,19 @@ protected Meta() {
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -1255672639: // normalType
return normalType;
return this.normalType;
case 110843994: // typeT
return typeT;
return this.typeT;
case 110843995: // typeU
return typeU;
return this.typeU;
case 508018712: // typeTList
return typeTList;
return this.typeTList;
case 508942233: // typeUList
return typeUList;
return this.typeUList;
case -1441181153: // typeTArray
return typeTArray;
return this.typeTArray;
case -1412552002: // typeUArray
return typeUArray;
return this.typeUArray;
}
return super.metaPropertyGet(propertyName);
}
Expand Down
Loading