GuavaEclipsePlugin / GuavaEclipsePluginParent

"Guava Eclipse Plugin" is an eclipse plugin which will generate following methods using Google guava utility classes or jdk utility classes toString() [STRG + SHIFT + 4] - equals(Object object) & hashCode() [STRG + SHIFT + 5] - compareTo(...) [STRG + SHIFT + 6]
https://guavaeclipseplugin.github.io/
10 stars 4 forks source link

option for Java 7 java.util.Objects support #24

Closed godspeedyou closed 9 years ago

godspeedyou commented 9 years ago

It would be great, if you could offer an option to choose java.util.Objects methods for equals- and hashCode-generation.

arolfes commented 9 years ago

i will implement it.

you will get a checkBox in Preferences which behave like is checked then use Java7 java.util.Objects if unchecked then use guava

by default it will be unchecked

arolfes commented 9 years ago

feature is implemented and as snapshot available under https://sourceforge.net/projects/guavaeclipse/files/SNAPSHOTS/UpdateSite/LATEST/

for a full release a i will add some more integration tests

godspeedyou commented 6 years ago

Thanks for implementing this.

I have 2 notes:

  1. As default "Use java.util.Objects..." is ticked in the settings. But guava is used. To use java.util.Objects I had to untick and retick it.
  2. When using java.util.Objects the guava methods (equals, hash) are used instead of the java.util.Objects methods (equal, hashCode).
arolfes commented 6 years ago

hi,

As default "Use java.util.Objects..." is ticked in the settings. But guava is used. To use java.util.Objects I had to untick and retick it.

Looks like you found a bug in the way i handle preferences... can you tell me what eclipse version you use? I open a separate issue #37

When using java.util.Objects the guava methods (equals, hash) are used instead of the java.util.Objects methods (equal, hashCode).

Sorry but I don't get the point. the generated code should call this method: java.util.Objects.equals(Object, Object) there is no equal Method in java.util.Objects and for hashCode this method should be used java.util.Objects.hash(Object...) maybe you want to use java.util.Objects.hashCode(Object) when you only have one field. this would be a new feature request. would you open one feature request if this what you want.

godspeedyou commented 6 years ago

1.I'm using Version: Oxygen.1 (4.7.1) Build id: M20170906-1700

2.You are correct. There's no equal-method in java.util.Objects. I mixed the method names up. I meant: When using java.util.Objects the guava methods (equal, hashCode) are used instead of the java.util.Objects methods (equals, hash).

Nevermind, I just tried it again, and it works for me now. I must have had problems with existing Guava objects methods within the class I wanted to generate a new equals method. The existing import wasn't removed and interferred with the generated code. So I guess both issues I mentioned are my faux pas.