Package pw.forst.katlib

Types

InstantTimeProvider
Link copied to clipboard
object InstantTimeProvider : TimeProvider<Instant>
Implementation of TimeProvider providing access to Instant.now method.
TimeProvider
Link copied to clipboard
fun fun interface TimeProvider<T : Temporal>
Interface providing access to current time via now method.

Functions

applyIf
Link copied to clipboard
inline fun <T : Any> T.applyIf(shouldApply: Boolean, block: T.() -> Unit): T
Calls the specified function block with this value as its receiver if and only if the shouldApply parameter is true.
inline fun <T : Any> T.applyIf(shouldApplyBlock: (T) -> Boolean, block: T.() -> Unit): T
Calls the specified function block with this value as its receiver if and only if the shouldApplyBlock lambda returns true.
applyIfNotNull
Link copied to clipboard
inline fun <T : Any, V : Any> T.applyIfNotNull(value: V?, block: T.(V) -> Unit): T
Applies given block if the value is not null, supplies non-nullable value to the block as an input.
asList
Link copied to clipboard
fun <T : Any> T.asList(): List<T>
Creates a single element list from this.
assoc
Link copied to clipboard
fun <K, V> Iterable<Pair<K, V>>.assoc(): Map<K, V>
Returns a Map containing key-value pairs provided by elements of the given collection.
fun <K, V> Sequence<Pair<K, V>>.assoc(): Map<K, V>
Returns a Map containing key-value pairs provided by elements of the given collection.
inline fun <T, K, V> Iterable<T>.assoc(transform: (T) -> Pair<K, V>): Map<K, V>
Returns a Map containing key-value pairs provided by transform function applied to elements of the given collection.
inline fun <T, K, V> Sequence<T>.assoc(transform: (T) -> Pair<K, V>): Map<K, V>
Returns a Map containing key-value pairs provided by transform function applied to elements of the given collection.
assocBy
Link copied to clipboard
inline fun <T, K> Iterable<T>.assocBy(keySelector: (T) -> K): Map<K, T>
Returns a Map containing the elements from the given collection indexed by the key returned from keySelector function applied to each element.
inline fun <T, K> Sequence<T>.assocBy(keySelector: (T) -> K): Map<K, T>
Returns a Map containing the elements from the given collection indexed by the key returned from keySelector function applied to each element.
inline fun <T, K, V> Iterable<T>.assocBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V>
Returns a Map containing the values provided by valueTransform and indexed by keySelector functions applied to elements of the given collection.
inline fun <T, K, V> Sequence<T>.assocBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V>
Returns a Map containing the values provided by valueTransform and indexed by keySelector functions applied to elements of the given collection.
assocByTo
Link copied to clipboard
inline fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.assocByTo(destination: M, keySelector: (T) -> K): M
Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function applied to each element of the given collection and value is the element itself.
inline fun <T, K, M : MutableMap<in K, in T>> Sequence<T>.assocByTo(destination: M, keySelector: (T) -> K): M
Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function applied to each element of the given collection and value is the element itself.
inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.assocByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M
Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function and value is provided by the valueTransform function applied to elements of the given collection.
inline fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.assocByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M
Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function and value is provided by the valueTransform function applied to elements of the given collection.
assocTo
Link copied to clipboard
fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.assocTo(destination: M): M
Populates and returns the destination mutable map with key-value pairs provided by elements of the given collection.
fun <K, V, M : MutableMap<in K, in V>> Sequence<Pair<K, V>>.assocTo(destination: M): M
Populates and returns the destination mutable map with key-value pairs provided by elements of the given collection.
inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.assocTo(destination: M, transform: (T) -> Pair<K, V>): M
Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each element of the given collection.
inline fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.assocTo(destination: M, transform: (T) -> Pair<K, V>): M
Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each element of the given collection.
assocWith
Link copied to clipboard
inline fun <K, V> Iterable<K>.assocWith(valueSelector: (K) -> V): Map<K, V>
Returns a Map where keys are elements from the given collection and values are produced by the valueSelector function applied to each element.
inline fun <K, V> Sequence<K>.assocWith(valueSelector: (K) -> V): Map<K, V>
Returns a Map where keys are elements from the given collection and values are produced by the valueSelector function applied to each element.
assocWithTo
Link copied to clipboard
inline fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.assocWithTo(destination: M, valueSelector: (K) -> V): M
Populates and returns the destination mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the valueSelector function applied to that key.
inline fun <K, V, M : MutableMap<in K, in V>> Sequence<K>.assocWithTo(destination: M, valueSelector: (K) -> V): M
Populates and returns the destination mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the valueSelector function applied to that key.
cartesianProduct
Link copied to clipboard
fun <T> Iterable<Iterable<T>>.cartesianProduct(): List<List<T>>
List cartesian production.
fun <T1, T2> Iterable<T1>.cartesianProduct(other: Iterable<T2>): Set<Pair<T1, T2>>
Creates cartesian product between all the elements from this and other iterable.
createJson
Link copied to clipboard
fun <T : Any> createJson(value: T): String
Serializes given object to string.
createJsonBytes
Link copied to clipboard
fun <T : Any> createJsonBytes(value: T): ByteArray
Serializes given object to byte array.
createPrettyJson
Link copied to clipboard
fun <T : Any> createPrettyJson(value: T): String
Serializes given object to string.
dominantValueBy
Link copied to clipboard
inline fun <T, R> Iterable<T>.dominantValueBy(crossinline selector: (T) -> R): R?
Returns the most frequently occurring value of the given function or null if there are no elements.
durationInMilli
Link copied to clipboard
fun durationInMilli(a: Instant, b: Instant): Long
Computes duration in milliseconds between two Instant instances.
durationToInMilli
Link copied to clipboard
fun Instant.durationToInMilli(other: Instant): Long
Computes duration in milliseconds between two Instant instances.
filterNotNullBy
Link copied to clipboard
inline fun <T : Any, R : Any> Iterable<T?>.filterNotNullBy(selector: (T) -> R?): List<T>
Returns a list containing only the non-null results of applying the given transform function to each element in the original collection.
flatMapIndexedNotNull
Link copied to clipboard
inline fun <T, R> Iterable<T>.flatMapIndexedNotNull(transform: (index: Int, T) -> Iterable<R>?): List<R>
Returns a single list of all not null elements yielded from results of transform function being invoked on each element of original collection.
flatMapIndexedTo
Link copied to clipboard
inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(destination: C, transform: (index: Int, T) -> Iterable<R>?): C
Appends all elements yielded from results of transform function being invoked on each element of original collection, to the given destination.
flatMapToSet
Link copied to clipboard
inline fun <T, R> Iterable<T>.flatMapToSet(transform: (T) -> Iterable<R>): Set<R>
Applies the given transform function to each element of the original collection and returns results as Set.
flatMerge
Link copied to clipboard
fun <K, V : Any> Iterable<Map<K, List<V>>>.flatMerge(): Map<K, List<V>>
For each key, merges all the list into one common list.
flattenToLists
Link copied to clipboard
fun <A, B, C> Iterable<Triple<A, B, C>>.flattenToLists(): Triple<List<A>, List<B>, List<C>>
Returns three lists with separated values from list of triples.
foldValidated
Link copied to clipboard
inline fun <S, T : S> Iterable<T>.foldValidated(validationFunction: (S, T) -> Boolean): Boolean
Validates the relationship between every element of Iterable.
forEachNotNull
Link copied to clipboard
inline fun <T : Any> Iterable<T?>.forEachNotNull(action: (T) -> Unit)
Performs the given action on each element that is not null.
getDateRangeTo
Link copied to clipboard
fun LocalDate.getDateRangeTo(to: LocalDate): List<LocalDate>
Returns list of days from this date to to date (both inclusive).
getDateRangeToAsStream
Link copied to clipboard
fun LocalDate.getDateRangeToAsStream(to: LocalDate): Stream<LocalDate>
Returns stream of days from this date to to date (both inclusive).
getDayDifference
Link copied to clipboard
fun LocalDate.getDayDifference(to: LocalDate): Int
Returns number of days between this date and to date (exclusive).
getDaysInInterval
Link copied to clipboard
fun LocalDate.getDaysInInterval(to: LocalDate): Int
Returns number of days in interval between this date and to date (both inclusive).
getEnv
Link copied to clipboard
fun getEnv(variableName: String): String?
Retrieves environment variable from the system.
inline fun getEnv(variableName: String, recoverBlock: () -> String): String
Retrieves environment variable from the system, if the value is not found, recoverBlock is executed.
getInvertedDateRangeToAsStream
Link copied to clipboard
fun LocalDate.getInvertedDateRangeToAsStream(to: LocalDate): Stream<LocalDate>
Returns stream of decreasing days from this date to to date (both inclusive).
getKeysInWeightedRandomOrder
Link copied to clipboard
fun <T> Map<T, Double>.getKeysInWeightedRandomOrder(normalizer: Double, rand: Random): List<T>
Randomly sorts the items with respect to the current weight distribution.
getRandomElement
Link copied to clipboard
fun <E> Iterable<E>.getRandomElement(rand: Random): E
Function that will return a random element from the iterable.
getSecondLevelValues
Link copied to clipboard
fun <K1, K2, V> Map<K1, Map<K2, V>>.getSecondLevelValues(): Set<V>
Collects all the values from the bottom level into set.
getSecondLevelValuesTo
Link copied to clipboard
fun <K1, K2, V, M : MutableCollection<V>> Map<K1, Map<K2, V>>.getSecondLevelValuesTo(destination: M): M
Collects all the values from the bottom level into the given collection M.
getThirdLevelValues
Link copied to clipboard
fun <K1, K2, K3, V> Map<K1, Map<K2, Map<K3, V>>>.getThirdLevelValues(): Set<V>
Collects all the values from the bottom level into set.
getThirdLevelValuesTo
Link copied to clipboard
fun <K1, K2, K3, V, M : MutableCollection<V>> Map<K1, Map<K2, Map<K3, V>>>.getThirdLevelValuesTo(destination: M): M
Collects all the values from the bottom level into the given collection M.
getWeekOfYear
Link copied to clipboard
fun LocalDate.getWeekOfYear(locale: Locale = Locale.GERMANY): Int
Returns week of year for this.
getWeightedRandom
Link copied to clipboard
fun <T> Map<T, Double>.getWeightedRandom(rand: Random): T
Randomly selects item with respect to the current weight distribution.
hashWith256
Link copied to clipboard
fun hashWith256(fileToHash: File): String
Creates SHA256 hash of the given file.
fun hashWith256(bytes: ByteArray): String
Creates SHA256 hash of the given byte array.
fun hashWith256(textToHash: String): String
Creates SHA256 hash of the given text.
intersect
Link copied to clipboard
fun <T> Iterable<Iterable<T>?>.intersect(): Set<T>
Creates intersection of the given iterables.
intersects
Link copied to clipboard
fun <T : Comparable<T>> ClosedRange<T>.intersects(other: ClosedRange<T>): Boolean
Returns true when there is at least one element x for which x in this and x in other returns true.
isEmail
Link copied to clipboard
fun String.isEmail(): Boolean
Checks if string is valid email address.
isEmpty
Link copied to clipboard
fun <T> Iterable<T>.isEmpty(): Boolean
Returns true if the iterable is empty.
isURL
Link copied to clipboard
fun String.isUrl(): Boolean
See documentation for isUrl.
fun isUrl(candidateUrl: String): Boolean
Check whether a given string is a valid URL.
isUUID
Link copied to clipboard
fun String.isUuid(): Boolean
See documentation for isUuid.
fun isUuid(candidateUuid: String): Boolean
Check whether a given string is a valid UUID.
itemsToString
Link copied to clipboard
inline fun <TItem> Iterable<TItem>.itemsToString(itemsType: String = "items", separator: String = ", ", itemLength: Int = 30, totalLength: Int = 200, itemToString: (TItem) -> String = { item -> item.toShortString() }): String
Formats a collection of TItems to a readable string like "3 colors: red, yellow, green".
jacksonMapper
Link copied to clipboard
fun jacksonMapper(): ObjectMapper
Standard ObjectMapper configured in a way the platform operates.
join
Link copied to clipboard
inline fun <K, V1, V2, VR> Map<K, V1>.join(other: Map<K, V2>, join: (V1?, V2?) -> VR): Map<K, VR>
Joins two maps together using the given join function.
joinTo
Link copied to clipboard
inline fun <K, V1, V2, VR, M : MutableMap<K, VR>> Map<K, V1>.joinTo(destination: M, other: Map<K, V2>, join: (V1?, V2?) -> VR): M
Joins two maps together using the given join function into the given destination.
kClass
Link copied to clipboard
inline fun <T : Any> kClass(): KClass<T>
A function used to get the instance of class.
lazyCartesianProduct
Link copied to clipboard
fun <T> Iterable<Iterable<T>>.lazyCartesianProduct(): Sequence<List<T>>
Lazy cartesian production.
letLeft
Link copied to clipboard
inline fun <T, NT, V> Pair<T, V>.letLeft(block: (T) -> NT): Pair<NT, V>
Applies block on left part of pair.
letPair
Link copied to clipboard
inline fun <T, V, NT, NV> Pair<T, V>.letPair(leftBlock: (T) -> NT, rightBlock: (V) -> NV): Pair<NT, NV>
Applies leftBlock on left part and rightBlock on right part.
letRight
Link copied to clipboard
inline fun <T, V, NV> Pair<T, V>.letRight(block: (V) -> NV): Pair<T, NV>
Applies block on right part of pair.
mapLeft
Link copied to clipboard
inline fun <T, NT, V> Pair<Iterable<T>, V>.mapLeft(block: (T) -> NT): Pair<Iterable<NT>, V>
Applies block on left part of pair in List.
mapPair
Link copied to clipboard
inline fun <T, V, NT, NV> Pair<Iterable<T>, Iterable<V>>.mapPair(leftBlock: (T) -> NT, rightBlock: (V) -> NV): Pair<Iterable<NT>, Iterable<NV>>
Applies leftBlock on left part and rightBlock on right part.
mapRight
Link copied to clipboard
inline fun <T, V, NV> Pair<T, Iterable<V>>.mapRight(block: (V) -> NV): Pair<T, Iterable<NV>>
Applies block on right part of pair in List.
mapToSet
Link copied to clipboard
inline fun <T, R> Iterable<T>.mapToSet(transform: (T) -> R): Set<R>
Applies the given transform function to each element of the original collection and returns results as Set.
max
Link copied to clipboard
fun <E> SortedSet<E>.max(): E?
Returns the last item in this sorted set.
maxValueBy
Link copied to clipboard
inline fun <T, R : Comparable<R>> Iterable<T>.maxValueBy(selector: (T) -> R): R?
Returns the largest value of the given function or null if there are no elements.
merge
Link copied to clipboard
fun <K, V : Any> Iterable<Map<K, V>>.merge(): Map<K, List<V>>
For each key, merges all the values into one common list.
mergeReduce
Link copied to clipboard
inline fun <K, V> Map<K, V>.mergeReduce(other: Map<K, V>, reduce: (V, V) -> V = { a, _ -> a }): Map<K, V>
Merges two maps together using the given reduce function.
mergeReduceTo
Link copied to clipboard
inline fun <K, V, M : MutableMap<K, V>> Map<K, V>.mergeReduceTo(destination: M, other: Map<K, V>, reduce: (V, V) -> V = { a, _ -> a }): M
Merges two maps together using the given reduce function into the given destination.
min
Link copied to clipboard
fun <E> SortedSet<E>.min(): E?
Returns the first item in this sorted set.
minValueBy
Link copied to clipboard
inline fun <T, R : Comparable<R>> Iterable<T>.minValueBy(selector: (T) -> R): R?
Returns the smallest value of the given function or null if there are no elements.
orNull
Link copied to clipboard
fun <T> Optional<T>.orNull(): T?
Returns value or null from Optional.
parseJson
Link copied to clipboard
inline fun <T> parseJson(json: ByteArray, logParserException: Boolean = true): T?
Tries to create instance of T from provided json, null is returned when it is not possible to parse it.
inline fun <T> parseJson(json: String, logParserException: Boolean = true): T?
Tries to create instance of T from provided json, null is returned when it is not possible to parse it.
prettyPrintJson
Link copied to clipboard
fun prettyPrintJson(json: String): String
Pretty print a json.
propagateNull
Link copied to clipboard
fun <A : Any, B : Any> Pair<A?, B?>.propagateNull(): Pair<A, B>?
When both items in pair are not null, returns non-nullable pair, otherwise returns null.
propertiesFromResources
Link copied to clipboard
inline fun <T : Any> T.propertiesFromResources(resourcesPath: String): Properties?
Loads properties file from the resources.
reduction
Link copied to clipboard
inline fun <T, R> Iterable<T>.reduction(initial: R, operation: (R, T) -> R): List<R>
Creates reduction of the given Iterable.
restrictLengthWithEllipsis
Link copied to clipboard
fun String.restrictLengthWithEllipsis(maxLength: Int, ellipsis: String = "…"): String
Shortens the string to maxLength; in such case, appends the ellipsis (typically "…" ).
setDifferenceBy
Link copied to clipboard
inline fun <T, R> Iterable<T>.setDifferenceBy(other: Iterable<T>, selector: (T) -> R): List<T>
Returns all values that are in this and not in other with custom selector.
setWeekOfYearMonday
Link copied to clipboard
fun LocalDate.setWeekOfYearMonday(week: Int, locale: Locale = Locale.GERMANY): LocalDate
Returns this LocalDate with week of the year set to week and day of the week set to DayOfWeek.MONDAY.
singleOrEmpty
Link copied to clipboard
fun <T> Iterable<T>.singleOrEmpty(): T?
Returns single element, or null if the collection is empty.
inline fun <T> Iterable<T>.singleOrEmpty(predicate: (T) -> Boolean): T?
Returns the single element matching the given predicate, or null if element was not found.
splitPairCollection
Link copied to clipboard
fun <T, V> Iterable<Pair<T, V>>.splitPairCollection(): Pair<List<T>, List<V>>
Takes Iterable with pairs and returns pair of collections filled with values in each part of pair.
stacktraceToString
Link copied to clipboard
fun Throwable.stacktraceToString(): String
Converts stacktrace to the string.
startsWithLetter
Link copied to clipboard
fun String.startsWithLetter(): Boolean
Returns true if the string starts with a latin letter a-z or A-Z.
sumByFloat
Link copied to clipboard
inline fun <T> Iterable<T>.sumByFloat(selector: (T) -> Float): Float
Sum collection by float as this is missing in the stdlib...
sumByIndexes
Link copied to clipboard
fun Iterable<List<Int>>.sumByIndexes(): List<Int>
Sums all Lists of integers into single one by indexes (i.e.
sumByLong
Link copied to clipboard
inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long
Returns the sum of all values produced by selector function applied to each element in the collection.
inline fun <T> Sequence<T>.sumByLong(selector: (T) -> Long): Long
Returns the sum of all values produced by selector function applied to each element in the sequence.
sumDoublesByIndexes
Link copied to clipboard
fun Iterable<List<Double>>.sumDoublesByIndexes(): List<Double>
Sums all Lists of integers into single one by indexes (i.e.
swapKeys
Link copied to clipboard
fun <K1, K2, V> Map<K1, Map<K2, V>>.swapKeys(): Map<K2, Map<K1, V>>
Swaps dimensions in two dimensional map.
inline fun <K1, K2, K3, KR1, KR2, KR3, V> Map<K1, Map<K2, Map<K3, V>>>.swapKeys(transform: (K1, K2, K3) -> Triple<KR1, KR2, KR3>): Map<KR1, Map<KR2, Map<KR3, V>>>
Works similarly as swapKeys but the final map has three levels.
swapKeysTo
Link copied to clipboard
inline fun <K1, K2, V, M2 : MutableMap<K1, V>, M1 : MutableMap<K2, M2>> Map<K1, Map<K2, V>>.swapKeysTo(topDestination: M1, bottomDestination: () -> M2): M1
Swaps dimensions in two dimensional map.
inline fun <K1, K2, K3, KR1, KR2, KR3, V, M3 : MutableMap<KR3, V>, M2 : MutableMap<KR2, M3>, M1 : MutableMap<KR1, M2>> Map<K1, Map<K2, Map<K3, V>>>.swapKeysTo(topDestination: M1, middleDestination: () -> M2, bottomDestination: () -> M3, transform: (K1, K2, K3) -> Triple<KR1, KR2, KR3>): M1
Works similarly as swapKeys but the final map has three levels.
toLocalDate
Link copied to clipboard
fun Date.toLocalDate(zoneId: ZoneId): LocalDate
Convert Date to LocalDate.
toLongString
Link copied to clipboard
fun Any.toLongString(description: String, brackets: String = "()", className: String? = null): String
Creates a string like "className(description)", for example "Double(42.0)" Useful e.g.
toNavigableSet
Link copied to clipboard
fun <T> Iterable<T>.toNavigableSet(comparator: Comparator<in T>): NavigableSet<T>
Returns a NavigableSet of all elements.
toShortString
Link copied to clipboard
fun Any?.toShortString(): String
Extracts the essential information from an object (most usually a string), whose toString() call result has a similar format as the output of function toLongString .
toThreeLevelMap
Link copied to clipboard
fun <K1, K2, K3, V> Map<Triple<K1, K2, K3>, V>.toThreeLevelMap(): Map<K1, Map<K2, Map<K3, V>>>
Works similarly as toTwoLevelMap but the final map has three levels.
inline fun <K1, K2, K3, V, M3 : MutableMap<K3, V>, M2 : MutableMap<K2, M3>, M1 : MutableMap<K1, M2>> Map<Triple<K1, K2, K3>, V>.toThreeLevelMap(topDestination: M1, middleDestination: () -> M2, bottomDestination: () -> M3): M1
Works similarly as toTwoLevelMap but the final map has three levels.
toTwoLevelMap
Link copied to clipboard
fun <K1, K2, V> List<Pair<Pair<K1, K2>, V>>.toTwoLevelMap(): Map<K1, Map<K2, V>>
Transforms list of pairs, where the first element consists of pairs into two-dimensional map where the first elements from the inner pair are used as primary keys and second elements as secondary keys.
fun <K1, K2, V> Map<Pair<K1, K2>, V>.toTwoLevelMap(): Map<K1, Map<K2, V>>
Transforms map of pairs as a keys into two-dimensional map where the first elements in the pair are used as primary keys and second elements as secondary keys.
inline fun <K1, K2, V, M2 : MutableMap<K2, V>, M1 : MutableMap<K1, M2>> List<Pair<Pair<K1, K2>, V>>.toTwoLevelMap(topDestination: M1, bottomDestination: () -> M2): M1
Transforms list of pairs, where the first element consists of pairs into two-dimensional map where the first elements from the inner pair are used as primary keys and second elements as secondary keys.
inline fun <K1, K2, V, M2 : MutableMap<K2, V>, M1 : MutableMap<K1, M2>> Map<Pair<K1, K2>, V>.toTwoLevelMap(topDestination: M1, bottomDestination: () -> M2): M1
Transforms map of pairs as a keys into two-dimensional map where the first elements in the pair are used as primary keys and second elements as secondary keys.
toUrl
Link copied to clipboard
fun String.toUrl(): URL
Creates URL instance from this string.
toUtcLocalDate
Link copied to clipboard
fun Date.toUtcLocalDate(): LocalDate
Convert Date to LocalDate with zone set to UTC.
toUuid
Link copied to clipboard
fun ByteArray.toUuid(): UUID
Read ByteArray as two longs and combine the to UUID.
fun String.toUuid(): UUID
Converts given string to UUID.
toUuidFlipped
Link copied to clipboard
fun ByteArray.toUuidFlipped(): UUID
Read ByteArray as two longs and combine the to UUID.
union
Link copied to clipboard
fun <T> Iterable<Iterable<T>?>.union(): Set<T>
Creates union of the given iterables.
validate
Link copied to clipboard
inline fun <T> T.validate(isValid: Boolean, invalidBlock: (T) -> Unit): T
If isValid is true, executes invalidBlock.
inline fun <T> T.validate(isValidSelector: (T) -> Boolean, invalidBlock: (T) -> Unit): T
If isValidSelector returns true, executes invalidBlock.
whenFalse
Link copied to clipboard
inline fun Boolean.whenFalse(block: () -> Unit): Boolean
Executes block iff this (result of previous method) is false.
whenNull
Link copied to clipboard
inline fun <T> T.whenNull(block: () -> Unit): T
Calls the specified function block only when this value is null and then returns this value.
whenTrue
Link copied to clipboard
inline fun Boolean.whenTrue(block: () -> Unit): Boolean
Executes block iff this (result of previous method) is true.
with
Link copied to clipboard
infix fun <T : Any> T.with(other: T): List<T>
Creates collection of this and other.
zip
Link copied to clipboard
inline fun <A, B, C, V> Iterable<A>.zip(b: Iterable<B>, c: Iterable<C>, transform: (A, B, C) -> V): List<V>
Zip alternative for three collections.

Properties

newLine
Link copied to clipboard
val newLine: String
Shortcut for System.lineSeparator.