Why not Objects.equal, taking each primitive type as an argument?
I know that you can insert a value through #valueOfor allow each primitive to be auto-boxed, but don't you lose performance? This is what I once thought about.
Imagine I have something like
public class Foo {
private final int integerValue;
private final boolean booleanValue;
private final Bar bar;
public Foo(int integerValue, boolean booleanValue, Bar bar) {
this.integerValue = integerValue;
this.booleanValue = booleanValue;
this.bar = bar;
}
@SuppressWarnings("boxing")
@Override
public boolean equals(Object object) {
if (object instanceof Foo) {
Foo that = (Foo) object;
return Objects.equal(this.integerValue, that.integerValue)
&& Objects.equal(this.booleanValue, that.booleanValue)
&& Objects.equal(this.bar, that.bar);
}
return false;
}
}
equals? , ( ) . == , "" equals, . , guava lib Objects.equal . - ?
MoreObjects.toStringHelper ( ), , , Objects#equal. , JB Nizet, equals , int Integer, .
Guava