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

Escape autoboxing for primitive types #30

Closed foal closed 6 years ago

foal commented 8 years ago

e.g generated hashCode now

    public int hashCode() {
        return Objects.hashCode(super.hashCode(), getOffset());
    }

have to be

    public int hashCode() {
        return Objects.hashCode(Integer.valueOf(super.hashCode()), Long.valueOf(getOffset()));
    }

the same for equals

arolfes commented 6 years ago

Hi foal,

can you check the new version. There is a setting called "for primitives don't use Objects method to avoid casting" https://guavaeclipseplugin.github.io/images/GuavaEclipsePlugin_Preferences_EqualsHashCode.png

i will add some documentation about this setting

can you check if this behavior fits your needs? If yes, please let me know if not let us talk about an example.

arolfes commented 6 years ago

I think i get your point

you want an option to enable explicite AutoBoxing.

foal commented 6 years ago

Yes, I see it as following options: ( ) generate it as it ( ) add @SuppressWarnings("boxing") annotation ( ) use the explicit boxing

I check the current version - it solves the issue for equals method, but we still have autoboxing in a hash.

arolfes commented 6 years ago

hi foal,

can you test current snapshot, please. update site is here: https://dl.bintray.com/guavaeclipseplugin/GuavaEclipsePlugin/SNAPSHOT/latest/

Window -> Preferences -> Guava Preferences -> Equals/HashCode Methods Preferences there is a new RadioGroup "autoboxing, supressWarning(boxing), explicit boxing for primitives"

One thing to know for equals methods: the selection of the new radio group has no effect so long the checkbox "For primitives don't use Objects method in equals() to avoid casting" is selected.