This project contains a set of libraries providing tools for expressive programming in Kotlin.
Libraries
Kotools Types
Versions 1, 2 and 3 are not maintained anymore. Please find the new one in this repository.
Kotools Types provides explicit types like NonZeroInt
or NotBlankString
for
the following platforms: JVM, JS, Linux x64, macOS x64 and Windows x64.
import kotools.types.number.StrictlyPositiveInt
import kotools.types.number.toStrictlyPositiveInt
import kotools.types.text.NotBlankString
import kotools.types.text.toNotBlankString
data class Person(val name: NotBlankString, val age: StrictlyPositiveInt)
fun main() {
val name: NotBlankString = "Somebody".toNotBlankString()
.getOrThrow()
val age: StrictlyPositiveInt = 42.toStrictlyPositiveInt()
.getOrThrow()
val somebody = Person(name, age)
println(somebody) // Person(name=Somebody, age=42)
}
Kotools CSV
Kotools CSV is a JVM library for managing CSV files an expressive DSL.
data class Person(val name: String, val age: Int, val isAdmin: Boolean = false)
suspend fun main() {
csvWriter<Person> {
file = "people"
records { +Person("Nobody", 25) }
}
val people: List<Person> = csvReader { file = "people" }
println(people)
}
Kotools Assert
Kotools Assert provides additional assertions for the following platforms: JVM, JS, Linux x64, macOS x64 and Windows x64.
1 assertEquals 1
2 assertNotEquals 0
assertNull { null }
null.assertNull()
assertNotNull { 3 }
3.assertNotNull()
assertPass { println("Hello") }
assertFails { throw Exception() }
assertFailsWith<RuntimeException> { throw RuntimeException() }
Installation
Gradle
Kotlin DSL
implementation("io.github.kotools:csv:2.2.1")
implementation("io.github.kotools:types:3.2.0")
testImplementation("io.github.kotools:assert:3.0.2")
Groovy DSL
implementation "io.github.kotools:csv:2.2.1"
implementation "io.github.kotools:types:3.2.0"
testImplementation "io.github.kotools:assert:3.0.2"
Maven
<dependencies>
<dependency>
<groupId>io.github.kotools</groupId>
<artifactId>csv</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>io.github.kotools</groupId>
<artifactId>types</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>io.github.kotools</groupId>
<artifactId>assert</artifactId>
<version>3.0.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Documentation
Latest documentation of those libraries is available here.
Contributing
Feel free to contribute to this project with issues and pull requests.
This project follows the Conventional Commits guidelines for committing with Git. Please read the specifications before committing to this project.
License
All libraries are licensed under the MIT License.