B
Ben Phillips
This seems to be a minor irritation with NetBeans: if you have a class A
that overrides equals() with something like
if (o == this) return true;
if (o == null) return false;
if (!o instanceof A) return false;
// and maybe
if (o.getClass() != getClass()) return false; // objects of different
// subclasses aren't equal
return equalTo((A)o);
public abstract boolean equalTo (A other);
and hashCode with something like
throw new Error("My subclass should have overridden me!");
and then, in a subclass B, implement equalTo and hashCode (to be
consistent with one another), NetBeans warns of having overridden
hashCode without equals.
This is just a touch annoying, since it means you either have the
warning or else have to repeat a bunch of boilerplate equals() code in
every subclass.
Is there an @SuppressWarnings for this, or a NetBeans update in the
works that will make it smarter about guessing if a subclass really is
implementing equalTo in some indirect manner (say, because it implements
a boolean-returning abstract method the superclass declares and only
calls from inside equals())?
that overrides equals() with something like
if (o == this) return true;
if (o == null) return false;
if (!o instanceof A) return false;
// and maybe
if (o.getClass() != getClass()) return false; // objects of different
// subclasses aren't equal
return equalTo((A)o);
public abstract boolean equalTo (A other);
and hashCode with something like
throw new Error("My subclass should have overridden me!");
and then, in a subclass B, implement equalTo and hashCode (to be
consistent with one another), NetBeans warns of having overridden
hashCode without equals.
This is just a touch annoying, since it means you either have the
warning or else have to repeat a bunch of boilerplate equals() code in
every subclass.
Is there an @SuppressWarnings for this, or a NetBeans update in the
works that will make it smarter about guessing if a subclass really is
implementing equalTo in some indirect manner (say, because it implements
a boolean-returning abstract method the superclass declares and only
calls from inside equals())?