Stardust 5
The Stardust library consists of different modules that can be included to fit your needs. The following sections provide a brief overview of the modules by showing some selected features.
Main Module
| Artifact: | 
                cc.persch:stardust
             | 
        
Stardust’s main module provides common functionalities for value checking, text building, localization, and a lot more.
String Building
String formatting was yesterday—with Kotlin’s type-safe builders, we have new capabilities to build things directly with Kotlin code. The Stardust library provides type-safe builders to comfortably create strings especially for the localization of multilingual applications.
fun ShoppingCart.makeString() = rope {
    +"Your shopping cart "
    if(size > 0) {
        +"contains "
        if(size > 1)
            +"$size"
        else
            +"one"
        +" item"
        plural(size, "s")
    }
    else
        +"is empty"
    +"."
}
println("Empty shopping cart:               ${ShoppingCart(0).makeString()}")
println("Shopping cart containing 1 item:   ${ShoppingCart(1).makeString()}")
println("Shopping cart containing 42 items: ${ShoppingCart(42).makeString()}")
Empty shopping cart:               Your shopping cart is empty.
Shopping cart containing 1 item:   Your shopping cart contains one item.
Shopping cart containing 42 items: Your shopping cart contains 42 items.
Extension Modules
CEH Computation Utility
| Artifact: | 
                cc.persch:stardustx-cehc
             | 
        
Provides utils to implement the equals, hashCode, and compareTo functions in a declarative manner.
Collections
| Artifact: | 
                cc.persch:stardustx-collections
             | 
        
Contains different collection types with a comfortable API.
Mutable Collections
val mutableList: MutableList<Int> = mutableListOf(1, 2, 3, 4, 5)
// Get an immutable view of the mutable list
val immutableView: ImmutableList<Int> = mutableList.asImmutable()
// Altering the original list …
mutableList.add(6)
println("Mutable list:   $mutableList")
// … also changes the immutable view
println("Immutable view: $immutableView")
Mutable list:   [1, 2, 3, 4, 5, 6]
Immutable view: [1, 2, 3, 4, 5, 6]
Persistent Collections
// Create a persistent list that is guaranteed to be immutable
val persistentList1: PersistentList<Int> = persistentListOf(1, 2, 3, 4, 5)
// Create a mutated persistent copy of the original list
val persistentList2: PersistentList<Int> = persistentList1.mutate { add(6) }
println("Original list: $persistentList1")
println("Mutated copy:  $persistentList2")
Original list: [1, 2, 3, 4, 5]
Mutated copy:  [1, 2, 3, 4, 5, 6]
Date and Time
| Artifact: | 
                cc.persch:stardustx-datetime
             | 
        
Stardust provides date and time classes with comfortable handling.
val date = Date.utcCurrent()
val dateTime = DateTime.utcNow()
val timeSpan = dateTime.minus(date.toUtcDateTime())
println("Date:     $date")
println("DateTime: $dateTime")
println("TimeSpan: $timeSpan")
Date:     2025-05-21
DateTime: 2025-05-21T19:52:42.832556638Z[UTC]
TimeSpan: PT19H52M42.832556638S
Event Handling
| Artifact: | 
                cc.persch:stardustx-events
             | 
        
Provides an easy-to-use event mechanism.
// Subscribe an event
eventSource.subscribe { _, arg -> println("Hello, ${arg.value}!") }
// Raise an event
eventSource.raise(this, EventArgument("Kotlin Notebook"))
Hello, Kotlin Notebook!
Results
| Artifact: | 
                cc.persch:stardustx-results
             | 
        
With Conclude and Unsure, Stardust provides two result types.
Where Unsure is used to indicate whether there is a result or not,
a Conclude additionally contains information about the error.
fun Users.find(username: String): Conclude<User, String> {
    return users.get(username) orFailure { "Username ${username.quote()} not found." }
    //             ↖ User?           ↖ Conclude<User, String>
    //                                      ↖ Either Success<User> or Failure<String>
}
println("""Find "jdoe":   ${users.find("jdoe")}""")
println("""Find "asmith": ${users.find("asmith")}""")
Find "jdoe":   Success(value=John Doe)
Find "asmith": Failure(reason=Username "asmith" not found.)
Text
| Artifact: | 
                cc.persch:stardustx-text
             | 
        
Contains lots of utilities to manipulate and parse character sequences.
UUID
| Artifact: | 
                cc.persch:stardustx-uuid
             | 
        
Provides utils for generating UUIDs of versions 3 and 5.
Experimental Module
| Artifact: | 
                cc.persch:stardusty
             | 
        
This module contains experimental features. The API of this module is unstable and may change anytime.
Use Stardust 5 in Your Software Project
The following code sample shows how you can include Stardust in your software project using the Gradle build tool.
Select the modules you want use and add them to your build.gradle.kts file.
New Package Registry URL
The former package registry is discontinued! The packages are now provided in the package registry of Stardust's GitLab repository.
Please make sure to use the new repository URL in your repository configuration:
https://gitlab.com/api/v4/projects/37316414/packages/maven
If you want to test the beta version of the upcoming version 6, you can follow the instructions on the page about Stardust 6.
repositories {
    // The URL to the Maven package registry to retrieve the artifacts of the Stardust library.
    // Find the GitLab repository under: <https://gitlab.com/jmpersch/stardust/-/packages>
    maven("https://gitlab.com/api/v4/projects/37316414/packages/maven")
}
dependencies {
    val stardustVersion = "5.1.3"
    // Main module
    implementation("cc.persch:stardust-jvm:$stardustVersion")
    // Extension modules
    implementation("cc.persch:stardustx-cehc-jvm:$stardustVersion")
    implementation("cc.persch:stardustx-collections-jvm:$stardustVersion")
    implementation("cc.persch:stardustx-datetime-jvm:$stardustVersion")
    implementation("cc.persch:stardustx-events-jvm:$stardustVersion")
    implementation("cc.persch:stardustx-results-jvm:$stardustVersion")
    implementation("cc.persch:stardustx-text-jvm:$stardustVersion")
    implementation("cc.persch:stardustx-uuid-jvm:$stardustVersion")
    // Experimental module
    implementation("cc.persch:stardusty-jvm:$stardustVersion")
}