dev.marksman.kraftwerk.Constant Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kraftwerk Show documentation
Show all versions of kraftwerk Show documentation
Purely functional random data generation
The newest version!
package dev.marksman.kraftwerk;
import com.jnape.palatable.lambda.adt.Maybe;
import static dev.marksman.kraftwerk.Result.result;
final class Constant implements Generator {
private static final Maybe LABEL = Maybe.just("constant");
private final A value;
private Constant(A value) {
this.value = value;
}
static Constant constant(A value) {
return new Constant<>(value);
}
@Override
public GenerateFn createGenerateFn(GeneratorParameters generatorParameters) {
return input -> result(input, value);
}
@Override
public Maybe getLabel() {
return LABEL;
}
}