I'm using the Apache Commons EqualsBuilder to build the equals method for a non-static Java inner class. For example:
import org.apache.commons.lang.builder.EqualsBuilder; public class Foo { public class Bar { private Bar() {} public Foo getMyFoo() { return Foo.this } private int myInt = 0; public boolean equals(Object o) { if (o == null || o.getClass() != getClass) return false; Bar other = (Bar) o; return new EqualsBuilder() .append(getMyFoo(), other.getMyFoo()) .append(myInt, other.myInt) .isEquals(); } } public Bar createBar(...) { //sensible implementation } public Bar createOtherBar(...) { //another implementation } public boolean equals(Object o) { //sensible equals implementation } } Is there syntax by which I can refer to other's Foo reference apart from declaring the getMyFoo() method? Something like other.Foo.this (which doesn't work)?