default equals again, sorry
Jose
jgetino at telefonica.net
Thu Jan 23 13:02:48 PST 2014
Until now I've been able to overcome the limitation of default equals() in
interfaces, by providing a defaultEquals() everywhere. Not very elegant but
al least it works.
But now I found an issue I don't know how to solve. I often use an idiom
like this in the deepest loops of my code to restrict object allocation to a
minimum. I call it stateless factory, but maybe there is already a more
appropriate name for it.
interface Point(){
int x();
int y();
static Point of(int x, int y) {
return new Point() {
public int x() {
return x;
}
public int y() {
return y;
}
};
}
Until now it was working ok, but then I found I can't make equality tests
with this construct.
Any idea on how to overcome this limitation?.
More information about the lambda-dev
mailing list