I have two classes, Outer
and Inner
, and a method in Outer
that takes an Inner
. It needs to validate that this Inner
is one of its own, and not an Inner
that belongs to another instance. What I'd like to do is essentially innerInstance.outer.this
, but there doesn't seem to be a keyword for that. My only other idea is a getOuterThis()
method on Inner
, but I'd rather not have to resort to that.
Here's the general skeleton of what I'm trying to accomplish:
public class Outer {
public Inner getInner() { ... }
public void useInner(Inner inner) {
// Validate here
}
public class Inner {
// Can I avoid this?
public Outer getOuterThis() {
return Outer.this;
}
}
}