All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.robertboothby.djenni.lang.ByteSupplierBuilder Maven / Gradle / Ivy

Go to download

This module holds the core components of the Djenni data generator framework. By itself it provides most of the components to create an efficient end to end data generation framework for a specific domain. It contains the core SupplierBuilder interfaces, implementations for the core Java data types and useful test components. It is intended to be used in conjunction with the source-generator module that will speed up delivery of domain specific data generation and also with common domain modules (TBD) that deliver standard generators for common frameworks such as JAXB.

There is a newer version: 0.2.0
Show newest version
package com.robertboothby.djenni.lang;

import com.robertboothby.djenni.SupplierBuilder;
import com.robertboothby.djenni.core.StreamableSupplier;

import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Supplier;

/**
 * Trivial supplier builder that simply supplies a random byte. No fancy distributions or anything else.
 * TODO consider if this one could be grown into something more.
 */
public class ByteSupplierBuilder implements SupplierBuilder {

    @Override
    public StreamableSupplier build() {
        return () -> {
            byte[] single = new byte[1];
            ThreadLocalRandom.current().nextBytes(single);
            return single[0];
        };
    }

    public static ByteSupplierBuilder byteSupplier() {
        return new ByteSupplierBuilder();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy