SDgen
A random data generator to produce realistic data files for multiple file types (e.g. csv, log, json)
Installation
If you're using Maven, just add the following to your pom.xml
<dependency>
<groupId>au.com.anthonybruno</groupId>
<artifactId>SdGen</artifactId>
<version>0.2.0</version>
</dependency>
Alternatively, grab the latest jar and chuck it on your class path.
Usage
There are two main ways to use SDGen to generate random data. The first way is
to use an annotated plain old Java object like so:
Gen.create()
.use(Person.class)
.generate(2)
.asCsv()
.toFile("output.csv");
Where the Person class looks like this:
public class Person {
@Generation(NameGenerator.class)
private final String name;
@Range(min=18, max=70)
private final int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
}
Annotations allow us to control how random values are generated.
Omitting Annotations would produce Strings like: f9j)32
, and ints like: -34093
output.csv
would look something like this:
name, age
Bob, 40
Ashley, 22
Here is the same example using a fluent builder:
Gen.create()
.addField("Name", new NameGenerator())
.addField("Age", new IntGenerator(18, 70)
.generate(2)
.asCsv()
.toFile("output.csv");
Generator
Generators are simple classes that generate random data.
@FunctionalInterface
public interface Generator<T> {
T generate();
}
SDgen provides basic generators for all primitive data types.
Contributing
To contribute, please fork the project and submit a pull request.
The project is backed by maven
which handles dependency management and
the build process.
Any pull request needs all tests passing (can run tests via mvn test
),
as well as the addition of tests that cover any added code.
Contributors List
Acknowledgements