Package-level declarations

Platform information and other useful utilities. Includes basic program settings support at the Platform object (like loading and retrieving system settings).

Types

Link copied to clipboard
abstract class MapResourceBundle(val map: Map<*, *>) : ListResourceBundle

Properties

Link copied to clipboard
val countryCodes: Set<String>

Set of allowed country codes in this JVM.

Link copied to clipboard
val currencyCodes: Set<String>

Set of allowed currency codes in this JVM.

Link copied to clipboard
val languageCodes: Set<String>

Set of allowed language codes in this JVM.

Functions

Link copied to clipboard
fun UUID.bytes(): ByteArray
Link copied to clipboard
fun check(message: String, vararg blocks: () -> Unit)

Execute a list of code block collecting the exceptions they may throw, in case there is any error, it throws a MultipleException with all the thrown exceptions.

Link copied to clipboard
fun <Z> Collection<Z>.checkSize(count: IntRange): Collection<Z>

Ensure a collection has a fixed number of elements.

Link copied to clipboard
fun countryOf(country: String): Locale
Link copied to clipboard
fun countryOfOrNull(country: String): Locale?
Link copied to clipboard
fun String.exec(workingDirectory: File = File(System.getProperty("user.dir")), timeout: Long = Long.MAX_VALUE, fail: Boolean = false): String

TODO Add use case and example in documentation. TODO Support multiple words parameters by processing " and '

fun List<String>.exec(workingDirectory: File = File(System.getProperty("user.dir")), timeout: Long = Long.MAX_VALUE, fail: Boolean = true): String
Link copied to clipboard
fun languageOf(language: String): Locale
Link copied to clipboard
fun languageOfOrNull(language: String): Locale?
Link copied to clipboard
fun localeOf(language: String = "", country: String = ""): Locale
Link copied to clipboard
fun localeOfOrNull(language: String = "", country: String = ""): Locale?
Link copied to clipboard
fun parseLocale(languageCountry: String): Locale
Link copied to clipboard
fun parseLocaleOrNull(languageCountry: String): Locale?
Link copied to clipboard
fun properties(url: URL): Map<String, String>

Load a '*.properties' file from a URL transforming the content into a plain map. If the resource can not be found, a com.hexagontk.core.ResourceNotFoundException is thrown.

Link copied to clipboard
fun <T : Any, N> T.requireGreater(field: KProperty1<T, Comparable<N>?>, min: N)
fun <T : Any, N> T.requireGreater(field: KProperty1<T, Comparable<N>?>, field2: KProperty1<T, N?>)
Link copied to clipboard
fun <T : Any, N> T.requireGreaterOrEquals(field: KProperty1<T, Comparable<N>?>, min: N)
fun <T : Any, N> T.requireGreaterOrEquals(field: KProperty1<T, Comparable<N>?>, field2: KProperty1<T, N?>)
Link copied to clipboard
fun <T : Any, N> T.requireLower(field: KProperty1<T, Comparable<N>?>, min: N)
fun <T : Any, N> T.requireLower(field: KProperty1<T, Comparable<N>?>, field2: KProperty1<T, N?>)
Link copied to clipboard
fun <T : Any, N> T.requireLowerOrEquals(field: KProperty1<T, Comparable<N>?>, min: N)
fun <T : Any, N> T.requireLowerOrEquals(field: KProperty1<T, Comparable<N>?>, field2: KProperty1<T, N?>)
Link copied to clipboard
fun <T : Any> T.requireNotBlank(field: KProperty1<T, CharSequence?>)
Link copied to clipboard
fun <T : Any> T.requireNotBlanks(field: KProperty1<T, Collection<CharSequence>?>)
Link copied to clipboard
inline fun <T : ResourceBundle> resourceBundle(locale: Locale = Locale.getDefault()): ResourceBundle
fun <T : ResourceBundle> resourceBundle(type: KClass<T>, locale: Locale = Locale.getDefault()): ResourceBundle
Link copied to clipboard
fun <T> retry(times: Int, delay: Long, block: () -> T): T

Execute a lambda until no exception is thrown or a number of times is reached.

Link copied to clipboard
fun String.shell(workingDirectory: File = File(System.getProperty("user.dir")), timeout: Long = Long.MAX_VALUE, fail: Boolean = false): String

Executes a command in a shell (allowing to use pipes, redirections, etc.).

Link copied to clipboard
fun UUID.toBase64(): String
Link copied to clipboard
fun uuid(bytes: ByteArray): UUID
fun uuid(text: String): UUID