You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

au.com.anthonybruno:SdGen

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

au.com.anthonybruno:SdGen

A random data generator to produce realistic files for multiple file types (e.g. csv, log, json)


Version published
Maintainers
1

Readme

Source

SDgen Build Status

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) //Number of rows that will be generated
    .asCsv()
    .toFile("output.csv");

Where the Person class looks like this:

public class Person {

   @Generation(NameGenerator.class) //Generator is used to create values
   private final String name; 
   
   @Range(min=18, max=70) //Range is used to limit the range of values
   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) //number of rows to generate
    .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

FAQs

Package last updated on 31 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc