Created
August 31, 2017 03:29
-
-
Save TedaLIEz/ed7e5e12a0ad9c65654fe9e930dd6aa5 to your computer and use it in GitHub Desktop.
F-bounded style
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
/** | |
* If the return type must be the type of the class that implements the interface, | |
* then what you want is called an F-bounded type | |
*/ | |
public interface A<T extends A<T>> { | |
public T b(); | |
} | |
public class C implements A<C> { | |
public C b() { ... } | |
} | |
public class D implements A<D> { | |
public D b() { ... } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment