Created
June 25, 2018 09:46
-
-
Save elizarov/30ca944eb5390caac3362590c8472b89 to your computer and use it in GitHub Desktop.
This file contains 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
import java.util.stream.Stream | |
abstract class NodeScaffold<THIS : NodeScaffold<THIS>> { | |
private val children: List<THIS>? = null | |
fun children(): Stream<THIS> { | |
return children!!.stream() | |
} | |
fun grandChildren(): Stream<THIS> { | |
return children!!.stream() | |
.flatMap { child -> child.children() } | |
} | |
} | |
abstract class SpecialNodeScaffold<THIS : SpecialNodeScaffold<THIS>> : NodeScaffold<THIS>()// special methods | |
abstract class VerySpecialNodeScaffold<THIS : VerySpecialNodeScaffold<THIS>> : | |
SpecialNodeScaffold<THIS>()// more special methods | |
class Node : NodeScaffold<Node>() | |
class SpecialNode : SpecialNodeScaffold<SpecialNode>() | |
class VerySpecialNode : VerySpecialNodeScaffold<VerySpecialNode>() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment