Skip to content

Conversation

@timo-a
Copy link
Contributor

@timo-a timo-a commented Dec 24, 2024

What's changed?

What's your motivation?

To convert classes to @Value or @Data they need to have @EqualsAndHashCode.
But this annotation is probably not there.
equals() and hashCode() are if defined hard to validate, so this recipe assumes that manual work is necessary and adds
@EqualsAndHashCode to any class that implements either equals() or hashCode() regardless of how they are implemented. The user has to review each class, but saves the effort of finding and replacing.

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@timtebeek timtebeek self-requested a review January 1, 2025 14:43
@timo-a timo-a force-pushed the lombok/convert-equals-negligently branch from 4ab6051 to 68838e4 Compare January 1, 2025 19:13
@timo-a timo-a force-pushed the lombok/convert-equals-negligently branch from 4d5d678 to 4194a9d Compare January 15, 2025 15:59
@timo-a
Copy link
Contributor Author

timo-a commented Jan 15, 2025

Now there is a seemingly unrelated error in /home/runner/work/rewrite-migrate-java/rewrite-migrate-java/src/main/java/org/openrewrite/java/migrate/javax/AddColumnAnnotation.java:92:

error: constructor AddOrUpdateAnnotationAttribute in class AddOrUpdateAnnotationAttribute cannot be applied to given types;
                        J.VariableDeclarations updatedVariable = (J.VariableDeclarations) new AddOrUpdateAnnotationAttribute(
                                                                                          ^
  required: String,String,String,String,Boolean,Boolean
  found:    String,String,String,boolean,<null>
  reason: actual and formal argument lists differ in lengthNote: Recompile with -Xlint:unchecked for details.warning: [options] source value 8 is obsolete and will be removed in a future releaseNote: Some input files use unchecked or unsafe operations.warning: unknown enum constant ElementType.MODULE

Maybe a rebase on main can fix this?
Update: apparently so, pushing

timo-a and others added 4 commits January 15, 2025 17:23
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timo-a timo-a force-pushed the lombok/convert-equals-negligently branch from 7b8ffe4 to 51ffbc2 Compare January 15, 2025 16:48
@timtebeek timtebeek added recipe Recipe requested lombok labels Jan 17, 2025
@timtebeek timtebeek removed their request for review May 6, 2025 14:50
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/main/resources/META-INF/rewrite/examples.yml
    • lines 6501-6500

@github-actions
Copy link
Contributor

This PR is stale because it has been open for 90 days with no activity. Remove stale label or comment or this will be closed in two weeks. PRs may be reopened when there is renewed interest.

@github-actions github-actions bot added the Stale label Aug 11, 2025
@timtebeek timtebeek removed the Stale label Aug 11, 2025
@github-actions
Copy link
Contributor

This PR is stale because it has been open for 90 days with no activity. Remove stale label or comment or this will be closed in two weeks. PRs may be reopened when there is renewed interest.

@github-actions github-actions bot added the Stale label Nov 10, 2025
@github-actions github-actions bot closed this Nov 24, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Nov 24, 2025
@timtebeek
Copy link
Member

Thanks again for your efforts here; I think this one might have been a bit too much of a risk to adopt, as it's quite common for folks to deliberately only use some fields for their equals/hashcode, which is perhaps tough to judge correctly with a recipe given the amount of variation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants