klib / klib.functions

Package klib.functions

Functions

alphanumericalRegex

Returns a Regex that matches A-Z a-z 0-9

fun alphanumericalRegex(): Regex

arrayBinSearch

Binary Search any kind of Array

fun <T : Comparable<T>> arrayBinSearch(array: Array<T>, element: T, start: Int = 0, end: Int): Int

currentMillis

Get the current system time in milli seconds

fun currentMillis(): Long

eHandled

Run code with T return inside Try-Catch

fun <T> eHandled(block: () -> T): Any?

equal

Check if a and b are equal

fun equal(a: Any, b: Any): Boolean

exceptionHandled

Run code with Boolean return status inside Try-Catch

fun exceptionHandled(block: () -> Boolean): Boolean

kLibRequire

Check if the used kLib is the required version (Dependency Check) If not, kLibInf.exit() is called

fun kLibRequire(version: SemVer): Unit
fun kLibRequire(min: SemVer, max: SemVer): Unit

kLibRequireMin

Check if the used kLib is at least the required version (Dependency Check) If not, kLibInf.exit() is called

fun kLibRequireMin(min: SemVer): Unit

kstring

StringBuilder DSL

fun kstring(builder: KString.() -> Unit): String

listQuicksort

Quicksort any kind of List

fun <T : Comparable<T>> listQuicksort(items: List<T>): List<T>

loadClass

Dynamically load a Class from a Jar File

fun loadClass(builder: LibLoad.() -> Unit): LClass

loadFunction

Dynamically load a Method/Function from a Jar File

fun loadFunction(builder: LibLoad.() -> Unit): LFunction

p

Create a Pair of A and B

fun <A, B> p(first: A, second: B): Pair<A, B>

pairOf

Create a Pair of A and B

fun <A, B> pairOf(first: A, second: B): Pair<A, B>

print

Print a list of arguments

fun print(vararg messages: Any?): Unit

println

Print a list of arguments

fun println(vararg messages: Any?): Unit

prompt

Text Prompt generic

fun <T> prompt(text: String, default: T? = null, reader: () -> String? = ::readLine, printer: (String) -> Unit = ::print, dateFormat: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd")): T?

readInt

Read Int from STDIN

fun readInt(default: Int = -1): Int

readLong

Read Long from STDIN

fun readLong(default: Long = -1L): Long

requireAllOrFail

Require something to be not null; Else execute onError

fun requireAllOrFail(vararg somethings: Any?, onError: Function): Unit

requireOrFail

Require something to be not null; Else execute onError

fun requireOrFail(something: Any?, onError: Function): Unit

runRandom

fun runRandom(range: IntRange = IntRange(1, 10), target: Int = 5, block: () -> Unit): Unit

using

.Net like function that proxies Kotlin's .use

fun <T : Closeable?, R> using(receiver: T, block: (T) -> R): R