com.robertboothby.djenni.lang.ByteSupplierBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
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.
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();
}
}