I have a case where I have something like:
public abstract class Base{
private Base sibling;
public Base( Base sibling ){
this.sibling = sibling;
}
public Base getSibling(){
return this.sibling;
}
}
public class ChildA extends Base{
private ChildB brother;
public ChildA(){
this.brother = new ChildB( this );
}
public ChildB getBrother(){ return this.brother }
public void methodA(){ ... }
public void methodB(){ ... }
}
public class ChildB extends Base{
public childB someMethodX(){ ... }
public childB someMethodY(){ ... }
}
Now I need it so that when doing something like:
var child = new ChildA()
.getBrother()
.someMethodX()
.someMethodY()
.getSibling()
.methodA()
.methodB()
.getSibling()
returns me back into the scope of ChildA
. Currently however it seems to be returning me an instance of Base
and giving me an error that methodA()
does not exist in class Base
.
I've looked at some cases of GenericTypes as possibly being what I want in this case, but I've struggled to implement it as of yet. Any examples/pointers/links would be greatly appreciated.
Thanks.