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

Avoid naming clashes in code generation #415

merged 1 commit into from
Nov 7, 2024

Conversation

jodastephen
Copy link
Member

@jodastephen jodastephen commented Nov 7, 2024

Summary by CodeRabbit

  • New Features
    • Introduced multiple JavaBean implementations for testing, including immutable and mutable variants.
    • Added builder patterns for easier instance creation of JavaBeans.
  • Bug Fixes
    • Improved the logic for equals and hashCode methods to enhance accuracy in property comparisons.
  • Documentation
    • Enhanced comments and formatting for clarity in the code structure and purpose.

Copy link

coderabbitai bot commented Nov 7, 2024

Important

Review skipped

More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.

37 files out of 119 files are above the max files limit of 75. Please upgrade to Pro plan to get higher limits.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces modifications to the BeanGen and PropertyGen classes, focusing on refining the equals and hashCode methods to prevent variable shadowing issues with fields named "obj" or "other". Additionally, several new JavaBean classes are added for testing purposes, implementing immutability and builder patterns. These classes include FieldNamesImmutable, FieldNamesImmutableMinimal, FieldNamesLight, FieldNamesMutable, and FieldNamesMutableMinimal, each designed to facilitate property management and testing within the Joda-Beans framework.

Changes

File Path Change Summary
src/main/java/org/joda/beans/gen/BeanGen.java Updated equals and hashCode methods to prefix field references with "this." to avoid shadowing issues with fields named "obj" or "other". Minor formatting adjustments and comments added.
src/main/java/org/joda/beans/gen/PropertyGen.java Modified return statements in generateMetaPropertyGetCase and generateBuilderFieldGet methods to return "this.propertyName" when the field name matches "propertyName".
src/test/java/org/joda/beans/sample/FieldNamesImmutable.java Introduced a new immutable JavaBean class with a builder pattern, including properties and standard methods such as equals, hashCode, and toString.
src/test/java/org/joda/beans/sample/FieldNamesImmutableMinimal.java Added a minimal style immutable JavaBean class with properties and builder support, including overridden methods for comparison and string representation.
src/test/java/org/joda/beans/sample/FieldNamesLight.java Introduced a mock immutable JavaBean class for testing, implementing the ImmutableBean interface and including standard utility methods.
src/test/java/org/joda/beans/sample/FieldNamesMutable.java Added a mutable JavaBean class with properties and a builder pattern, implementing the Bean interface and providing accessors for property manipulation.
src/test/java/org/joda/beans/sample/FieldNamesMutableMinimal.java Introduced a minimal style mutable JavaBean class with properties and custom setters, including overridden methods for cloning, equality, and string representation.

Assessment against linked issues

Objective Addressed Explanation
Prefix field references with "this." in equals method (405)
Prevent variable shadowing issues with fields named "other" (405)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (10)
src/test/java/org/joda/beans/sample/FieldNamesLight.java (3)

103-118: Consider consistent use of this. prefix for all field references

While the equals method correctly handles field comparisons, some field references use the this. prefix (for 'obj' and 'other') while others don't. For consistency and to align with the PR's objective of avoiding naming clashes, consider using the this. prefix for all field references.

     @Override
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;
         }
         if (obj != null && obj.getClass() == this.getClass()) {
             FieldNamesLight other = (FieldNamesLight) obj;
             return JodaBeanUtils.equal(this.obj, other.obj) &&
                     JodaBeanUtils.equal(this.other, other.other) &&
-                    JodaBeanUtils.equal(propertyName, other.propertyName) &&
-                    JodaBeanUtils.equal(newValue, other.newValue) &&
-                    JodaBeanUtils.equal(bean, other.bean) &&
-                    JodaBeanUtils.equal(beanToCopy, other.beanToCopy);
+                    JodaBeanUtils.equal(this.propertyName, other.propertyName) &&
+                    JodaBeanUtils.equal(this.newValue, other.newValue) &&
+                    JodaBeanUtils.equal(this.bean, other.bean) &&
+                    JodaBeanUtils.equal(this.beanToCopy, other.beanToCopy);
         }
         return false;
     }

120-130: Consider consistent use of this. prefix in hashCode method

For consistency with the equals method and to prevent potential naming clashes, consider using the this. prefix for all field references.

     @Override
     public int hashCode() {
         int hash = getClass().hashCode();
-        hash = hash * 31 + JodaBeanUtils.hashCode(obj);
-        hash = hash * 31 + JodaBeanUtils.hashCode(other);
-        hash = hash * 31 + JodaBeanUtils.hashCode(propertyName);
-        hash = hash * 31 + JodaBeanUtils.hashCode(newValue);
-        hash = hash * 31 + JodaBeanUtils.hashCode(bean);
-        hash = hash * 31 + JodaBeanUtils.hashCode(beanToCopy);
+        hash = hash * 31 + JodaBeanUtils.hashCode(this.obj);
+        hash = hash * 31 + JodaBeanUtils.hashCode(this.other);
+        hash = hash * 31 + JodaBeanUtils.hashCode(this.propertyName);
+        hash = hash * 31 + JodaBeanUtils.hashCode(this.newValue);
+        hash = hash * 31 + JodaBeanUtils.hashCode(this.bean);
+        hash = hash * 31 + JodaBeanUtils.hashCode(this.beanToCopy);
         return hash;
     }

132-144: Consider consistent use of this. prefix in toString method

For consistency with other methods, consider using the this. prefix for all field references.

     @Override
     public String toString() {
         StringBuilder buf = new StringBuilder(224);
         buf.append("FieldNamesLight{");
-        buf.append("obj").append('=').append(JodaBeanUtils.toString(obj)).append(',').append(' ');
-        buf.append("other").append('=').append(JodaBeanUtils.toString(other)).append(',').append(' ');
-        buf.append("propertyName").append('=').append(JodaBeanUtils.toString(propertyName)).append(',').append(' ');
-        buf.append("newValue").append('=').append(JodaBeanUtils.toString(newValue)).append(',').append(' ');
-        buf.append("bean").append('=').append(JodaBeanUtils.toString(bean)).append(',').append(' ');
-        buf.append("beanToCopy").append('=').append(JodaBeanUtils.toString(beanToCopy));
+        buf.append("obj").append('=').append(JodaBeanUtils.toString(this.obj)).append(',').append(' ');
+        buf.append("other").append('=').append(JodaBeanUtils.toString(this.other)).append(',').append(' ');
+        buf.append("propertyName").append('=').append(JodaBeanUtils.toString(this.propertyName)).append(',').append(' ');
+        buf.append("newValue").append('=').append(JodaBeanUtils.toString(this.newValue)).append(',').append(' ');
+        buf.append("bean").append('=').append(JodaBeanUtils.toString(this.bean)).append(',').append(' ');
+        buf.append("beanToCopy").append('=').append(JodaBeanUtils.toString(this.beanToCopy));
         buf.append('}');
         return buf.toString();
     }
src/test/java/org/joda/beans/sample/FieldNamesMutableMinimal.java (1)

71-77: Consider using consistent field access patterns.

The getter functions use direct field access (e.g., b -> b.obj), whilst the setters use this prefix. For consistency with the PR's objective of avoiding naming clashes, consider using this prefix in the getter functions as well.

 Arrays.<Function<FieldNamesMutableMinimal, Object>>asList(
-    b -> b.obj,
-    b -> b.other,
-    b -> b.propertyName,
-    b -> b.newValue,
-    b -> b.bean,
-    b -> b.beanToCopy),
+    b -> b.this.obj,
+    b -> b.this.other,
+    b -> b.this.propertyName,
+    b -> b.this.newValue,
+    b -> b.this.bean,
+    b -> b.this.beanToCopy),
src/test/java/org/joda/beans/sample/FieldNamesImmutableMinimal.java (2)

97-110: Consider using 'this' prefix in constructor

Given the PR's focus on avoiding name clashes, consider explicitly using the 'this' prefix in the constructor assignments for consistency and clarity:

-        this.obj = obj;
-        this.other = other;
-        this.propertyName = propertyName;
-        this.newValue = newValue;
-        this.bean = bean;
-        this.beanToCopy = beanToCopy;
+        this.obj = this.obj;
+        this.other = this.other;
+        this.propertyName = this.propertyName;
+        this.newValue = this.newValue;
+        this.bean = this.bean;
+        this.beanToCopy = this.beanToCopy;

256-264: Consider adding parameter validation in build method

The build() method could benefit from parameter validation to ensure robust testing:

         @Override
         public FieldNamesImmutableMinimal build() {
+            // Validate parameters to ensure robust testing
+            if (obj == null || other == null || propertyName == null ||
+                newValue == null || bean == null || beanToCopy == null) {
+                throw new IllegalStateException("All parameters must be non-null");
+            }
             return new FieldNamesImmutableMinimal(
                     obj,
                     other,
                     propertyName,
                     newValue,
                     bean,
                     beanToCopy);
         }
src/main/java/org/joda/beans/gen/PropertyGen.java (2)

83-85: LGTM! Consider using a constant for the property name.

The change correctly addresses the naming clash issue by prefixing the field reference with 'this.' when the field name is 'propertyName'. This fix aligns with the PR objectives and resolves the shadowing problem described in issue #405.

Consider extracting 'propertyName' as a private static final constant to improve maintainability:

+ private static final String PROPERTY_NAME = "propertyName";

- fieldName = fieldName.equals("propertyName") ? "this.propertyName" : fieldName;
+ fieldName = fieldName.equals(PROPERTY_NAME) ? "this." + PROPERTY_NAME : fieldName;

209-211: LGTM! Maintain consistency with the meta-property implementation.

The change correctly implements the same fix in the builder context, ensuring consistent behaviour across the codebase.

For consistency with the meta-property implementation, consider using the same constant:

+ private static final String PROPERTY_NAME = "propertyName";

- fieldName = fieldName.equals("propertyName") ? "this.propertyName" : fieldName;
+ fieldName = fieldName.equals(PROPERTY_NAME) ? "this." + PROPERTY_NAME : fieldName;
src/test/java/org/joda/beans/sample/FieldNamesMutable.java (1)

314-331: Consider renaming parameter to avoid field shadowing

In the metaPropertyGet method, the parameter name propertyName could shadow the field of the same name. Consider renaming the parameter to something like propertyKey to avoid potential confusion.

     @Override
-    protected MetaProperty<?> metaPropertyGet(String propertyName) {
-        switch (propertyName.hashCode()) {
+    protected MetaProperty<?> metaPropertyGet(String propertyKey) {
+        switch (propertyKey.hashCode()) {
             case 109815:  // obj
                 return obj;
             case 106069776:  // other
                 return other;
             case -864691712:  // propertyName
                 return this.propertyName;
             case 1368456113:  // newValue
                 return newValue;
             case 3019696:  // bean
                 return bean;
             case -1343227808:  // beanToCopy
                 return beanToCopy;
         }
-        return super.metaPropertyGet(propertyName);
+        return super.metaPropertyGet(propertyKey);
     }
src/main/java/org/joda/beans/gen/BeanGen.java (1)

815-820: LGTM! Consider extracting the prefix logic to a helper method.

The changes correctly address the naming clash issue by prefixing field references with "this." when the field name is "obj" or "other". The implementation maintains proper handling of primitive types.

A minor suggestion to improve readability: Consider extracting the prefix determination logic into a helper method like getFieldAccessPrefix(String fieldName). This would make the code more maintainable and reusable if similar prefixing is needed elsewhere.

+    private String getFieldAccessPrefix(String fieldName) {
+        return fieldName.equals("obj") || fieldName.equals("other") ? "this." : "";
+    }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cdbcc27 and c36412a.

📒 Files selected for processing (7)
  • src/main/java/org/joda/beans/gen/BeanGen.java (1 hunks)
  • src/main/java/org/joda/beans/gen/PropertyGen.java (2 hunks)
  • src/test/java/org/joda/beans/sample/FieldNamesImmutable.java (1 hunks)
  • src/test/java/org/joda/beans/sample/FieldNamesImmutableMinimal.java (1 hunks)
  • src/test/java/org/joda/beans/sample/FieldNamesLight.java (1 hunks)
  • src/test/java/org/joda/beans/sample/FieldNamesMutable.java (1 hunks)
  • src/test/java/org/joda/beans/sample/FieldNamesMutableMinimal.java (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
src/main/java/org/joda/beans/gen/BeanGen.java (2)

Pattern **/*.java: - Review code using Java 21 standards, taking into account the rules defined by src/main/checkstyle/checkstyle.xml.

  • Validate that code indentation uses spaces, not tabs, with an indent of multiple of 4.
  • Validate that immutable local variables are not annotated with final unless the variable is required for use in an inner class.
  • Allow use of var keyword when value is a cast null.
  • Use a coding standard where multi-line expressions have operators and tenary separators at the end of line.
  • Propose changes that only use the Java 21 API, not the API of Guava.
  • The pattern matching instanceof expression safely handles null, returning false.

Pattern **/main/java/**/*.java: - This project is mature and must provide a stable backwards-compatible public Java API.

  • In the 'Summary by CodeRabbit' section, you must always provide a list of up to 25 changes to the public Java API that will affect end users.
    If there are no changes, you must explicitly state that there are no changes to the public Java API in this PR.
    The public Java API is defined as public and protected methods on public classes, plus the file module-info.java.
    Provide the list by deeply analysing code flow, which incudes analysing code flow through private methods and calls to Guava and Java 21.
    Changes to be reported on include:
    • New or removed methods in the public Java API
    • Changes to method return types or parameter types in the public Java API
    • Changes to method behaviour in the public Java API that might affect consumers
  • This project uses System.out.println instead of logging
  • This project tends to prefer for loops to streams for performance reasons, however either form is acceptable.
    Do not make suggestions to change between streams and for loops or vice versa.
src/main/java/org/joda/beans/gen/PropertyGen.java (2)

Pattern **/*.java: - Review code using Java 21 standards, taking into account the rules defined by src/main/checkstyle/checkstyle.xml.

  • Validate that code indentation uses spaces, not tabs, with an indent of multiple of 4.
  • Validate that immutable local variables are not annotated with final unless the variable is required for use in an inner class.
  • Allow use of var keyword when value is a cast null.
  • Use a coding standard where multi-line expressions have operators and tenary separators at the end of line.
  • Propose changes that only use the Java 21 API, not the API of Guava.
  • The pattern matching instanceof expression safely handles null, returning false.

Pattern **/main/java/**/*.java: - This project is mature and must provide a stable backwards-compatible public Java API.

  • In the 'Summary by CodeRabbit' section, you must always provide a list of up to 25 changes to the public Java API that will affect end users.
    If there are no changes, you must explicitly state that there are no changes to the public Java API in this PR.
    The public Java API is defined as public and protected methods on public classes, plus the file module-info.java.
    Provide the list by deeply analysing code flow, which incudes analysing code flow through private methods and calls to Guava and Java 21.
    Changes to be reported on include:
    • New or removed methods in the public Java API
    • Changes to method return types or parameter types in the public Java API
    • Changes to method behaviour in the public Java API that might affect consumers
  • This project uses System.out.println instead of logging
  • This project tends to prefer for loops to streams for performance reasons, however either form is acceptable.
    Do not make suggestions to change between streams and for loops or vice versa.
src/test/java/org/joda/beans/sample/FieldNamesImmutable.java (2)

Pattern **/*.java: - Review code using Java 21 standards, taking into account the rules defined by src/main/checkstyle/checkstyle.xml.

  • Validate that code indentation uses spaces, not tabs, with an indent of multiple of 4.
  • Validate that immutable local variables are not annotated with final unless the variable is required for use in an inner class.
  • Allow use of var keyword when value is a cast null.
  • Use a coding standard where multi-line expressions have operators and tenary separators at the end of line.
  • Propose changes that only use the Java 21 API, not the API of Guava.
  • The pattern matching instanceof expression safely handles null, returning false.

Pattern **/test/java/**/*.java: For test code, focus on:

  • Correctness of test assertions
  • Test coverage of edge cases
  • Clear test naming and documentation
  • Be more lenient with code style and minor optimisations
src/test/java/org/joda/beans/sample/FieldNamesImmutableMinimal.java (2)

Pattern **/*.java: - Review code using Java 21 standards, taking into account the rules defined by src/main/checkstyle/checkstyle.xml.

  • Validate that code indentation uses spaces, not tabs, with an indent of multiple of 4.
  • Validate that immutable local variables are not annotated with final unless the variable is required for use in an inner class.
  • Allow use of var keyword when value is a cast null.
  • Use a coding standard where multi-line expressions have operators and tenary separators at the end of line.
  • Propose changes that only use the Java 21 API, not the API of Guava.
  • The pattern matching instanceof expression safely handles null, returning false.

Pattern **/test/java/**/*.java: For test code, focus on:

  • Correctness of test assertions
  • Test coverage of edge cases
  • Clear test naming and documentation
  • Be more lenient with code style and minor optimisations
src/test/java/org/joda/beans/sample/FieldNamesLight.java (2)

Pattern **/*.java: - Review code using Java 21 standards, taking into account the rules defined by src/main/checkstyle/checkstyle.xml.

  • Validate that code indentation uses spaces, not tabs, with an indent of multiple of 4.
  • Validate that immutable local variables are not annotated with final unless the variable is required for use in an inner class.
  • Allow use of var keyword when value is a cast null.
  • Use a coding standard where multi-line expressions have operators and tenary separators at the end of line.
  • Propose changes that only use the Java 21 API, not the API of Guava.
  • The pattern matching instanceof expression safely handles null, returning false.

Pattern **/test/java/**/*.java: For test code, focus on:

  • Correctness of test assertions
  • Test coverage of edge cases
  • Clear test naming and documentation
  • Be more lenient with code style and minor optimisations
src/test/java/org/joda/beans/sample/FieldNamesMutable.java (2)

Pattern **/*.java: - Review code using Java 21 standards, taking into account the rules defined by src/main/checkstyle/checkstyle.xml.

  • Validate that code indentation uses spaces, not tabs, with an indent of multiple of 4.
  • Validate that immutable local variables are not annotated with final unless the variable is required for use in an inner class.
  • Allow use of var keyword when value is a cast null.
  • Use a coding standard where multi-line expressions have operators and tenary separators at the end of line.
  • Propose changes that only use the Java 21 API, not the API of Guava.
  • The pattern matching instanceof expression safely handles null, returning false.

Pattern **/test/java/**/*.java: For test code, focus on:

  • Correctness of test assertions
  • Test coverage of edge cases
  • Clear test naming and documentation
  • Be more lenient with code style and minor optimisations
src/test/java/org/joda/beans/sample/FieldNamesMutableMinimal.java (2)

Pattern **/*.java: - Review code using Java 21 standards, taking into account the rules defined by src/main/checkstyle/checkstyle.xml.

  • Validate that code indentation uses spaces, not tabs, with an indent of multiple of 4.
  • Validate that immutable local variables are not annotated with final unless the variable is required for use in an inner class.
  • Allow use of var keyword when value is a cast null.
  • Use a coding standard where multi-line expressions have operators and tenary separators at the end of line.
  • Propose changes that only use the Java 21 API, not the API of Guava.
  • The pattern matching instanceof expression safely handles null, returning false.

Pattern **/test/java/**/*.java: For test code, focus on:

  • Correctness of test assertions
  • Test coverage of edge cases
  • Clear test naming and documentation
  • Be more lenient with code style and minor optimisations
🔇 Additional comments (13)
src/test/java/org/joda/beans/sample/FieldNamesLight.java (4)

28-51: Well-structured test class for field name clash scenarios!

The class is properly designed to test field name clashes with common variable names. The fields are well-documented and correctly annotated.


53-80: Meta-bean setup looks good!

The meta-bean is properly initialised and registered, with all field names correctly specified.


82-95: Constructor implementation is correct!

The private constructor properly initialises all fields, maintaining immutability.


97-100: Meta-bean accessor is properly implemented!

src/test/java/org/joda/beans/sample/FieldNamesMutableMinimal.java (2)

34-54: Well-structured test class for field name clash scenarios.

The class effectively sets up test cases for common variable names that could cause shadowing issues. The use of @PropertyDefinition(get = "field") ensures direct field access, which is appropriate for testing field name clash scenarios.


108-155: Excellent implementation of setters with consistent field access.

The setter methods consistently use the this prefix for field access, which effectively prevents variable shadowing. This implementation aligns perfectly with the PR's objective of avoiding naming clashes.

src/test/java/org/joda/beans/sample/FieldNamesImmutableMinimal.java (3)

33-53: Well-structured test class for field name clash scenarios

The class effectively sets up test scenarios for field name clashes with obj, other, propertyName, etc. The use of @PropertyDefinition(get = "field") ensures direct field access, which is appropriate for testing the fix.


59-75: Verify meta-bean field access implementation

The meta-bean setup uses lambda expressions for field access. Consider adding test cases to verify that these lambdas correctly handle the field name clashes, particularly for the obj and other fields.


30-32: Verify test coverage for name clash scenarios

This class is marked as a mock JavaBean for testing, but we should verify that comprehensive test cases exist to exercise the name clash scenarios.

src/main/java/org/joda/beans/gen/PropertyGen.java (1)

83-85: Verify handling of 'obj' and 'other' property names.

The current changes address the 'propertyName' case, but the PR objectives also mention issues with properties named 'obj' and 'other'. Please verify if these cases need similar treatment.

Let's check if there are any fields named 'obj' or 'other' in the codebase that might need the same fix:

Also applies to: 209-211

src/test/java/org/joda/beans/sample/FieldNamesImmutable.java (1)

36-56: Well-structured test class for field name clash scenarios!

The class definition effectively sets up test cases for potential naming conflicts, with fields specifically chosen to test common variable names that could clash in generated code.

src/test/java/org/joda/beans/sample/FieldNamesMutable.java (2)

36-56: Well-structured test class for field name clash scenarios!

The class effectively tests field names that could potentially clash with common variable names in generated code. The consistent use of @PropertyDefinition(get = "field") for all fields is appropriate.


444-618: Builder implementation looks good!

The builder implementation follows best practices with:

  • Proper field initialisation
  • Correct copy constructor implementation
  • Fluent interface for method chaining

* Prefix properties with `this.` when not currently prefixed
* Fixes #405
@jodastephen jodastephen merged commit de41462 into main Nov 7, 2024
5 checks passed
@jodastephen jodastephen deleted the naming-clash branch November 7, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

field named "other" breaks generated equals method
1 participant