Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard

Implementation of TimeProvider providing access to Instant.now method.

Link copied to clipboard

Implementation of TimeProvider providing access to LocalDateTime.now method.

Link copied to clipboard

This name makes a bit more sense as we're constraining to temporal.

Link copied to clipboard
fun interface TimeProvider<T : Temporal>

Interface providing access to current time via now method.

Functions

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. Returns this value.

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. Returns this value.

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.

Link copied to clipboard
fun <T : Any> T.asList(): List<T>

Creates a single element list from this.

Link copied to clipboard
fun <K, V> Iterable<Pair<K, V>>.assoc(): Map<K, V>
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>
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.

Link copied to clipboard
inline fun <T, K> Iterable<T>.assocBy(keySelector: (T) -> K): Map<K, T>
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>
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.

Link copied to clipboard
inline fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.assocByTo(destination: M, keySelector: (T) -> K): M
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
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.

Link copied to clipboard
fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.assocTo(destination: M): M
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
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.

Link copied to clipboard
inline fun <K, V> Iterable<K>.assocWith(valueSelector: (K) -> V): Map<K, V>
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.

Link copied to clipboard
inline fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.assocWithTo(destination: M, valueSelector: (K) -> V): M
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.

Link copied to clipboard
inline fun <E> buildArray(builderAction: MutableList<E>.() -> Unit): Array<E>

Builds a new Array by populating a MutableList using the given builderAction and returning an Array with the same elements.

Link copied to clipboard

List cartesian production.

Creates cartesian product between all the elements from this and other iterable. E.g. when this contains 1,2,3 and other contains 'a', 'b', the result will be {Pair(1,'a'), Pair(1,'b'), Pair(2,'a'), Pair(2,'b'), Pair(3,'a'), Pair(3,'b')}.

Link copied to clipboard

Computes MD5 from given byte array, returns base64 encoded data.

Link copied to clipboard
fun <T : Any> createJson(value: T): String

Serializes given object to string.

Link copied to clipboard
fun <T : Any> createJsonBytes(value: T): ByteArray

Serializes given object to byte array.

Link copied to clipboard
fun <T : Any> createPrettyJson(value: T): String

Serializes given object to string.

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.

Link copied to clipboard

Computes duration in milliseconds between two Instant instances.

Link copied to clipboard

Computes duration in milliseconds between two Instant instances.

Link copied to clipboard
infix fun String?.equalsIgnoreCase(other: String?): Boolean

Compares two strings ignoring case.

Link copied to clipboard
inline fun <T> Array<out T>.filter(predicate: (T) -> Boolean): Array<T>

Returns an array containing only elements matching the given predicate.

Link copied to clipboard
inline fun <T> Array<out T>.filterIndexed(predicate: (index: Int, T) -> Boolean): Array<T>

Returns an array containing only elements matching the given predicate.

Link copied to clipboard
inline fun <R> Array<*>.filterIsInstance(): Array<R>

Returns an array containing all elements that are instances of specified type parameter R.

Link copied to clipboard
inline fun <T> Array<out T>.filterNot(predicate: (T) -> Boolean): Array<T>

Returns an array containing all elements not matching the given predicate.

Link copied to clipboard
inline fun <T : Any> Array<out T?>.filterNotNull(): Array<T>

Returns an array containing all elements that are not null.

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.

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.

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.

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.

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.

Link copied to clipboard

Returns three lists with separated values from list of triples.

Link copied to clipboard
inline fun <S, T : S> Iterable<T>.foldValidated(validationFunction: (acc: S, T) -> Boolean): Boolean

Validates the relationship between every element of Iterable.

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.

Link copied to clipboard

Returns list of days from this date to to date (both inclusive).

Link copied to clipboard

Returns stream of days from this date to to date (both inclusive).

Link copied to clipboard

Returns number of days between this date and to date (exclusive). This means that this method returns 0 when this and to are equal.

Link copied to clipboard

Returns number of days in interval between this date and to date (both inclusive). This means that this method returns 1 when this and to are equal.

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.

Link copied to clipboard

Returns stream of decreasing days from this date to to date (both inclusive). This means that this date should be later than to date to obtain non-empty stream.

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. normalizer is used to normalize the random value obtained from rand to control how important the original weights are. With higher normalizer the importance of the random factor decreases.

Link copied to clipboard

Function that will return a random element from the iterable.

Link copied to clipboard

Collects all the values from the bottom level into set.

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.

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.

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.

Link copied to clipboard
fun LocalDate.getWeekOfYear(locale: Locale = Locale.GERMANY): Int

Returns week of year for this.

Link copied to clipboard

Randomly selects item with respect to the current weight distribution.

Link copied to clipboard
fun hashWithSha256(fileToHash: File): String

Creates SHA256 hash of the given file.

Creates SHA256 hash of the given byte array.

fun hashWithSha256(textToHash: String): String

Creates SHA256 hash of the given text.

Link copied to clipboard

Creates intersection of the given iterables.

Link copied to clipboard

Returns true when there is at least one element x for which x in this and x in other returns true.

Link copied to clipboard

Checks if string is valid email address.

Link copied to clipboard

Returns true if the iterable is empty. If this is a Collection, uses isEmpty, otherwise creates iterator and verifies whether it has next value.

Link copied to clipboard
fun isURL(candidateUrl: String): Boolean

See documentation for isUrl.

Link copied to clipboard
fun isUrl(candidateUrl: String): Boolean

Check whether a given string is a valid URL.

Link copied to clipboard

See documentation for isUrl.

Link copied to clipboard
fun isUUID(candidateUuid: String): Boolean

See documentation for isUuid.

Link copied to clipboard
fun isUuid(candidateUuid: String): Boolean

Check whether a given string is a valid UUID.

Link copied to clipboard

See documentation for isUuid.

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".

Link copied to clipboard
fun jacksonMapper(): ObjectMapper

Standard ObjectMapper configured in a way the platform operates.

fun jacksonMapper(objectMapperSettings: ObjectMapper.() -> Unit): ObjectMapper

ObjectMapper with registered Kotlin plugin and given settings.

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.

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.

Link copied to clipboard
inline fun <T : Any> kClass(): KClass<T>

A function used to get the instance of class. This method allows to get class instances even for generic classes, which cannot be obtained using :: notation.

Link copied to clipboard

Lazy cartesian production.

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.

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.

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.

Link copied to clipboard
inline fun <T, R> Array<out T>.map(transform: (T) -> R): Array<R>

Returns an array containing the results of applying the given transform function to each element in the original array.

Link copied to clipboard
inline fun <T, R> Array<out T>.mapIndexed(transform: (index: Int, T) -> R): Array<R>

Returns an array containing the results of applying the given transform function to each element and its index in the original array.

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.

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.

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.

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.

Link copied to clipboard
fun <E> SortedSet<E>.max(): E?

Returns the last item in this sorted set.

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.

Link copied to clipboard

Returns base64 string MD5 of given byte array.

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.

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. By default, the reduce function keeps the value from this map.

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. By default, the reduce function keeps the value from this map.

Link copied to clipboard
fun <E> SortedSet<E>.min(): E?

Returns the first item in this sorted set.

Link copied to clipboard
inline operator fun <T> Array<out T>.minus(element: T): Array<T>

Returns an array containing all elements of the original collection without the first occurrence of the given element.

inline operator fun <T> Array<out T>.minus(elements: Array<out T>): Array<T>

Returns an array containing all elements of the original collection except the elements contained in the given elements array.

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.

Link copied to clipboard
fun <T> Optional<T>.orNull(): T?

Returns value or null from Optional. Useful when using kotlin-like T? and Optional.

Link copied to clipboard
inline fun <T> parseJson(json: ByteArray, logParserException: Boolean = true): T?
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. If logParserException set to true and exception is raised during JSON parsing, it is logged.

Link copied to clipboard

Pretty print a json.

Link copied to clipboard
fun <R> prompt(promptText: String, exceptionHandler: (Exception) -> String? = { null }, transform: (input: String) -> R): R

Prints @param promptText, reads input from console and applies @param transform to it. If @param transform throws an exception on user input, @param exceptionHandler will be invoked, and prompt will be repeated.

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.

Link copied to clipboard
inline fun <T : Any> T.propertiesFromResources(resourcesPath: String): Properties?

Loads properties file from the resources. Returns null if the properties were not loaded.

Link copied to clipboard
fun <E> Iterable<E>.random(random: Random = Random): E

Function that will return a random element from the iterable.

Link copied to clipboard
inline fun <T, R> Iterable<T>.reduction(initial: R, operation: (acc: R, T) -> R): List<R>

Creates reduction of the given Iterable. This function can be used for example for cumulative sums.

Link copied to clipboard
fun String.restrictLengthWithEllipsis(maxLength: Int, ellipsis: String = "…"): String

Shortens the string to maxLength; in such case, appends the ellipsis (typically "…" ).

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.

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. I.e. when this date is 23-08-2019 and week is 2, the returned date is 07-01-2019.

Link copied to clipboard

Returns base64 encoded SHA256 of given byte array.

Link copied to clipboard

Returns single element, or null if the collection is empty. Throws IllegalArgumentException when multiple elements are matching predicate.

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.

Link copied to clipboard

Takes Iterable with pairs and returns a pair of collections filled with values in each part of pair.

Link copied to clipboard

Converts stacktrace to the string. Uses Throwable.printStackTrace and returns it as string.

Link copied to clipboard

Returns true if the string starts with a latin letter a-z or A-Z.

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 even after version 1.4.0.

Link copied to clipboard

Sums all Lists of integers into single one by indexes (i.e. all the numbers with the same index are always summed together). If the lists have different lengths, the final list has length corresponding to the shortest list in this iterable.

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.

Link copied to clipboard

Sums all Lists of integers into single one by indexes (i.e. all the numbers with the same index are always summed together). If the lists have different lengths, the final list has length corresponding to the shortest list in this iterable.

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. The returned map has keys from the second dimension as primary keys and primary keys are used in the second dimension.

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. transform specifies how the keys should be swapped (or modified) in the newly created map.

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. The returned map has keys from the second dimension as primary keys and primary keys are stored in the second dimension. topDestination specifies which map should be used to store the new primary keys and bottomDestination is used to store the new secondary keys.

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. transform specifies how the keys should be swapped (or modified) in the newly created map. topDestination specifies which map should be used to store the new primary keys, middleDestination is used to store the new secondary keys and bottomDestination is used to store the new tertiary keys.

Link copied to clipboard

Returns base64 string representation of given byte array.

Returns base64 representation of this string.

Link copied to clipboard

Convert Date to LocalDate. zoneId parameter sets the zone of the LocalDate instance.

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. for implementing .toString() override.

Link copied to clipboard
fun <T> Iterable<T>.toNavigableSet(comparator: Comparator<in T>): NavigableSet<T>

Returns a NavigableSet of all elements.

Link copied to clipboard

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 . If the format is not similar, it simply returns this.toString() .

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. topDestination specifies which map should be used to store the new primary keys, middleDestination is used to store the new secondary keys and bottomDestination is used to store the new tertiary keys.

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. topDestination specifies which map should be used to store the new primary keys and bottomDestination is used to store the new 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. topDestination specifies which map should be used to store the new primary keys and bottomDestination is used to store the new secondary keys.

Link copied to clipboard

Creates URL instance from this string.

Link copied to clipboard

Convert Date to LocalDate with zone set to UTC.

Link copied to clipboard

Read ByteArray as two longs and combine the to UUID.

Converts given string to UUID.

Link copied to clipboard

Read ByteArray as two longs and combine the to UUID.

Link copied to clipboard
fun <T> Iterable<Iterable<T>?>.union(): Set<T>

Creates union of the given iterables.

Link copied to clipboard
inline fun <T> T.validate(isValid: Boolean, invalidBlock: (T) -> Unit): T

If isValid is true, executes invalidBlock. Used mainly for validating entities -> do something when validation failed.

inline fun <T> T.validate(isValidSelector: (T) -> Boolean, invalidBlock: (T) -> Unit): T

If isValidSelector returns true, executes invalidBlock. Used mainly for validating entities -> do something when validation failed.

Link copied to clipboard
inline fun Boolean.whenFalse(block: () -> Unit): Boolean

Executes block iff this (result of previous method) is false. Returns given Boolean.

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.

Link copied to clipboard
inline fun Boolean.whenTrue(block: () -> Unit): Boolean

Executes block iff this (result of previous method) is true. Returns given Boolean.

Link copied to clipboard
infix fun <T : Any> T.with(other: T): List<T>

Creates collection of this and other.

Link copied to clipboard
inline fun <T> Iterable<T>.withEach(action: T.() -> Unit)

Performs the given action with each element as a receiver.

Link copied to clipboard
inline fun <T> Iterable<T>.withEachIndexed(action: T.(index: Int) -> Unit)

Performs the given action with each element as a receiver, providing sequential index with the element.

Link copied to clipboard
inline fun <A, B, C, V> Iterable<A>.zip(b: Iterable<B>, c: Iterable<C>, transform: (a: A, b: B, c: C) -> V): List<V>

Zip alternative for three collections.

Properties

Link copied to clipboard