Created
October 28, 2016 12:37
-
-
Save sliskiCode/979a738274b310ac028b19107b2503c8 to your computer and use it in GitHub Desktop.
Zero boilerplate delegation in Kotlin 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CopyPrinter implements Copy, Print { | |
private Copy copier; | |
private Print printer; | |
public CopyPrinter(Copy copier, Print printer) { | |
this.copier = copier; | |
this.printer = printer; | |
} | |
@Override | |
public Page copy(Page page) { | |
return copier.copy(page); | |
} | |
@Override | |
public void print(Page page) { | |
printer.print(page); | |
} | |
} | |
interface Copy { | |
Page copy(Page page); | |
} | |
interface Print { | |
void print(Page page); | |
} | |
class Page {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment