Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atsushi130/builderkit
BuilderKit is test data builder auto generator.
https://github.com/atsushi130/builderkit
autogenerate kotlin kotlinpoet testdatabuilder
Last synced: about 2 months ago
JSON representation
BuilderKit is test data builder auto generator.
- Host: GitHub
- URL: https://github.com/atsushi130/builderkit
- Owner: atsushi130
- License: apache-2.0
- Created: 2017-10-18T22:32:20.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-31T07:32:49.000Z (almost 7 years ago)
- Last Synced: 2023-08-17T11:38:17.767Z (over 1 year ago)
- Topics: autogenerate, kotlin, kotlinpoet, testdatabuilder
- Language: Kotlin
- Homepage:
- Size: 55.7 KB
- Stars: 2
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license-apache.md
Awesome Lists containing this project
README
# BuilderKit
[![apache licensed](https://img.shields.io/badge/License-Apache_2.0-d94c32.svg)](./license-apache.md)
[![builderkit](https://img.shields.io/badge/Kotlin-BuilderKit-3B5998.svg)](https://github.com/atsushi130/BuilderKit.git)
![kotlin](https://img.shields.io/badge/Language-Kotlin-f88909.svg)
[![travis](https://travis-ci.org/atsushi130/BuilderKit.svg?branch=develop)](https://travis-ci.org/atsushi130/BuilderKit)
[![Issues](https://img.shields.io/github/issues-raw/atsushi130/BuilderKit.svg)](https://github.com/atsushi130/BuilderKit/issues)
[![Version](https://img.shields.io/maven-central/v/com.github.atsushi130/builderkit.svg)](https://search.maven.org/#search|gav|1|g%3A"com.github.atsushi130"%20AND%20a%3A"builderkit")## Usage
Implement Generator class to `/generate/src/`.
```kotlin
class Generator {
companion object {
@JvmStatic fun main(vararg args: String) {
BuilderGenerator.generates(ModelClass::class)
}
}
}
```
Builder class is automatically generated to `generate/src/` by default.## Output Builder class
**Sample model class**
```kotlin
data class ModelClass(val arg1: Int, val arg2: List, val arg3: MyClass)
```**Output builder class**
```kotlin
class ModelClassBuilder(
private var arg1: Int,
private var arg2: List,
private var arg3: MyClass
) {
fun build() = ModelClass(this.arg1, this.arg2, this.arg3)fun withArg1(arg1: Int): ModelClassBuilder {
this.arg1 = arg1
return this
}fun withArg2(arg2: List): ModelClassBuilder {
this.arg2 = arg2
return this
}fun withArg3(arg3: MyClass): ModelClassBuilder {
this.arg3 = arg3
return this
}
}
```## Other Usage
**Specify indent and output file path**
```kotlin
import java.io.Fileclass Generator {
companion object {
@JvmStatic fun main(vararg args: String) {
val builder = BuilderGenerator(indent = "\t", path = File("generate/src/"))
builder.generates(ModelClass::class)
}
}
}
```## Dependency
**Maven**
```xmlcom.github.atsushi130
builderkit
0.6.0```
**Gradle**
```gradle
compile 'com.github.atsushi130:builderkit:0.6.0'
```