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
import org.gradle.kotlin.dsl.extra | |
import org.jetbrains.kotlin.gradle.dsl.Coroutines | |
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper | |
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
val kotlinVersion = plugins.getPlugin(KotlinPluginWrapper::class.java).kotlinPluginVersion | |
val kotlinCoroutinesVersion = "0.19.3" | |
val vertxVersion = "3.5.0" | |
val nexusRepo = "http://x.x.x.x:8080/nexus/content/repositories/releases" |
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 LazyContextAware<out T>(private val initializer: (Any?) -> T) : ReadOnlyProperty<Any?, T> { | |
private object UNINITIALIZED_VALUE | |
private var prop: Any? = UNINITIALIZED_VALUE | |
@Suppress("UNCHECKED_CAST") | |
override fun getValue(thisRef: Any?, property: KProperty<*>): T { | |
return if (prop == UNINITIALIZED_VALUE) { | |
synchronized(this) { | |
return if (prop == UNINITIALIZED_VALUE) { |
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
import com.github.jengelman.gradle.plugins.shadow.ShadowApplicationPlugin | |
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | |
import com.jfrog.bintray.gradle.BintrayPlugin | |
import org.jetbrains.kotlin.gradle.dsl.Coroutines | |
import org.gradle.api.publish.maven.MavenPom | |
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper | |
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
import com.jfrog.bintray.gradle.BintrayExtension | |
val kotlinVersion = plugins.getPlugin(KotlinPluginWrapper::class.java).kotlinPluginVersion |
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
fun main(args: Array<String>) { | |
println("Hello Kotlin World") | |
} |
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
data class PageableDTO(val offset: Int, val limit: Int, val sortBy: String? = null, val ascending: Boolean? = null) | |
fun PageableDTO.injectDefaults() = | |
copy(sortBy = if (sortBy?.isNotEmpty() == true) sortBy else "created_ts", ascending = ascending ?: true) | |
fun main(args: Array<String>) { | |
val pageableDTO = PageableDTO(1, 2) | |
val withDefaults = pageableDTO.injectDefaults() | |
} |
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
fun trueOrFalse() = Random().nextBoolean() |
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
public class SingleExpFun { | |
private BooleanSupplier trueOrFalse = new Random()::nextBoolean; | |
private boolean getNext(){ | |
return trueOrFalse.getAsBoolean(); | |
} | |
} |
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
public class Overloader { | |
public void test(int a, boolean printToConsole) { | |
if (printToConsole) { | |
System.out.println("int a: " + a); | |
} | |
} | |
public void testWithoutPrint(int a) { | |
test(a, false); | |
} | |
public void test(int a) { |
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
fun test(a: Int, printToConsole: Boolean = true) { | |
if (printToConsole) println("int a: " + a) | |
} | |
fun testWithoutPrint(a: Int) = test(a, false) | |
fun main(args: Array) { | |
testWithoutPrint(2) | |
test(2) | |
} |
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 Turtle { | |
fun penDown() | |
fun penUp() | |
fun turn(degrees: Double) | |
fun forward(pixels: Double) | |
} | |
with(Turtle()) { | |
penDown() | |
for(i in 1..4) { |