Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eranboudjnah/randomgenkt
Kotlin port of RandomGen
https://github.com/eranboudjnah/randomgenkt
demo generator kotlin random random-generation random-generator randomgenerator reflection
Last synced: 28 days ago
JSON representation
Kotlin port of RandomGen
- Host: GitHub
- URL: https://github.com/eranboudjnah/randomgenkt
- Owner: EranBoudjnah
- License: mit
- Created: 2018-10-21T14:10:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-22T11:19:40.000Z (7 months ago)
- Last Synced: 2024-05-23T05:48:36.298Z (7 months ago)
- Topics: demo, generator, kotlin, random, random-generation, random-generator, randomgenerator, reflection
- Language: Kotlin
- Homepage:
- Size: 5.72 MB
- Stars: 35
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# RandomGenKt
>
> Initialize instances of any class with generated data.
>[![Version - RandomGenKt](https://img.shields.io/maven-central/v/com.mitteloupe.randomgenkt/randomgenkt?label=RandomGenKt+|+MavenCentral)](https://mvnrepository.com/artifact/com.mitteloupe.randomgenkt/randomgenkt)
[![Version - DataSource](https://img.shields.io/maven-central/v/com.mitteloupe.randomgenkt/randomgenkt.datasource?label=datasource+|+MavenCentral)](https://mvnrepository.com/artifact/com.mitteloupe.randomgenkt/randomgenkt.datasource)
![Build Status](https://img.shields.io/github/actions/workflow/status/EranBoudjnah/RandomGenKt/gradle-checks.yml)
[![License](https://img.shields.io/github/license/EranBoudjnah/RandomGenKt)](https://github.com/EranBoudjnah/RandomGenKt/blob/master/LICENSE)![Example](https://github.com/EranBoudjnah/RandomGenKt/raw/master/example/videocap.gif)
This is a Kotlin port of the Java library designed to generate random instances of any class.
This is great for demoing your app with interesting content, manually testing it with varying data, and even populating it with smart, random generated data in production.
## Install
In your `build.gradle`, add the following:
```groovy
dependencies {
implementation("com.mitteloupe.randomgenkt:randomgenkt:2.0.1")
}
```To include the default data generators, also include
```groovy
dependencies {
implementation("com.mitteloupe.randomgenkt:randomgenkt.datasource:2.0.1")
}
```## Usage
### Kotlin
```kotlin
val randomGen = RandomGen.Builder()
.ofKotlinClass()
.withField("id")
.returningSequentialInteger()
.withField("uuid")
.returningUuid()
.build()
```### Java
```java
RandomGen randomGen = new RandomGen.Builder()
.ofJavaClass(ObjectClass.class)
.withField("id")
.returningSequentialInteger()
.withField("uuid")
.returningUuid()
.build();
```This will create a `RandomGen` instance producing `ObjectClass` instances with sequential IDs and random UUIDs.
To use the newly generated `RandomGen`, simply call:
### Kotlin
```kotlin
val instance = randomGen()
```### Java
```java
ObjectClass instance = randomGen.invoke();
```### What's New?
Version 2.0
This is an overhaul of RandomGenKt. It has been dusted, polished and refactored to align with modern conventions.
--
The Kotlin version adds the following:
* Support for fields with lazy init
* Lambdas
* `ofClass()` instead of `ofClass(Type::class.java)`## Created by
[Eran Boudjnah](https://www.linkedin.com/in/eranboudjnah)## License
[MIT](LICENSE) © [Eran Boudjnah](https://www.linkedin.com/in/eranboudjnah)