https://github.com/virelion/buildata
Kotlin multiplatform builder generator.
https://github.com/virelion/buildata
builder codegen kotlin kotlin-multiplatform
Last synced: 3 months ago
JSON representation
Kotlin multiplatform builder generator.
- Host: GitHub
- URL: https://github.com/virelion/buildata
- Owner: Virelion
- License: apache-2.0
- Created: 2021-01-16T20:03:50.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-01-24T17:59:01.000Z (3 months ago)
- Last Synced: 2025-01-24T18:34:16.477Z (3 months ago)
- Topics: builder, codegen, kotlin, kotlin-multiplatform
- Language: Kotlin
- Homepage:
- Size: 530 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README









Kotlin multiplatform code-generator for typed tree data class structures.
# [Builder generator](docs/data-tree-building.md)
Generate builders for your immutable data classes.
Annotate class:
```kotlin
@Buildable
data class Root(
//...
)
```and use builders:
```kotlin
Root::class.build {
branch {
leaf = "My value"
}
}
```See more in [data-tree-building.md](docs/data-tree-building.md)
# [Path reflection](docs/path-reflection.md)
Generate builders for your immutable data classes.Annotate class:
```kotlin
@PathReflection
data class Root(
//...
)
```and automatically gather information about the path to the value:
```kotlin
root.withPath().branch.leaf.path().jsonPath // will return "$.branch.leaf"
```See more in [path-reflection.md](docs/path-reflection.md)
# [Dynamic access](docs/dynamic-access.md)
All `@Buildable` classes can be dynamically accessed.
Annotate class:
```kotlin
@Buildable
data class Item(
val value: String,
val list: List>
// ...
)
```and access data dynamically with generated accessors:
```kotlin
item.dynamicAccessor["value"] // returns item.value
item.dynamicAccessor["$.list[2]['element']"] // returns item.list[2]["element"]
```See more in [dynamic-access.md](docs/dynamic-access.md)
# How to set up?
0. Have open source repositories connected to project:
```kotlin
buildscript {
repositories {
gradlePluginPortal()
// ...
}
}repositories {
mavenCentral()
// ...
}
```1. Add buildata plugin to your build
```kotlin
plugins {
kotlin("multiplatform") version "1.9.20"
kotlin("jvm") version "1.9.20" // alternatively
// ...
id("io.github.virelion.buildata") version
}
```2. Add buildata runtime to your dependencies
```kotlin
kotlin {
// ...
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.virelion.buildata:buildata-runtime:")
}
}// ...
}
}
```