-1

When creating a new class, it is useful to generate all the boilerplate by IDE (unless e.g. Lombok is used, of course). I tried to do it with IntelliJ Idea and I didn't like the equals and hashCode methods.

In fact, not even Idea itself liked the equals method. The code inspection says that the statement can be simplified. Well, it looks slightly better after applying Simplify n+1 times where n is amount of fields used in the methods, but it is still not the intended result.

Objects.equals(objA, objB) and Objects.hash(Object...) are considered best practice where I work. Is it possible to modify the templates used in Quick Generation feature?

If not, is there any update planned to enhance its behavior so that it at least passes inspections?

Vlasec
  • 5,500
  • 3
  • 27
  • 30
  • Technically this is a duplicate of [this question](https://stackoverflow.com/questions/18362721/is-it-possible-to-change-intellijs-code-generation-template-for-equals-and-ha). The answers in there contain links to plugins that allow it, and a link to the feature request for it in IntelliJ core (I didn't investigate the validity of those links). You could use the plugins while you wait for 14.1, or join the EAP. – ajp15243 Feb 23 '15 at 17:36
  • I looked at the similar questions while typing this and the question you mentioned didn't appear there. It even has the same tags, I guess I should practice my searching skills. Anyway, it seems I got an answer that is not mentioned there - I'm looking forward to 14.1 – Vlasec Feb 24 '15 at 09:29
  • It could also be that Stack Overflow's search isn't perfect (*hides from SO devs*) – ajp15243 Feb 24 '15 at 15:16
  • Quite interesting that the older question only mentioned plugins until March 15. Not surprising there is a downvote if it's technically a duplicate, but another question being downvoted in the very same minute sounds more like some personal vendetta, however feeble. – Vlasec Feb 09 '18 at 21:18

1 Answers1

1

The latest IDEA 14.1 EAP (https://confluence.jetbrains.com/display/IDEADEV/IDEA+14.1+EAP) contains this possibility, please try it.

Peter Gromov
  • 17,615
  • 7
  • 49
  • 35