Git Product home page Git Product logo

randomgenkt's Introduction

RandomGenKt

Initialize instances of any class with generated data.

Version - RandomGenKt Version - DataSource Build Status License

Example

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:

dependencies {
    implementation("com.mitteloupe.randomgenkt:randomgenkt:2.0.1")
}

To include the default data generators, also include

dependencies {
    implementation("com.mitteloupe.randomgenkt:randomgenkt.datasource:2.0.1")
}

Usage

Kotlin

val randomGen = RandomGen.Builder<ObjectClass>()
	.ofKotlinClass<ObjectClass>()
	.withField("id")
	.returningSequentialInteger()
	.withField("uuid")
	.returningUuid()
	.build()

Java

RandomGen<ObjectClass> randomGen = new RandomGen.Builder<ObjectClass>()
	.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

val instance = randomGen()

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<Type>() instead of ofClass(Type::class.java)

Created by

Eran Boudjnah

License

MIT © Eran Boudjnah

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.