I have a following code:
class PageMedia {
public PageMedia upload(){return this;}
public void insert(){}
}
class PageA {
public PageA dosomething(){ return this;}
public void openMedia(){ return page(PageMedia.class);}
public PageA save(){ return this;}
}
class PageB {
public PageB dosomething(){ return this;}
public void openMedia(){ return page(PageMedia.class);}
public PageB save(){ return this;}
}
Each class is unique and each method is unique.
It is needed that method "insert" of class PageMedia returns a class PageA or PageB, which is used in the chain.
So it would be possible to do following:
PageA.open()
.dosomething()
.openMedia()
.upload()
.insert()
.save;
PageB.open()
.dosomething()
.openMedia()
.upload()
.insert()
.save;