Module json_values

Class JsBinaryGen

java.lang.Object
jsonvalues.gen.JsBinaryGen
All Implemented Interfaces:
fun.gen.Gen<JsBinary>, Function<Random,Supplier<JsBinary>>

public final class JsBinaryGen extends Object implements fun.gen.Gen<JsBinary>
Represents a JsBinary generator. It can be created using the static factory methods biased and arbitrary or, if none of the previous suit your needs, from a bytes generator and the function map:

      import fun.gen.Gen;
      import jsonvalues.JsBinary;

      Gen<byte[]> byteGen = seed -> () -> {...};
      Gen<JsBinary> jsByteGen = gen.map(JsBinary::of)
      
  

Arbitrary generators produces uniformed distributions of values. Biased generators produces, with higher probability, potential problematic values that usually cause more bugs.

  • Method Summary

    Modifier and Type
    Method
    Description
    apply(Random seed)
    Returns a supplier from the specified seed that generates a new JsBinary each time it's called
    static fun.gen.Gen<JsBinary>
    arbitrary(int minLength, int maxLength)
    returns an arbitrary Json bytes generator
    static fun.gen.Gen<JsBinary>
    biased(int minLength, int maxLength)
    returns a biased Json bytes generator

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Function

    andThen, compose

    Methods inherited from interface fun.gen.Gen

    map, peek, sample, sample, sample, suchThat, suchThat, then
  • Method Details

    • arbitrary

      public static fun.gen.Gen<JsBinary> arbitrary(int minLength, int maxLength)
      returns an arbitrary Json bytes generator
      Parameters:
      minLength - minimum number of bytes (inclusive)
      maxLength - maximum number of bytes (inclusive)
      Returns:
      an arbitrary Json bytes generator
    • biased

      public static fun.gen.Gen<JsBinary> biased(int minLength, int maxLength)
      returns a biased Json bytes generator
      Parameters:
      minLength - minimum number of bytes (inclusive)
      maxLength - maximum number of bytes (inclusive)
      Returns:
      a biased Json bytes generator
    • apply

      public Supplier<JsBinary> apply(Random seed)
      Returns a supplier from the specified seed that generates a new JsBinary each time it's called
      Specified by:
      apply in interface Function<Random,Supplier<JsBinary>>
      Parameters:
      seed - the generator seed
      Returns:
      a JsBinary supplier