Interface Generator<A>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default Generator<java.util.ArrayList<A>> arrayList()
      Creates a new Generator that yields ArrayLists of various sizes, with this Generator generating the elements.
      default Generator<java.util.ArrayList<A>> arrayListOfSize​(int size)
      Creates a new Generator that yields ArrayLists of a specific size, with this Generator generating the elements.
      default Generator<java.util.ArrayList<A>> arrayListOfSize​(IntRange sizeRange)
      Creates a new Generator that yields ArrayLists of various sizes within a specific range, with this Generator generating the elements.
      default Generator<A> attachApplicationData​(java.lang.Object applicationData)
      Creates a new Generator that is the same as this one, with the attached application changed to the object provided.
      GenerateFn<A> createGenerateFn​(GeneratorParameters generatorParameters)
      Creates a GenerateFn using the given GeneratorParameters.
      default <B> Generator<B> flatMap​(com.jnape.palatable.lambda.functions.Fn1<? super A,​? extends com.jnape.palatable.lambda.monad.Monad<B,​Generator<?>>> f)
      Creates a new Generator that, when invoked, feeds the output of this Generator to a function that returns another Generator, and invokes that.
      default <B> Generator<B> fmap​(com.jnape.palatable.lambda.functions.Fn1<? super A,​? extends B> fn)
      Creates a new Generator by mapping the output of this Generator.
      default com.jnape.palatable.lambda.adt.Maybe<java.lang.Object> getApplicationData()
      Returns the application-specific opaque object associated with this Generator, if any.
      default com.jnape.palatable.lambda.adt.Maybe<java.lang.String> getLabel()
      Returns an optional label used in diagnostics.
      default Generator<A> injectSpecialValue​(A specialValue)
      Creates a new Generator with a special value mixed into the output of this one.
      default Generator<A> injectSpecialValues​(software.kes.enhancediterables.NonEmptyFiniteIterable<A> values)
      Creates a new Generator with special values mixed into the output of this one.
      default Generator<com.jnape.palatable.lambda.adt.Maybe<A>> just()
      Converts this Generator<A> into a Generator<Maybe<A>> that always yields just.
      default Generator<A> labeled​(java.lang.String label)
      Creates a new Generator that is the same as this one, with the label changed to the one provided.
      default <R> Generator<com.jnape.palatable.lambda.adt.Either<A,​R>> left()
      Converts this Generator<A> into a Generator<Either<A, R>> that always yields left.
      default Generator<com.jnape.palatable.lambda.adt.Maybe<A>> maybe()
      Converts this Generator<A> into a Generator<Maybe<A>> that usually yields just, but occasionally yields nothing.
      default Generator<com.jnape.palatable.lambda.adt.Maybe<A>> maybe​(MaybeWeights weights)
      Converts this Generator<A> into a Generator<Maybe<A>> with custom probabilities for just vs.
      default Generator<java.util.ArrayList<A>> nonEmptyArrayList()
      Creates a new Generator that yields non-empty ArrayLists of various sizes, with this Generator generating the elements.
      default Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> nonEmptyVector()
      Creates a new Generator that yields NonEmptyVectors of various sizes, with this Generator generating the elements.
      default Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> nonEmptyVectorOfSize​(int size)
      Creates a new Generator that yields NonEmptyVectors of a specific size, with this Generator generating the elements.
      default Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> nonEmptyVectorOfSize​(IntRange sizeRange)
      Creates a new Generator that yields NonEmptyVectors of various sizes within a specific range, with this Generator generating the elements.
      default Generator<com.jnape.palatable.lambda.adt.hlist.Tuple2<A,​A>> pair()
      Creates a new Generator that yields pairs of values generated by this one.
      default <B> Generator<B> pure​(B b)
      The pure method to satisfy the Monad interface.
      default <L> Generator<com.jnape.palatable.lambda.adt.Either<L,​A>> right()
      Converts this Generator<A> into a Generator<Either<L, A>> that always yields right.
      default ValueSupply<A> run()
      Creates a ValueSupply from a random initial seed, using the built-in default GeneratorParameters.
      default ValueSupply<A> run​(GeneratorParameters generatorParameters)
      Creates a ValueSupply from custom GeneratorParameters, and a random initial seed.
      default ValueSupply<A> run​(GeneratorParameters generatorParameters, Seed initialSeed)
      Creates a ValueSupply from custom GeneratorParameters and a specific initial Seed.
      default ValueSupply<A> run​(Seed initialSeed)
      Creates a ValueSupply from a specific initial Seed, using the built-in default GeneratorParameters.
      default Generator<A> toGenerator()  
      default Generator<com.jnape.palatable.lambda.adt.hlist.Tuple3<A,​A,​A>> triple()
      Creates a new Generator that yields triples of values generated by this one.
      default Generator<software.kes.collectionviews.ImmutableVector<A>> vector()
      Creates a new Generator that yields Vectors of various sizes, with this Generator generating the elements.
      default Generator<software.kes.collectionviews.ImmutableVector<A>> vectorOfSize​(int size)
      Creates a new Generator that yields Vectors of a specific size, with this Generator generating the elements.
      default Generator<software.kes.collectionviews.ImmutableVector<A>> vectorOfSize​(IntRange sizeRange)
      Creates a new Generator that yields Vectors of various sizes within a specific range, with this Generator generating the elements.
      default Weighted<Generator<A>> weighted()
      Creates a Weighted instance of this Generator with a weight of 1.
      default Weighted<Generator<A>> weighted​(int weight)
      Creates a Weighted instance of this Generator with a custom weight.
      default Generator<A> withNulls()
      Creates a new Generator that is the same as this one, but occasionally yields null.
      default Generator<A> withNulls​(NullWeights weights)
      Creates a new Generator that is the same as this one, but occasionally yields null, with a custom probability.
      default <B,​C>
      Generator<C>
      zipWith​(com.jnape.palatable.lambda.functions.Fn2<A,​B,​C> fn, Generator<B> other)
      Creates a new Generator that combines the output of another Generator using a function to yield the final output.
      • Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

        coerce
      • Methods inherited from interface com.jnape.palatable.lambda.monad.Monad

        discardL, discardR, lazyZip, zip
    • Method Detail

      • createGenerateFn

        GenerateFn<A> createGenerateFn​(GeneratorParameters generatorParameters)
        Creates a GenerateFn using the given GeneratorParameters. This is the only method that a Generator needs to implement. Since this is a low level method, users may wish to call once of the higher level run methods instead.

        Implementers must follow these rules: - createGenerateFn must be referentially transparent; it must yield the equivalent GenerateFn for all calls for a given Seed - The GenerateFn must pure and referentially transparent - The GenerateFn must be guaranteed to yield a value - The GenerateFn must not mutate the input Seed; it must return a new Seed

        Parameters:
        generatorParameters - the GeneratorParameters
        Returns:
        a GenerateFn<A>
        See Also:
        run(), run(Seed), run(GeneratorParameters), run(GeneratorParameters, Seed)
      • fmap

        default <B> Generator<B> fmap​(com.jnape.palatable.lambda.functions.Fn1<? super A,​? extends B> fn)
        Creates a new Generator by mapping the output of this Generator.
        Specified by:
        fmap in interface com.jnape.palatable.lambda.functor.Applicative<A,​Generator<?>>
        Specified by:
        fmap in interface com.jnape.palatable.lambda.functor.Functor<A,​Generator<?>>
        Specified by:
        fmap in interface com.jnape.palatable.lambda.monad.Monad<A,​Generator<?>>
        Type Parameters:
        B - the new output type
        Parameters:
        fn - the mapping function
        Returns:
        a Generator<B>
      • flatMap

        default <B> Generator<B> flatMap​(com.jnape.palatable.lambda.functions.Fn1<? super A,​? extends com.jnape.palatable.lambda.monad.Monad<B,​Generator<?>>> f)
        Creates a new Generator that, when invoked, feeds the output of this Generator to a function that returns another Generator, and invokes that.
        Specified by:
        flatMap in interface com.jnape.palatable.lambda.monad.Monad<A,​Generator<?>>
        Type Parameters:
        B - the new output type
        Parameters:
        f - the mapping function
        Returns:
        a Generator<B>
      • pure

        default <B> Generator<B> pure​(B b)
        The pure method to satisfy the Monad interface.
        Specified by:
        pure in interface com.jnape.palatable.lambda.functor.Applicative<A,​Generator<?>>
        Specified by:
        pure in interface com.jnape.palatable.lambda.monad.Monad<A,​Generator<?>>
        See Also:
        Generators.constant(A)
      • getLabel

        default com.jnape.palatable.lambda.adt.Maybe<java.lang.String> getLabel()
        Returns an optional label used in diagnostics.
        Returns:
        a Maybe<String>
        See Also:
        labeled(String)
      • getApplicationData

        default com.jnape.palatable.lambda.adt.Maybe<java.lang.Object> getApplicationData()
        Returns the application-specific opaque object associated with this Generator, if any.
        Returns:
        a Maybe<Object>
        See Also:
        attachApplicationData(Object)
      • labeled

        default Generator<A> labeled​(java.lang.String label)
        Creates a new Generator that is the same as this one, with the label changed to the one provided.
        Parameters:
        label - the label
        Returns:
        a Generator<A>
        See Also:
        getLabel()
      • attachApplicationData

        default Generator<A> attachApplicationData​(java.lang.Object applicationData)
        Creates a new Generator that is the same as this one, with the attached application changed to the object provided.
        Parameters:
        applicationData - an opaque application-defined object of any type to be used as metadata
        Returns:
        a Generator<A>
        See Also:
        getApplicationData()
      • pair

        default Generator<com.jnape.palatable.lambda.adt.hlist.Tuple2<A,​A>> pair()
        Creates a new Generator that yields pairs of values generated by this one.
        Returns:
        a Generator<Tuple2<A, A>>
      • triple

        default Generator<com.jnape.palatable.lambda.adt.hlist.Tuple3<A,​A,​A>> triple()
        Creates a new Generator that yields triples of values generated by this one.
        Returns:
        a Generator<Tuple3<A, A, A>>
      • weighted

        default Weighted<Generator<A>> weighted()
        Creates a Weighted instance of this Generator with a weight of 1.
        Returns:
        a Weighted<Generator<A>>
      • weighted

        default Weighted<Generator<A>> weighted​(int weight)
        Creates a Weighted instance of this Generator with a custom weight.
        Parameters:
        weight - the weight value; must be >= 0
        Returns:
        a Weighted<Generator<A>>
      • just

        default Generator<com.jnape.palatable.lambda.adt.Maybe<A>> just()
        Converts this Generator<A> into a Generator<Maybe<A>> that always yields just.
        Returns:
        a Generator<Maybe<A>>
      • maybe

        default Generator<com.jnape.palatable.lambda.adt.Maybe<A>> maybe()
        Converts this Generator<A> into a Generator<Maybe<A>> that usually yields just, but occasionally yields nothing.
        Returns:
        a Generator<Maybe<A>>
      • maybe

        default Generator<com.jnape.palatable.lambda.adt.Maybe<A>> maybe​(MaybeWeights weights)
        Converts this Generator<A> into a Generator<Maybe<A>> with custom probabilities for just vs. nothing.
        Returns:
        a Generator<Maybe<A>>
      • left

        default <R> Generator<com.jnape.palatable.lambda.adt.Either<A,​R>> left()
        Converts this Generator<A> into a Generator<Either<A, R>> that always yields left.
        Returns:
        a Generator<Either<A, R>>
      • right

        default <L> Generator<com.jnape.palatable.lambda.adt.Either<L,​A>> right()
        Converts this Generator<A> into a Generator<Either<L, A>> that always yields right.
        Returns:
        a Generator<Either<L, A>>
      • withNulls

        default Generator<A> withNulls()
        Creates a new Generator that is the same as this one, but occasionally yields null.
        Returns:
        a Generator<Maybe<A>>
      • withNulls

        default Generator<A> withNulls​(NullWeights weights)
        Creates a new Generator that is the same as this one, but occasionally yields null, with a custom probability.
        Returns:
        a Generator<Maybe<A>>
      • arrayList

        default Generator<java.util.ArrayList<A>> arrayList()
        Creates a new Generator that yields ArrayLists of various sizes, with this Generator generating the elements.
        Returns:
        a Generator<ArrayList<A>>
      • nonEmptyArrayList

        default Generator<java.util.ArrayList<A>> nonEmptyArrayList()
        Creates a new Generator that yields non-empty ArrayLists of various sizes, with this Generator generating the elements.
        Returns:
        a Generator<ArrayList<A>>
      • arrayListOfSize

        default Generator<java.util.ArrayList<A>> arrayListOfSize​(int size)
        Creates a new Generator that yields ArrayLists of a specific size, with this Generator generating the elements.
        Parameters:
        size - the size of the ArrayLists generated; must be >=0
        Returns:
        a Generator<ArrayList<A>>
      • arrayListOfSize

        default Generator<java.util.ArrayList<A>> arrayListOfSize​(IntRange sizeRange)
        Creates a new Generator that yields ArrayLists of various sizes within a specific range, with this Generator generating the elements.
        Parameters:
        sizeRange - the IntRange of the sizes of ArrayLists generated
        Returns:
        a Generator<ArrayList<A>>
      • vector

        default Generator<software.kes.collectionviews.ImmutableVector<A>> vector()
        Creates a new Generator that yields Vectors of various sizes, with this Generator generating the elements.
        Returns:
        a Generator<ImmutableVector<A>>
      • vectorOfSize

        default Generator<software.kes.collectionviews.ImmutableVector<A>> vectorOfSize​(int size)
        Creates a new Generator that yields Vectors of a specific size, with this Generator generating the elements.
        Parameters:
        size - the size of the Vectors generated; must be >=0
        Returns:
        a Generator<ImmutableVector<A>>
      • vectorOfSize

        default Generator<software.kes.collectionviews.ImmutableVector<A>> vectorOfSize​(IntRange sizeRange)
        Creates a new Generator that yields Vectors of various sizes within a specific range, with this Generator generating the elements.
        Parameters:
        sizeRange - the IntRange of the sizes of Vectors generated
        Returns:
        a Generator<ImmutableVector<A>>
      • nonEmptyVector

        default Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> nonEmptyVector()
        Creates a new Generator that yields NonEmptyVectors of various sizes, with this Generator generating the elements.
        Returns:
        a Generator<ImmutableNonEmptyVector<A>>
      • nonEmptyVectorOfSize

        default Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> nonEmptyVectorOfSize​(int size)
        Creates a new Generator that yields NonEmptyVectors of a specific size, with this Generator generating the elements.
        Parameters:
        size - the size of the NonEmptyVectors generated; must be >=1
        Returns:
        a Generator<ImmutableNonEmptyVector<A>>
      • nonEmptyVectorOfSize

        default Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> nonEmptyVectorOfSize​(IntRange sizeRange)
        Creates a new Generator that yields NonEmptyVectors of various sizes within a specific range, with this Generator generating the elements.
        Parameters:
        sizeRange - the IntRange of the sizes of NonEmptyVectors generated
        Returns:
        a Generator<ImmutableNonEmptyVector<A>>
      • zipWith

        default <B,​C> Generator<C> zipWith​(com.jnape.palatable.lambda.functions.Fn2<A,​B,​C> fn,
                                                 Generator<B> other)
        Creates a new Generator that combines the output of another Generator using a function to yield the final output.
        Type Parameters:
        B - the output type of the other Generator
        C - the new output type
        Parameters:
        fn - a function that takes the output of this Generator and the output of other, and returns the final output
        other - the other Generator
        Returns:
        a Generator<C>
      • injectSpecialValues

        default Generator<A> injectSpecialValues​(software.kes.enhancediterables.NonEmptyFiniteIterable<A> values)
        Creates a new Generator with special values mixed into the output of this one. Special values will be represented more frequently than non-special values.
        Parameters:
        values - the special values to mix in
        Returns:
        a Generator<A>
      • injectSpecialValue

        default Generator<A> injectSpecialValue​(A specialValue)
        Creates a new Generator with a special value mixed into the output of this one. Special values will be represented more frequently than non-special values.
        Parameters:
        specialValue - the special value
        Returns:
        a Generator<A>