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 com.google.protobuf.gradle.* | |
... | |
protobuf { | |
... | |
generatedFilesBaseDir = "$buildDir/generated-sources" | |
... | |
dependencies { | |
protobuf(files(project.properties["protoDir"].toString())) | |
} | |
generateProtoTasks { |
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
fun Tree<Int>.sum(): Long = when (this) { | |
Empty -> 0 | |
is Node -> value + left.sum() + right.sum() | |
} |
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
sealed class Tree<out T> |
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
data class Node<T>( | |
val value: T, | |
val left: Tree<T> = Empty, | |
val right: Tree<T> = Empty | |
) : Tree<T>() |
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
object Empty : Tree<Nothing>() { | |
override fun toString() = "Empty" | |
} |
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
val tree = Node( | |
42, | |
Empty, | |
Node(62) | |
) | |
println(tree) |
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
sealed class Tree<out T> |
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
sealed class Tree<out T> | |
object Empty : Tree<Nothing>() { | |
override fun toString() = "Empty" | |
} | |
data class Node<T>( | |
val value: T, | |
val left: Tree<T> = Empty, | |
val right: Tree<T> = Empty |
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
public SQLClient getConnection(Handler<AsyncResult<SQLConnection>> handler) { | |
Context ctx = vertx.getOrCreateContext(); | |
getConnection(ctx, ar -> ctx.runOnContext(v -> handler.handle(ar))); | |
return this; | |
} |
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
public void execute(Connection conn, | |
TaskQueue statementsQueue, | |
Handler<AsyncResult<T>> resultHandler) { | |
ctx.executeBlocking(future -> handle(conn, future), | |
statementsQueue, resultHandler); | |
} |