eclipse neon – removing redundant types in java 7 diamond operators

I’m really excited that Neon comes with a feature to remove the redundant types that haven’t been needed since Java 7. For example, List<String> list = new ArrayList<String>(); vs List<String> list = new ArrayList<>(); We have the diamond operator, but there hasn’t been any easy way that I know of for dealing with the old code.

How to use it

I wanted to run JUST this rule so my commit doesn’t have other things in it. (I like to run these rules one at a time). Here’s what I did:

  1. Select project
  2. Source > Cleanup
  3. Use custom profile
  4. Configure
  5. Uncheck box on member access tab
  6. Uncheck box on missing code tab
  7. Uncheck all boxes on unnecessary code tab
  8. Check box for Remove redundant type arguments (1.7 or higher)
  9. Ok
  10. Finish
  11. Wait about 30 seconds
  12. Sync with repository
  13. Spot check three classes – all good!
  14. Commit the 202 files that had changes in it
  15. Enjoy the cleaner code 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *