Package software.kes.kraftwerk
Class Generators
- java.lang.Object
-
- software.kes.kraftwerk.Generators
-
public final class Generators extends java.lang.Object
A collection of built-in generators
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <A,Builder,Out>
Generator<Out>aggregate(Aggregator<A,Builder,Out> aggregator, int size, Generator<A> gen)
Creates aGenerator
that, on each invocation, yields a value that is derived by invoking an elementGenerator
a specific number of times, and feeding these elements to anAggregator
.static <A,Builder,Out>
Generator<Out>aggregate(Aggregator<A,Builder,Out> aggregator, java.lang.Iterable<Generator<A>> elements)
Creates aGenerator
that aggregates elements generated from a collection ofGenerators
.static <A,Builder,Out>
Generator<Out>aggregate(Aggregator<A,Builder,Out> aggregator, IntRange sizeRange, Generator<A> gen)
Creates aGenerator
that, on each invocation, yields a value that is derived by invoking an elementGenerator
a random number of times (within a specific range), and feeding these elements to anAggregator
.static <A> ChoiceBuilder1<A>
choiceBuilder(Generator<? extends A> firstChoice)
Creates aChoiceBuilder1
.static <A> ChoiceBuilder1<A>
choiceBuilder(Weighted<? extends Generator<? extends A>> firstChoice)
Creates aChoiceBuilder1
.static <A> ChoiceBuilder1<A>
choiceBuilderValue(A firstChoice)
Creates aChoiceBuilder1
.static <A> ChoiceBuilder1<A>
choiceBuilderValue(Weighted<? extends A> firstChoice)
Creates aChoiceBuilder1
.static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>>
chooseAtLeastOneOf(Generator<? extends A> first, Generator<? extends A>... more)
Creates aGenerator
that, when invoked, chooses one or more of the supplied candidateGenerator
s.static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>>
chooseAtLeastOneOfValues(A first, A... more)
Creates aGenerator
that, when invoked, chooses one or more of the supplied candidate values, and returns a collection of all those chosen.static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>>
chooseAtLeastOneValueFromCollection(java.util.Collection<A> candidates)
Creates aGenerator
that, when invoked, chooses one or more values from a collection and returns a collection of the values chosen.static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>>
chooseAtLeastOneValueFromDomain(software.kes.collectionviews.NonEmptyVector<A> domain)
Creates aGenerator
that, when invoked, chooses one or more values from a custom domain and returns a collection of the values chosen.static <K,V>
Generator<java.util.Map.Entry<K,V>>chooseEntryFromMap(java.util.Map<K,V> map)
static <K,V>
Generator<K>chooseKeyFromMap(java.util.Map<K,V> map)
Creates aGenerator
that, when invoked, chooses a key from aMap
.static <A> Generator<A>
chooseOneFromCollection(java.lang.Iterable<Generator<? extends A>> candidates)
Creates aGenerator
that, when invoked, chooses aGenerator
from a collection of candidateGenerator
s (with an equal probability for each).static <A> Generator<A>
chooseOneFromCollectionWeighted(java.lang.Iterable<Weighted<? extends Generator<? extends A>>> candidates)
Creates aGenerator
that, when invoked, chooses aGenerator
from a collection of candidateGenerator
s (with a custom probability for each).static <A> Generator<A>
chooseOneOf(Generator<? extends A> first, Generator<? extends A>... more)
Creates aGenerator
that, when invoked, randomly selects from a list of candidateGenerator
s, (with equal probabilities for each).static <A> Generator<A>
chooseOneOfValues(A first, A... more)
Creates aGenerator
that, when invoked, randomly chooses an item from one or more candidate values, with an equal probability for each.static <A> Generator<A>
chooseOneOfWeighted(Weighted<? extends Generator<? extends A>> first, Weighted<? extends Generator<? extends A>>... more)
Creates aGenerator
that, when invoked, randomly selects from a list of candidateGenerator
s, (with custom probabilities for each).static <A> Generator<A>
chooseOneOfWeightedValues(Weighted<? extends A> first, Weighted<? extends A>... more)
Creates aGenerator
that, when invoked, randomly chooses and item from one or more candidate values, with custom probabilities for each.static <A> Generator<A>
chooseOneValueFromCollection(java.lang.Iterable<A> candidates)
Creates aGenerator
that, when invoked, chooses a value from a collection, with an equal probability for each element.static <A> Generator<A>
chooseOneValueFromDomain(software.kes.collectionviews.NonEmptyVector<A> domain)
Creates aGenerator
that, when invoked, chooses a value from a custom domain.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
chooseSomeOf(Generator<? extends A> first, Generator<? extends A>... more)
Creates aGenerator
that, when invoked, chooses zero or more of the supplied candidateGenerator
s.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
chooseSomeOfValues(A first, A... more)
Creates aGenerator
that, when invoked, chooses zero or more of the supplied candidate values, and returns a collection of all those chosen.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
chooseSomeValuesFromCollection(java.util.Collection<A> candidates)
Creates aGenerator
that, when invoked, chooses zero or more values from a collection and returns a collection of the values chosen.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
chooseSomeValuesFromDomain(software.kes.collectionviews.NonEmptyVector<A> domain)
Creates aGenerator
that, when invoked, chooses zero or more values from a custom domain and returns a collection of the values chosen.static <K,V>
Generator<V>chooseValueFromMap(java.util.Map<K,V> map)
Creates aGenerator
that, when invoked, chooses a value from aMap
.static Generator<java.lang.String>
concatMaybeStrings(java.lang.Iterable<Generator<com.jnape.palatable.lambda.adt.Maybe<java.lang.String>>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<Maybe<String>>
s and concatenating the results.static Generator<java.lang.String>
concatMaybeStrings(java.lang.String separator, java.lang.Iterable<Generator<com.jnape.palatable.lambda.adt.Maybe<java.lang.String>>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<Maybe<String>>
s and concatenating the results, separating them with a specific separator.static Generator<java.lang.String>
concatMaybeStrings(Generator<java.lang.String> separator, java.lang.Iterable<Generator<com.jnape.palatable.lambda.adt.Maybe<java.lang.String>>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<Maybe<String>>
s and concatenating the results, separating them by a separator that is also generated.static Generator<java.lang.String>
concatStrings(java.lang.Iterable<Generator<java.lang.String>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<String>
s and concatenating the results.static Generator<java.lang.String>
concatStrings(java.lang.String separator, java.lang.Iterable<Generator<java.lang.String>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<String>
s and concatenating the results, separating them with a specific separator.static Generator<java.lang.String>
concatStrings(Generator<java.lang.String> separator, java.lang.Iterable<Generator<java.lang.String>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<String>
s and concatenating the results, separating them by a separator that is also generated.static <A> Generator<A>
constant(A a)
Creates aGenerator
that yields the same value whenever invoked.static <A> Generator<A>
frequency(FrequencyMap<A> frequencyMap)
Creates aGenerator
that chooses its values from aFrequencyMap
.static Generator<java.lang.Character>
generateAlphaChar()
Creates aGenerator
that yields ASCII alphabeticCharacter
s (A-Z, a-z).static Generator<java.lang.Character>
generateAlphaLowerChar()
Creates aGenerator
that yields ASCII lowercase alphabeticCharacter
s (a-z).static Generator<java.lang.String>
generateAlphaLowerString()
Creates aGenerator
that yieldsString
s consisting of ASCII lowercase alphabetic characters.static Generator<java.lang.String>
generateAlphaLowerString(int length)
Creates aGenerator
that yieldsString
s consisting of ASCII lowercase alphabetic characters, and with a specific length.static Generator<java.lang.String>
generateAlphaLowerString(IntRange lengthRange)
Creates aGenerator
that yieldsString
s consisting of ASCII lowercase alphabetic characters, and with a length within a specific range.static Generator<java.lang.Character>
generateAlphanumericChar()
Creates aGenerator
that yields ASCII alphanumericCharacter
s (A-Z, a-z, 0-9).static Generator<java.lang.String>
generateAlphanumericString()
Creates aGenerator
that yieldsString
s consisting of ASCII alphanumeric characters (A-Z, a-z, 0-9).static Generator<java.lang.String>
generateAlphanumericString(int length)
Creates aGenerator
that yieldsString
s consisting of ASCII alphanumeric characters (A-Z, a-z, 0-9), and with a specific length.static Generator<java.lang.String>
generateAlphanumericString(IntRange lengthRange)
Creates aGenerator
that yieldsString
s consisting of ASCII alphanumeric characters (A-Z, a-z, 0-9), and with a length within a specific range.static Generator<java.lang.String>
generateAlphaString()
Creates aGenerator
that yieldsString
s consisting of ASCII alphabetic characters, both lowercase and uppercase.static Generator<java.lang.String>
generateAlphaString(int length)
Creates aGenerator
that yieldsString
s consisting of ASCII alphabetic characters, both lowercase and uppercase, and with a specific length.static Generator<java.lang.String>
generateAlphaString(IntRange lengthRange)
Creates aGenerator
that yieldsString
s consisting of ASCII alphabetic characters, both lowercase and uppercase, and with a length within a specific range.static Generator<java.lang.Character>
generateAlphaUpperChar()
Creates aGenerator
that yields ASCII uppercase alphabeticCharacter
s (A-Z).static Generator<java.lang.String>
generateAlphaUpperString()
Creates aGenerator
that yieldsString
s consisting of ASCII uppercase alphabetic characters.static Generator<java.lang.String>
generateAlphaUpperString(int length)
Creates aGenerator
that yieldsString
s consisting of ASCII uppercase alphabetic characters, and with a specific length.static Generator<java.lang.String>
generateAlphaUpperString(IntRange lengthRange)
Creates aGenerator
that yieldsString
s consisting of ASCII uppercase alphabetic characters, and with a length within a specific range.static <A> Generator<java.util.ArrayList<A>>
generateArrayList(Generator<A> elements)
Creates aGenerator
that yieldsArrayList
s of various sizes.static <A> Generator<java.util.ArrayList<A>>
generateArrayListOfSize(int size, Generator<A> elements)
Creates aGenerator
that yieldsArrayList
s of a specific size.static <A> Generator<java.util.ArrayList<A>>
generateArrayListOfSize(IntRange sizeRange, Generator<A> elements)
Creates aGenerator
that yieldsArrayList
s of various sizes, within a specific range.static Generator<java.lang.Character>
generateAsciiPrintableChar()
Creates aGenerator
that yields ASCII printableCharacter
s.static Generator<java.math.BigDecimal>
generateBigDecimal()
Creates aGenerator
that yieldsBigDecimal
s.static Generator<java.math.BigDecimal>
generateBigDecimal(int decimalPlaces, BigDecimalRange range)
Creates aGenerator
that yieldsBigDecimal
s within a specific range, and with a specific number of decimal places.static Generator<java.math.BigDecimal>
generateBigDecimal(BigDecimalRange range)
Creates aGenerator
that yieldsBigDecimal
s within a specific range.static Generator<java.math.BigDecimal>
generateBigDecimal(Generator<java.lang.Integer> generateDecimalPlaces, BigDecimalRange range)
Creates aGenerator
that yieldsBigDecimal
s within a specific range, and with the number of decimal places determined by a specificGenerator
.static Generator<BigDecimalRange>
generateBigDecimalRange()
Creates aGenerator
that yieldsBigDecimalRange
s.static Generator<BigDecimalRange>
generateBigDecimalRange(BigDecimalRange parentRange)
Creates aGenerator
that yieldsBigDecimalRange
s, within a specific parent range.static Generator<java.math.BigInteger>
generateBigInteger()
Creates aGenerator
that yieldsBigInteger
s.static Generator<java.math.BigInteger>
generateBigInteger(BigIntegerRange range)
Creates aGenerator
that yieldsBigInteger
s within a specific range.static Generator<BigIntegerRange>
generateBigIntegerRange()
Creates aGenerator
that yieldsBigIntegerRange
s.static Generator<BigIntegerRange>
generateBigIntegerRange(BigIntegerRange parentRange)
Creates aGenerator
that yieldsBigIntegerRange
s, within a specific parent range.static Generator<java.lang.Boolean>
generateBoolean()
Creates aGenerator
that yieldsBoolean
values.static Generator<java.lang.Boolean>
generateBoolean(BooleanWeights weights)
Creates aGenerator
that yieldsBoolean
values, with custom probabilities fortrue
andfalse
values.static Generator<java.lang.Object>
generateBoxedPrimitive()
Creates aGenerator
that yields boxed primitives.static Generator<java.lang.Byte>
generateByte()
Creates aGenerator
that yieldsByte
s within the full range ofByte
s (between -128 and 127, inclusive).static Generator<java.lang.Byte>
generateByte(ByteRange range)
Creates aGenerator
that yieldsByte
s within a specific range.static Generator<java.lang.Byte[]>
generateByteArray()
Creates aGenerator
that yieldsByte
arrays of varying sizes.static Generator<java.lang.Byte[]>
generateByteArray(int size)
Creates aGenerator
that yieldsByte
arrays of varying sizes.static Generator<ByteRange>
generateByteRange()
static Generator<ByteRange>
generateByteRange(ByteRange parentRange)
static Generator<java.lang.Character>
generateChar()
Creates aGenerator
that yieldsCharacter
s within the full range ofCharacter
s (betweenCharacter.MIN_VALUE
andCharacter.MAX_VALUE
, inclusive).static Generator<java.lang.Character>
generateChar(CharRange range)
Creates aGenerator
that yieldsCharacter
s within a specific range.static <A,B>
Generator<com.jnape.palatable.lambda.adt.choice.Choice2<A,B>>generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b)
Creates aGenerator
that yieldsChoice2
s.static <A,B,C>
Generator<com.jnape.palatable.lambda.adt.choice.Choice3<A,B,C>>generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c)
Creates aGenerator
that yieldsChoice3
s.static <A,B,C,D>
Generator<com.jnape.palatable.lambda.adt.choice.Choice4<A,B,C,D>>generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d)
Creates aGenerator
that yieldsChoice4
s.static <A,B,C,D,E>
Generator<com.jnape.palatable.lambda.adt.choice.Choice5<A,B,C,D,E>>generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d, Weighted<? extends Generator<? extends E>> e)
Creates aGenerator
that yieldsChoice5
s.static <A,B,C,D,E,F>
Generator<com.jnape.palatable.lambda.adt.choice.Choice6<A,B,C,D,E,F>>generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d, Weighted<? extends Generator<? extends E>> e, Weighted<? extends Generator<? extends F>> f)
Creates aGenerator
that yieldsChoice6
s.static <A,B,C,D,E,F,G>
Generator<com.jnape.palatable.lambda.adt.choice.Choice7<A,B,C,D,E,F,G>>generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d, Weighted<? extends Generator<? extends E>> e, Weighted<? extends Generator<? extends F>> f, Weighted<? extends Generator<? extends G>> g)
Creates aGenerator
that yieldsChoice7
s.static <A,B,C,D,E,F,G,H>
Generator<com.jnape.palatable.lambda.adt.choice.Choice8<A,B,C,D,E,F,G,H>>generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d, Weighted<? extends Generator<? extends E>> e, Weighted<? extends Generator<? extends F>> f, Weighted<? extends Generator<? extends G>> g, Weighted<? extends Generator<? extends H>> h)
Creates aGenerator
that yieldsChoice8
s.static <A,C extends java.util.Collection<A>>
Generator<C>generateCollection(com.jnape.palatable.lambda.functions.Fn0<C> constructCollection, int size, Generator<A> elements)
Creates aGenerator
that yieldsCollection
s of typeC
by invoking an elementGenerator
s a specific number of times, and then aggregating the results.static <A,C extends java.util.Collection<A>>
Generator<C>generateCollection(com.jnape.palatable.lambda.functions.Fn0<C> constructCollection, java.lang.Iterable<Generator<A>> elements)
Creates aGenerator
that yieldsCollection
s of typeC
by invoking a collection of elementGenerator
s in sequence, and then aggregating the results.static <A,C extends java.util.Collection<A>>
Generator<C>generateCollection(com.jnape.palatable.lambda.functions.Fn0<C> constructCollection, IntRange sizeRange, Generator<A> elements)
Creates aGenerator
that yieldsCollection
s of typeC
by invoking an elementGenerator
s a random number of times (within a specific range), and then aggregating the results.static Generator<java.lang.Character>
generateControlChar()
Creates aGenerator
that yields ASCII controlCharacter
s.static Generator<java.time.DayOfWeek>
generateDayOfWeek()
Creates aGenerator
that yieldsDayOfWeek
s.static FloatingPointGenerator<java.lang.Double>
generateDouble()
Creates aGenerator
that yieldsDouble
s within the full range ofDouble
s (betweenDouble.MIN_VALUE
andDouble.MAX_VALUE
, inclusive).static FloatingPointGenerator<java.lang.Double>
generateDouble(DoubleRange range)
Creates aGenerator
that yieldsDouble
s within a specific range.static FloatingPointGenerator<java.lang.Double>
generateDoubleFractional()
Creates aGenerator
that yieldsDouble
s between between 0 (inclusive) and 1 (exclusive).static Generator<DoubleRange>
generateDoubleRange()
Creates aGenerator
that yieldsDoubleRange
s.static Generator<DoubleRange>
generateDoubleRange(DoubleRange parentRange)
Creates aGenerator
that yieldsDoubleRange
s, within a specific parent range.static Generator<java.time.Duration>
generateDuration()
Creates aGenerator
that yieldsDuration
s.static Generator<java.time.Duration>
generateDuration(DurationRange range)
Creates aGenerator
that yieldsDuration
s with a specific range.static Generator<DurationRange>
generateDurationRange()
Creates aGenerator
that yieldsDurationRange
s.static Generator<DurationRange>
generateDurationRange(DurationRange parentRange)
Creates aGenerator
that yieldsDurationRange
s, within a specific parent range.static <L,R>
Generator<com.jnape.palatable.lambda.adt.Either<L,R>>generateEither(Generator<L> leftGen, Generator<R> rightGen)
static <L,R>
Generator<com.jnape.palatable.lambda.adt.Either<L,R>>generateEither(EitherWeights weights, Generator<L> leftGen, Generator<R> rightGen)
static Generator<java.lang.Boolean>
generateFalse()
Creates aGenerator
that, when invoked, always yieldsfalse
.static FloatingPointGenerator<java.lang.Float>
generateFloat()
Creates aGenerator
that yieldsFloat
s within the full range ofFloat
s (betweenFloat.MIN_VALUE
andFloat.MAX_VALUE
, inclusive).static FloatingPointGenerator<java.lang.Float>
generateFloat(FloatRange range)
Creates aGenerator
that yieldsFloat
s within a specific range.static FloatingPointGenerator<java.lang.Float>
generateFloatFractional()
Creates aGenerator
that yieldsFloat
s between between 0 (inclusive) and 1 (exclusive).static Generator<FloatRange>
generateFloatRange()
Creates aGenerator
that yieldsFloatRange
s.static Generator<FloatRange>
generateFloatRange(FloatRange parentRange)
Creates aGenerator
that yieldsFloatRange
s, within a specific parent range.static <R> Generator<com.jnape.palatable.lambda.functions.Fn0<R>>
generateFn0(Generator<R> result)
Creates aGenerator
that yieldsFn0
s.static <A,R>
Generator<com.jnape.palatable.lambda.functions.Fn1<A,R>>generateFn1(Cogenerator<A> param1, Generator<R> result)
Creates aGenerator
that yieldsFn1
s.static <A,B,R>
Generator<com.jnape.palatable.lambda.functions.Fn2<A,B,R>>generateFn2(Cogenerator<A> param1, Cogenerator<B> param2, Generator<R> result)
Creates aGenerator
that yields pureFn2
s.static <A,B,C,R>
Generator<com.jnape.palatable.lambda.functions.Fn3<A,B,C,R>>generateFn3(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Generator<R> result)
Creates aGenerator
that yields pureFn3
s.static <A,B,C,D,R>
Generator<com.jnape.palatable.lambda.functions.Fn4<A,B,C,D,R>>generateFn4(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Generator<R> result)
Creates aGenerator
that yields pureFn4
s.static <A,B,C,D,E,R>
Generator<com.jnape.palatable.lambda.functions.Fn5<A,B,C,D,E,R>>generateFn5(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Cogenerator<E> param5, Generator<R> result)
Creates aGenerator
that yields pureFn5
s.static <A,B,C,D,E,F,R>
Generator<com.jnape.palatable.lambda.functions.Fn6<A,B,C,D,E,F,R>>generateFn6(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Cogenerator<E> param5, Cogenerator<F> param6, Generator<R> result)
Creates aGenerator
that yields pureFn6
s.static <A,B,C,D,E,F,G,R>
Generator<com.jnape.palatable.lambda.functions.Fn7<A,B,C,D,E,F,G,R>>generateFn7(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Cogenerator<E> param5, Cogenerator<F> param6, Cogenerator<G> param7, Generator<R> result)
Creates aGenerator
that yields pureFn7
s.static <A,B,C,D,E,F,G,H,R>
Generator<com.jnape.palatable.lambda.functions.Fn8<A,B,C,D,E,F,G,H,R>>generateFn8(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Cogenerator<E> param5, Cogenerator<F> param6, Cogenerator<G> param7, Cogenerator<H> param8, Generator<R> result)
Creates aGenerator
that yields pureFn8
s.static <A extends java.lang.Enum<A>>
Generator<A>generateFromEnum(java.lang.Class<A> enumType)
Creates aGenerator
that chooses values from an enum.static <A> Generator<A>
generateFromMonoid(com.jnape.palatable.lambda.monoid.Monoid<A> monoid, Generator<A> gen)
Creates aGenerator
that builds its results by generating a random number of values (zero or more) and combining them usingMonoid
.static <A> Generator<A>
generateFromSemigroup(com.jnape.palatable.lambda.semigroup.Semigroup<A> semigroup, Generator<A> gen)
Creates aGenerator
that builds its results by generating a random number of values (one or more) and combining them usingSemigroup
.static Generator<java.lang.Double>
generateGaussian()
Creates aGenerator
that yieldsDouble
s, which, when accumulated, will result in normal distribution.static <A> Generator<java.util.HashSet<A>>
generateHashSet(Generator<A> elements)
Creates aGenerator
that yieldsHashSet
s of various sizes.static Generator<java.lang.String>
generateIdentifier()
Creates aGenerator
that yieldsString
s that are legal Java identifiers.static Generator<java.lang.String>
generateIdentifier(int length)
Creates aGenerator
that yieldsString
s that are legal Java identifiers of a specific length.static Generator<java.lang.String>
generateIdentifier(IntRange lengthRange)
Creates aGenerator
that yieldsString
s that are legal Java identifiers with a length within a specific range.static <A> Generator<ValueSupply<A>>
generateInfiniteIterable(Generator<A> elements)
Creates aGenerator
that yields infiniteIterable
s.static Generator<java.lang.Integer>
generateInt()
Creates aGenerator
that yieldsInteger
s within the full range ofInteger
s (betweenInteger.MIN_VALUE
andInteger.MAX_VALUE
, inclusive).static Generator<java.lang.Integer>
generateInt(IntRange range)
Creates aGenerator
that yieldsInteger
s within a specific range.static Generator<java.lang.Integer>
generateIntIndex(int bound)
Creates aGenerator
that yieldsInteger
s that are intended to be used as indices (e.g.static Generator<IntRange>
generateIntRange()
static Generator<IntRange>
generateIntRange(IntRange parentRange)
static <A> Generator<com.jnape.palatable.lambda.adt.Maybe<A>>
generateJust(Generator<A> gen)
static <L,R>
Generator<com.jnape.palatable.lambda.adt.Either<L,R>>generateLeft(Generator<L> gen)
static Generator<java.time.LocalDate>
generateLocalDate()
Creates aGenerator
that yieldsLocalDate
s.static Generator<java.time.LocalDate>
generateLocalDate(LocalDateRange range)
Creates aGenerator
that yieldsLocalDate
s within a specific range.static Generator<java.time.LocalDate>
generateLocalDateForMonth(java.time.YearMonth yearMonth)
static Generator<java.time.LocalDate>
generateLocalDateForYear(java.time.Year year)
static Generator<LocalDateRange>
generateLocalDateRange()
Creates aGenerator
that yieldsLocalDateRange
s.static Generator<LocalDateRange>
generateLocalDateRange(LocalDateRange parentRange)
Creates aGenerator
that yieldsLocalDateRange
s, within a specific parent range.static Generator<java.time.LocalDateTime>
generateLocalDateTime()
Creates aGenerator
that yieldsLocalDateTime
s.static Generator<java.time.LocalDateTime>
generateLocalDateTime(LocalDateRange dateRange)
Creates aGenerator
that yieldsLocalDateTime
s within a specific date range.static Generator<java.time.LocalDateTime>
generateLocalDateTime(LocalDateTimeRange range)
Creates aGenerator
that yieldsLocalDateTime
s within a specific range.static Generator<LocalDateTimeRange>
generateLocalDateTimeRange()
Creates aGenerator
that yieldsLocalDateTimeRange
s.static Generator<LocalDateTimeRange>
generateLocalDateTimeRange(LocalDateRange parentRange)
Creates aGenerator
that yieldsLocalDateTimeRange
s, within a specific parent range.static Generator<LocalDateTimeRange>
generateLocalDateTimeRange(LocalDateTimeRange parentRange)
Creates aGenerator
that yieldsLocalDateTimeRange
s, within a specific parent range.static Generator<java.time.LocalTime>
generateLocalTime()
Creates aGenerator
that yieldsLocalTime
s.static Generator<java.time.LocalTime>
generateLocalTime(LocalTimeRange range)
Creates aGenerator
that yieldsLocalTime
s within a specific range.static Generator<LocalTimeRange>
generateLocalTimeRange()
Creates aGenerator
that yieldsLocalTimeRange
s.static Generator<LocalTimeRange>
generateLocalTimeRange(LocalTimeRange parentRange)
Creates aGenerator
that yieldsLocalTimeRange
s, within a specific parent range.static Generator<java.lang.Long>
generateLong()
Creates aGenerator
that yieldsLong
s within the full range ofLong
s (betweenLong.MIN_VALUE
andLong.MAX_VALUE
, inclusive).static Generator<java.lang.Long>
generateLong(LongRange range)
Creates aGenerator
that yieldsLong
s within a specific range.static Generator<java.lang.Long>
generateLongIndex(long bound)
Creates aGenerator
that yieldsLong
s that are intended to be used as indices (e.g.static Generator<LongRange>
generateLongRange()
static Generator<LongRange>
generateLongRange(LongRange parentRange)
static <K,V>
Generator<java.util.Map<K,V>>generateMap(java.util.Collection<K> keys, Generator<V> generateValue)
Creates aGenerator
that yieldsMap
s with a given set of keys.static <K,V>
Generator<java.util.Map<K,V>>generateMap(software.kes.collectionviews.Vector<K> keys, Generator<V> generateValue)
Creates aGenerator
that yieldsMap
s with a given set of keys.static <K,V>
Generator<java.util.Map<K,V>>generateMap(Generator<K> generateKey, Generator<V> generateValue)
Creates aGenerator
that yieldsMap
s of various sizes.static <A> Generator<com.jnape.palatable.lambda.adt.Maybe<A>>
generateMaybe(Generator<A> gen)
Converts aGenerator
<A>
into aGenerator<Maybe<A>>
that most of the time yields ajust
, but will occasionally yield anothing
.static <A> Generator<com.jnape.palatable.lambda.adt.Maybe<A>>
generateMaybe(MaybeWeights weights, Generator<A> gen)
static Generator<java.time.Month>
generateMonth()
Creates aGenerator
that yieldsMonth
s.static <A> Generator<A>
generateNFromMonoid(com.jnape.palatable.lambda.monoid.Monoid<A> monoid, Generator<A> gen, int count)
Creates aGenerator
that builds its results by generating a specific number of values and combining them usingMonoid
.static <A> Generator<A>
generateNFromSemigroup(com.jnape.palatable.lambda.semigroup.Semigroup<A> semigroup, Generator<A> gen, int count)
Creates aGenerator
that builds its results by generating a specific number of values and combining them usingSemigroup
.static <A> Generator<java.util.ArrayList<A>>
generateNonEmptyArrayList(Generator<A> elements)
Creates aGenerator
that yieldsArrayList
s of various sizes, with a minimum size of one.static <A> Generator<java.util.HashSet<A>>
generateNonEmptyHashSet(Generator<A> elements)
Creates aGenerator
that yieldsHashSet
s of various sizes, with a minimum size of one.static <K,V>
Generator<java.util.Map<K,V>>generateNonEmptyMap(Generator<K> generateKey, Generator<V> generateValue)
Creates aGenerator
that yieldsMap
s of various sizes, with a minimum size of one.static <A> Generator<software.kes.collectionviews.NonEmptyVector<A>>
generateNonEmptyShuffled(int count, com.jnape.palatable.lambda.functions.Fn1<java.lang.Integer,A> fn)
Creates aGenerator
that yieldsNonEmptyVector
s by shuffling the indices from0
..count-1
in random order, and mapping them to a given function.static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>>
generateNonEmptyVector(Generator<A> elements)
Creates aGenerator
that yieldsImmutableNonEmptyVector
s of various sizes.static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>>
generateNonEmptyVectorOfSize(int size, Generator<A> elements)
Creates aGenerator
that yieldsImmutableNonEmptyVector
s of a specific size.static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>>
generateNonEmptyVectorOfSize(IntRange sizeRange, Generator<A> elements)
Creates aGenerator
that yieldsImmutableNonEmptyVector
s of a various sizes, within a specific range.static <A> Generator<com.jnape.palatable.lambda.adt.Maybe<A>>
generateNothing()
Creates aGenerator
that, when invoked, always yieldsMaybe.nothing()
.static <A> Generator<A>
generateNull()
Creates aGenerator
that, when invoked, always yieldsnull
of a specific type.static Generator<java.lang.Character>
generateNumericChar()
Creates aGenerator
that yields ASCII numericCharacter
s (0-9).static <A extends java.lang.Comparable<A>>
Generator<com.jnape.palatable.lambda.adt.hlist.Tuple2<A,A>>generateOrderedPair(Generator<A> elements)
Creates aGenerator
that yields ordered pairs of someComparable
type.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
generateOrderedSequence(IntRange countForEachElementRange, software.kes.collectionviews.ImmutableVector<A> orderedElems)
Creates aGenerator
that yields ordered sequences.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
generateOrderedSequence(Generator<java.lang.Integer> countForEachElement, software.kes.collectionviews.ImmutableVector<A> orderedElems)
Creates aGenerator
that yields ordered sequences.static <A,B,Out>
Generator<Out>generateProduct(Generator<A> a, Generator<B> b, com.jnape.palatable.lambda.functions.Fn2<A,B,Out> combine)
Creates aGenerator
that is a product of two otherGenerators
.static <A,B,C,Out>
Generator<Out>generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, com.jnape.palatable.lambda.functions.Fn3<A,B,C,Out> combine)
Creates aGenerator
that is a product of three otherGenerators
.static <A,B,C,D,Out>
Generator<Out>generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, com.jnape.palatable.lambda.functions.Fn4<A,B,C,D,Out> combine)
Creates aGenerator
that is a product of four otherGenerators
.static <A,B,C,D,E,Out>
Generator<Out>generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, com.jnape.palatable.lambda.functions.Fn5<A,B,C,D,E,Out> combine)
Creates aGenerator
that is a product of five otherGenerators
.static <A,B,C,D,E,F,Out>
Generator<Out>generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, com.jnape.palatable.lambda.functions.Fn6<A,B,C,D,E,F,Out> combine)
Creates aGenerator
that is a product of six otherGenerators
.static <A,B,C,D,E,F,G,Out>
Generator<Out>generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, Generator<G> g, com.jnape.palatable.lambda.functions.Fn7<A,B,C,D,E,F,G,Out> combine)
Creates aGenerator
that is a product of seven otherGenerators
.static <A,B,C,D,E,F,G,H,Out>
Generator<Out>generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, Generator<G> g, Generator<H> h, com.jnape.palatable.lambda.functions.Fn8<A,B,C,D,E,F,G,H,Out> combine)
Creates aGenerator
that is a product of eight otherGenerators
.static Generator<java.lang.Character>
generatePunctuationChar()
Creates aGenerator
that yields ASCII punctuationCharacter
s.static <L,R>
Generator<com.jnape.palatable.lambda.adt.Either<L,R>>generateRight(Generator<R> gen)
static Generator<Seed>
generateSeed()
static Generator<java.lang.Short>
generateShort()
Creates aGenerator
that yieldsShort
s within the full range ofShort
s (between -32768 and 32767, inclusive).static Generator<java.lang.Short>
generateShort(ShortRange range)
Creates aGenerator
that yieldsShort
s within a specific range.static Generator<ShortRange>
generateShortRange()
Creates aGenerator
that yieldsShortRange
s.static Generator<ShortRange>
generateShortRange(ShortRange parentRange)
Creates aGenerator
that yieldsShortRange
s, within a specific parent range.static Generator<software.kes.collectionviews.Vector<java.lang.Integer>>
generateShuffled(int count)
static <A> Generator<software.kes.collectionviews.Vector<A>>
generateShuffled(int count, com.jnape.palatable.lambda.functions.Fn1<java.lang.Integer,A> fn)
Creates aGenerator
that yieldsVector
s by shuffling the indices from0
..count-1
in random order, and mapping them to a given function.static <A> Generator<software.kes.collectionviews.Vector<A>>
generateShuffled(A[] input)
Creates aGenerator
that yieldsVector
s by randomly shuffling the order of the elements in the input.static <A> Generator<software.kes.collectionviews.Vector<A>>
generateShuffled(java.util.Collection<A> input)
Creates aGenerator
that yieldsVector
s by randomly shuffling the order of the elements in the input.static <A> Generator<software.kes.collectionviews.NonEmptyVector<A>>
generateShuffled(software.kes.collectionviews.NonEmptyVector<A> input)
Creates aGenerator
that yieldsNonEmptyVector
s by randomly shuffling the order of the elements in the input.static <A> Generator<software.kes.collectionviews.Vector<A>>
generateShuffled(software.kes.collectionviews.Vector<A> input)
Creates aGenerator
that yieldsVector
s by randomly shuffling the order of the elements in the input.static <A> Generator<software.kes.collectionviews.Vector<A>>
generateShuffled(software.kes.enhancediterables.FiniteIterable<A> input)
Creates aGenerator
that yieldsVector
s by randomly shuffling the order of the elements in the input.static <A> Generator<software.kes.collectionviews.NonEmptyVector<A>>
generateShuffled(software.kes.enhancediterables.NonEmptyFiniteIterable<A> input)
Creates aGenerator
that yieldsNonEmptyVector
s by randomly shuffling the order of the elements in the input.static Generator<java.lang.Integer>
generateSize()
Creates aGenerator
that yields sizes, generally used to determine sizes of collections.static Generator<java.lang.Integer>
generateSize(IntRange sizeRange)
Creates aGenerator
that yields sizes within a specific range, generally used to determine sizes of collections.static Generator<java.lang.String>
generateString()
Creates aGenerator
that yieldsString
s of printable ASCII characters, with varying lengths.static Generator<java.lang.String>
generateString(int numberOfChunks, Generator<java.lang.String> chunkGenerator)
Creates aGenerator
that yieldsString
s by invoking anotherGenerator
a specific number of times, and concatenating the results.static Generator<java.lang.String>
generateString(IntRange numberOfChunksRange, Generator<java.lang.String> chunkGenerator)
Creates aGenerator
that yieldsString
s by invoking anotherGenerator
a random number of times within a specific range, and concatenating the results.static Generator<java.lang.String>
generateString(Generator<java.lang.String> first, Generator<java.lang.String>... more)
Creates aGenerator
that yieldsString
s by invoking one or moreGenerator<String>
s in order and concatenating the result.static Generator<java.lang.String>
generateStringFromCharacters(int length, software.kes.collectionviews.NonEmptyVector<java.lang.Character> characters)
Creates aGenerator
that yieldsString
s by choosing from a collection ofCharacter
s a specific number of times, and concatenating the results.static Generator<java.lang.String>
generateStringFromCharacters(int length, Generator<java.lang.Character> g)
Creates aGenerator
that yieldsString
s by invoking aGenerator<Character>
a specific number of times, and concatenating the results.static Generator<java.lang.String>
generateStringFromCharacters(software.kes.collectionviews.NonEmptyVector<java.lang.Character> characters)
Creates aGenerator
that yieldsString
s by choosing from a collection ofCharacter
s a varying number of times, and concatenating the results.static Generator<java.lang.String>
generateStringFromCharacters(IntRange lengthRange, software.kes.collectionviews.NonEmptyVector<java.lang.Character> characters)
Creates aGenerator
that yieldsString
s by choosing from a collection ofCharacter
s a varying number of times within a specific range, and concatenating the results.static Generator<java.lang.String>
generateStringFromCharacters(IntRange lengthRange, Generator<java.lang.Character> g)
Creates aGenerator
that yieldsString
s by invoking aGenerator<Character>
a varying number of times within a specific range, and concatenating the results.static Generator<java.lang.String>
generateStringFromCharacters(Generator<java.lang.Character> g)
Creates aGenerator
that yieldsString
s by invoking aGenerator<Character>
a varying number of times, and concatenating the results.static <A,B>
Generator<com.jnape.palatable.lambda.adt.These<A,B>>generateThese(Generator<A> generatorA, Generator<B> generatorB)
Creates aGenerator
that yieldsThese
s, with equal probabilities for returning a value fromgeneratorA
,generatorB
, or a combination of both.static <A,B>
Generator<com.jnape.palatable.lambda.adt.These<A,B>>generateThese(TernaryWeights weights, Generator<A> generatorA, Generator<B> generatorB)
Creates aGenerator
that yieldsThese
s, with custom probabilities for returning a value fromgeneratorA
,generatorB
, or a combination of both.static Generator<java.lang.Boolean>
generateTrue()
Creates aGenerator
that, when invoked, always yieldstrue
.static <A,B>
Generator<com.jnape.palatable.lambda.adt.hlist.Tuple2<A,B>>generateTuple(Generator<A> a, Generator<B> b)
static <A,B,C>
Generator<com.jnape.palatable.lambda.adt.hlist.Tuple3<A,B,C>>generateTuple(Generator<A> a, Generator<B> b, Generator<C> c)
static <A,B,C,D>
Generator<com.jnape.palatable.lambda.adt.hlist.Tuple4<A,B,C,D>>generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d)
static <A,B,C,D,E>
Generator<com.jnape.palatable.lambda.adt.hlist.Tuple5<A,B,C,D,E>>generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e)
static <A,B,C,D,E,F>
Generator<com.jnape.palatable.lambda.adt.hlist.Tuple6<A,B,C,D,E,F>>generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f)
static <A,B,C,D,E,F,G>
Generator<com.jnape.palatable.lambda.adt.hlist.Tuple7<A,B,C,D,E,F,G>>generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, Generator<G> g)
static <A,B,C,D,E,F,G,H>
Generator<com.jnape.palatable.lambda.adt.hlist.Tuple8<A,B,C,D,E,F,G,H>>generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, Generator<G> g, Generator<H> h)
static Generator<com.jnape.palatable.lambda.adt.Unit>
generateUnit()
Creates aGenerator
that, when invoked, always yieldsUnit.UNIT
.static Generator<java.util.UUID>
generateUUID()
Creates aGenerator
that yields version 4UUID
s.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
generateVector(Generator<A> elements)
Creates aGenerator
that yieldsImmutableVector
s of various sizes.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
generateVectorOfSize(int size, Generator<A> elements)
Creates aGenerator
that yieldsImmutableVector
s of a specific size.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
generateVectorOfSize(IntRange sizeRange, Generator<A> elements)
Creates aGenerator
that yieldsImmutableVector
s of a various sizes, within a specific range.static <A> Generator<A>
generateWithNulls(Generator<A> gen)
static <A> Generator<A>
generateWithNulls(NullWeights weights, Generator<A> gen)
Creates aGenerator
that mixes occasionalnull
values into the output of an existingGenerator
, with a specific probability for null.static <A> Generator<software.kes.collectionviews.ImmutableVector<A>>
sequence(java.lang.Iterable<Generator<A>> gs)
Converts a sequence ofGenerator
s to aGenerator
of sequences.static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>>
sequenceNonEmpty(software.kes.enhancediterables.NonEmptyIterable<Generator<A>> gs)
Converts a non-empty sequence ofGenerator
s to aGenerator
of non-empty sequences.static <A> Generator<A>
sized(com.jnape.palatable.lambda.functions.Fn1<java.lang.Integer,Generator<A>> fn)
Creates aGenerator
that dynamically creates anotherGenerator
depending on a randomly generated size value.static <A> Generator<A>
sizedMinimum(int minimum, com.jnape.palatable.lambda.functions.Fn1<java.lang.Integer,Generator<A>> fn)
Creates aGenerator
that dynamically creates anotherGenerator
depending on a randomly generated size value.static StringGeneratorBuilder
stringGeneratorBuilder()
Instantiates aStringGeneratorBuilder
.
-
-
-
Method Detail
-
constant
public static <A> Generator<A> constant(A a)
Creates aGenerator
that yields the same value whenever invoked.- Type Parameters:
A
- the type of the value- Parameters:
a
- the value to return when theGenerator
is invoked- Returns:
- a
Generator<A>
-
generateBoolean
public static Generator<java.lang.Boolean> generateBoolean()
Creates aGenerator
that yieldsBoolean
values.- Returns:
- a
Generator<Boolean>
-
generateBoolean
public static Generator<java.lang.Boolean> generateBoolean(BooleanWeights weights)
Creates aGenerator
that yieldsBoolean
values, with custom probabilities fortrue
andfalse
values.- Parameters:
weights
- the probabilities for returningtrue
vs.false
values- Returns:
- a
Generator<Boolean>
-
generateDouble
public static FloatingPointGenerator<java.lang.Double> generateDouble()
Creates aGenerator
that yieldsDouble
s within the full range ofDouble
s (betweenDouble.MIN_VALUE
andDouble.MAX_VALUE
, inclusive).- Returns:
- a
FloatingPointGenerator
-
generateDoubleFractional
public static FloatingPointGenerator<java.lang.Double> generateDoubleFractional()
Creates aGenerator
that yieldsDouble
s between between 0 (inclusive) and 1 (exclusive).- Returns:
- a
FloatingPointGenerator
-
generateDouble
public static FloatingPointGenerator<java.lang.Double> generateDouble(DoubleRange range)
Creates aGenerator
that yieldsDouble
s within a specific range.- Parameters:
range
- theDoubleRange
of values to generate- Returns:
- a
FloatingPointGenerator
-
generateFloat
public static FloatingPointGenerator<java.lang.Float> generateFloat()
Creates aGenerator
that yieldsFloat
s within the full range ofFloat
s (betweenFloat.MIN_VALUE
andFloat.MAX_VALUE
, inclusive).- Returns:
- a
FloatingPointGenerator
-
generateFloatFractional
public static FloatingPointGenerator<java.lang.Float> generateFloatFractional()
Creates aGenerator
that yieldsFloat
s between between 0 (inclusive) and 1 (exclusive).- Returns:
- a
FloatingPointGenerator
-
generateFloat
public static FloatingPointGenerator<java.lang.Float> generateFloat(FloatRange range)
Creates aGenerator
that yieldsFloat
s within a specific range.- Parameters:
range
- theFloatRange
of values to generate- Returns:
- a
FloatingPointGenerator
-
generateInt
public static Generator<java.lang.Integer> generateInt()
Creates aGenerator
that yieldsInteger
s within the full range ofInteger
s (betweenInteger.MIN_VALUE
andInteger.MAX_VALUE
, inclusive).- Returns:
- a
Generator<Integer>
-
generateInt
public static Generator<java.lang.Integer> generateInt(IntRange range)
Creates aGenerator
that yieldsInteger
s within a specific range.- Parameters:
range
- theIntRange
of values to generate- Returns:
- a
Generator<Integer>
-
generateIntIndex
public static Generator<java.lang.Integer> generateIntIndex(int bound)
Creates aGenerator
that yieldsInteger
s that are intended to be used as indices (e.g. into arrays or collections). Values returned range from 0..bound
(exclusive). Ignores any bias settings.- Parameters:
bound
- the maximum value (exclusive)- Returns:
- a
Generator<Integer>
-
generateLong
public static Generator<java.lang.Long> generateLong()
Creates aGenerator
that yieldsLong
s within the full range ofLong
s (betweenLong.MIN_VALUE
andLong.MAX_VALUE
, inclusive).- Returns:
- a
Generator<Long>
-
generateLong
public static Generator<java.lang.Long> generateLong(LongRange range)
Creates aGenerator
that yieldsLong
s within a specific range.- Parameters:
range
- theLongRange
of values to generate- Returns:
- a
Generator<Long>
-
generateLongIndex
public static Generator<java.lang.Long> generateLongIndex(long bound)
Creates aGenerator
that yieldsLong
s that are intended to be used as indices (e.g. into arrays or collections). Values returned range from 0..bound
(exclusive). Ignores any bias settings.- Parameters:
bound
- the maximum value (exclusive)- Returns:
- a
Generator<Long>
-
generateByte
public static Generator<java.lang.Byte> generateByte()
Creates aGenerator
that yieldsByte
s within the full range ofByte
s (between -128 and 127, inclusive).- Returns:
- a
Generator<Byte>
-
generateByte
public static Generator<java.lang.Byte> generateByte(ByteRange range)
Creates aGenerator
that yieldsByte
s within a specific range.- Parameters:
range
- theByteRange
of values to generate- Returns:
- a
Generator<Byte>
-
generateShort
public static Generator<java.lang.Short> generateShort()
Creates aGenerator
that yieldsShort
s within the full range ofShort
s (between -32768 and 32767, inclusive).- Returns:
- a
Generator<Short>
-
generateShort
public static Generator<java.lang.Short> generateShort(ShortRange range)
Creates aGenerator
that yieldsShort
s within a specific range.- Parameters:
range
- theShortRange
of values to generate- Returns:
- a
Generator<Short>
-
generateChar
public static Generator<java.lang.Character> generateChar()
Creates aGenerator
that yieldsCharacter
s within the full range ofCharacter
s (betweenCharacter.MIN_VALUE
andCharacter.MAX_VALUE
, inclusive).- Returns:
- a
Generator<Character>
-
generateChar
public static Generator<java.lang.Character> generateChar(CharRange range)
Creates aGenerator
that yieldsCharacter
s within a specific range.- Parameters:
range
- theCharRange
of values to generate- Returns:
- a
Generator<Character>
-
generateAlphaChar
public static Generator<java.lang.Character> generateAlphaChar()
Creates aGenerator
that yields ASCII alphabeticCharacter
s (A-Z, a-z).- Returns:
- a
Generator<Character>
-
generateAlphaUpperChar
public static Generator<java.lang.Character> generateAlphaUpperChar()
Creates aGenerator
that yields ASCII uppercase alphabeticCharacter
s (A-Z).- Returns:
- a
Generator<Character>
-
generateAlphaLowerChar
public static Generator<java.lang.Character> generateAlphaLowerChar()
Creates aGenerator
that yields ASCII lowercase alphabeticCharacter
s (a-z).- Returns:
- a
Generator<Character>
-
generateAlphanumericChar
public static Generator<java.lang.Character> generateAlphanumericChar()
Creates aGenerator
that yields ASCII alphanumericCharacter
s (A-Z, a-z, 0-9).- Returns:
- a
Generator<Character>
-
generateNumericChar
public static Generator<java.lang.Character> generateNumericChar()
Creates aGenerator
that yields ASCII numericCharacter
s (0-9).- Returns:
- a
Generator<Character>
-
generatePunctuationChar
public static Generator<java.lang.Character> generatePunctuationChar()
Creates aGenerator
that yields ASCII punctuationCharacter
s. This include any ASCII character that is not a letter, digit, space, or control character.- Returns:
- a
Generator<Character>
-
generateAsciiPrintableChar
public static Generator<java.lang.Character> generateAsciiPrintableChar()
Creates aGenerator
that yields ASCII printableCharacter
s. This include any ASCII character that is not a control character.- Returns:
- a
Generator<Character>
-
generateControlChar
public static Generator<java.lang.Character> generateControlChar()
Creates aGenerator
that yields ASCII controlCharacter
s. A control character is any character from ASCII code 0-31.- Returns:
- a
Generator<Character>
-
generateGaussian
public static Generator<java.lang.Double> generateGaussian()
Creates aGenerator
that yieldsDouble
s, which, when accumulated, will result in normal distribution.- Returns:
- a
Generator<Double>
-
generateByteArray
public static Generator<java.lang.Byte[]> generateByteArray()
Creates aGenerator
that yieldsByte
arrays of varying sizes.- Returns:
- a
Generator<Byte[]>
-
generateByteArray
public static Generator<java.lang.Byte[]> generateByteArray(int size)
Creates aGenerator
that yieldsByte
arrays of varying sizes.- Parameters:
size
- the size of the arrays returned; must be >= 0- Returns:
- a
Generator<Byte[]>
-
generateBoxedPrimitive
public static Generator<java.lang.Object> generateBoxedPrimitive()
Creates aGenerator
that yields boxed primitives. When invoked, will return one of the following types:Integer
,Long
,Short
,Byte
,Double
,Float
,Boolean
, orCharacter
.- Returns:
- a
Generator<Object>
-
generateSize
public static Generator<java.lang.Integer> generateSize()
Creates aGenerator
that yields sizes, generally used to determine sizes of collections. Respects the size settings in theGeneratorParameters
used to configure the generator.- Returns:
- a
Generator<Integer>
-
generateSize
public static Generator<java.lang.Integer> generateSize(IntRange sizeRange)
Creates aGenerator
that yields sizes within a specific range, generally used to determine sizes of collections. Overrides theGeneratorParameters
's size parameters used to configure the generator, but will respect a preferred size if it can.- Returns:
- a
Generator<Integer>
-
sized
public static <A> Generator<A> sized(com.jnape.palatable.lambda.functions.Fn1<java.lang.Integer,Generator<A>> fn)
Creates aGenerator
that dynamically creates anotherGenerator
depending on a randomly generated size value. Respects the size settings in theGeneratorParameters
used to configure the generator.- Type Parameters:
A
- the type of value to generate- Parameters:
fn
- a function that takes a size (anInteger
>= 0) and returns aGenerator
- Returns:
- a
Generator<A>
-
sizedMinimum
public static <A> Generator<A> sizedMinimum(int minimum, com.jnape.palatable.lambda.functions.Fn1<java.lang.Integer,Generator<A>> fn)
Creates aGenerator
that dynamically creates anotherGenerator
depending on a randomly generated size value. Respects the size settings in theGeneratorParameters
used to configure the generator, but the size will always beminimum
or greater.- Type Parameters:
A
- the type of value to generate- Parameters:
minimum
- the minimum size to generatefn
- a function that takes a size (anInteger
>=minimum
) and returns aGenerator
- Returns:
- a
Generator<A>
-
aggregate
public static <A,Builder,Out> Generator<Out> aggregate(Aggregator<A,Builder,Out> aggregator, java.lang.Iterable<Generator<A>> elements)
Creates aGenerator
that aggregates elements generated from a collection ofGenerators
.- Type Parameters:
A
- the input type ofaggregator
Builder
- the builder type ofaggregator
Out
- the output type ofaggregator
- Parameters:
aggregator
- anAggregator
used to aggregate a group of generated elementselements
- anIterable
contain zero of moreGenerator<A>
s- Returns:
- a
Generator<Out>
-
aggregate
public static <A,Builder,Out> Generator<Out> aggregate(Aggregator<A,Builder,Out> aggregator, int size, Generator<A> gen)
Creates aGenerator
that, on each invocation, yields a value that is derived by invoking an elementGenerator
a specific number of times, and feeding these elements to anAggregator
.- Type Parameters:
A
- the input type ofaggregator
Builder
- the builder type ofaggregator
Out
- the output type ofaggregator
- Parameters:
aggregator
- anAggregator
used to aggregate a group of generated elementssize
- the number of input elements thataggregator
will be supplied to create one output. Must be >= 0.gen
- theGenerator
that generates elements- Returns:
- a
Generator<Out>
-
aggregate
public static <A,Builder,Out> Generator<Out> aggregate(Aggregator<A,Builder,Out> aggregator, IntRange sizeRange, Generator<A> gen)
Creates aGenerator
that, on each invocation, yields a value that is derived by invoking an elementGenerator
a random number of times (within a specific range), and feeding these elements to anAggregator
.- Type Parameters:
A
- the input type ofaggregator
Builder
- the builder type ofaggregator
Out
- the output type ofaggregator
- Parameters:
aggregator
- anAggregator
used to aggregate a group of generated elementssizeRange
- a range of the number of input elements thataggregator
will be supplied to create one output. Lower end of range must be >= 0.gen
- theGenerator
that yields elements- Returns:
- a
Generator<Out>
-
generateCollection
public static <A,C extends java.util.Collection<A>> Generator<C> generateCollection(com.jnape.palatable.lambda.functions.Fn0<C> constructCollection, java.lang.Iterable<Generator<A>> elements)
Creates aGenerator
that yieldsCollection
s of typeC
by invoking a collection of elementGenerator
s in sequence, and then aggregating the results.The size of the generated
Collection
s will always equal the size ofelements
.- Type Parameters:
A
- the element type of the desired collectionC
- the collection type. Instances ofC
must supportCollection.add(E)
(which is to say, must not throw on invocation).- Parameters:
constructCollection
- the constructor for the desired type of collection (e.g.ArrayList::new
)elements
- anIterable
containingGenerator<A>
s. EachGenerator
will correspond with a single output in the final result.- Returns:
- a
Generator<C>
-
generateCollection
public static <A,C extends java.util.Collection<A>> Generator<C> generateCollection(com.jnape.palatable.lambda.functions.Fn0<C> constructCollection, int size, Generator<A> elements)
Creates aGenerator
that yieldsCollection
s of typeC
by invoking an elementGenerator
s a specific number of times, and then aggregating the results.The size of the generated
Collection
s will always equalsize
.- Type Parameters:
A
- the element type of the desired collectionC
- the collection type. Instances ofC
must supportCollection.add(E)
(which is to say, must not throw on invocation).- Parameters:
constructCollection
- the constructor for the desired type of collection (e.g.ArrayList::new
)size
- the size of the output collection. Must be >= 0.elements
- the elementGenerator
- Returns:
- a
Generator<C>
-
generateCollection
public static <A,C extends java.util.Collection<A>> Generator<C> generateCollection(com.jnape.palatable.lambda.functions.Fn0<C> constructCollection, IntRange sizeRange, Generator<A> elements)
Creates aGenerator
that yieldsCollection
s of typeC
by invoking an elementGenerator
s a random number of times (within a specific range), and then aggregating the results.The size of the generated
Collection
s will always fall withinsizeRange
.- Type Parameters:
A
- the element type of the desired collectionC
- the collection type. Instances ofC
must supportCollection.add(E)
(which is to say, must not throw on invocation).- Parameters:
constructCollection
- the constructor for the desired type of collection (e.g.ArrayList::new
)sizeRange
- theIntRange
of sizes for the generated collections. Lower end of range must be >= 0.elements
- the elementGenerator
- Returns:
- a
Generator<C>
-
generateProduct
public static <A,B,Out> Generator<Out> generateProduct(Generator<A> a, Generator<B> b, com.jnape.palatable.lambda.functions.Fn2<A,B,Out> combine)
Creates aGenerator
that is a product of two otherGenerators
.- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorOut
- the type of the values to be ultimately yielded by the resultGenerator
(i.e, the return type of thecombine
function)- Parameters:
a
- the first component generatorb
- the second component generatorcombine
- a function to combine the results from the component generators- Returns:
- a
Generator<Out>
- See Also:
generateTuple(Generator, Generator)
-
generateProduct
public static <A,B,C,Out> Generator<Out> generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, com.jnape.palatable.lambda.functions.Fn3<A,B,C,Out> combine)
Creates aGenerator
that is a product of three otherGenerators
.- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorOut
- the type of the values to be ultimately yielded by the resultGenerator
(i.e, the return type of thecombine
function)- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatorcombine
- a function to combine the results from the component generators- Returns:
- a
Generator<Out>
- See Also:
generateTuple(Generator, Generator, Generator)
-
generateProduct
public static <A,B,C,D,Out> Generator<Out> generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, com.jnape.palatable.lambda.functions.Fn4<A,B,C,D,Out> combine)
Creates aGenerator
that is a product of four otherGenerators
.- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generatorOut
- the type of the values to be ultimately yielded by the resultGenerator
(i.e, the return type of thecombine
function)- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generatorcombine
- a function to combine the results from the component generators- Returns:
- a
Generator<Out>
- See Also:
generateTuple(Generator, Generator, Generator, Generator)
-
generateProduct
public static <A,B,C,D,E,Out> Generator<Out> generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, com.jnape.palatable.lambda.functions.Fn5<A,B,C,D,E,Out> combine)
Creates aGenerator
that is a product of five otherGenerators
.- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generatorE
- the type of the values generated by the fifth component generatorOut
- the type of the values to be ultimately yielded by the resultGenerator
(i.e, the return type of thecombine
function)- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generatore
- the fifth component generatorcombine
- a function to combine the results from the component generators- Returns:
- a
Generator<Out>
- See Also:
generateTuple(Generator, Generator, Generator, Generator, Generator)
-
generateProduct
public static <A,B,C,D,E,F,Out> Generator<Out> generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, com.jnape.palatable.lambda.functions.Fn6<A,B,C,D,E,F,Out> combine)
Creates aGenerator
that is a product of six otherGenerators
.- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generatorE
- the type of the values generated by the fifth component generatorF
- the type of the values generated by the sixth component generatorOut
- the type of the values to be ultimately yielded by the resultGenerator
(i.e, the return type of thecombine
function)- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generatore
- the fifth component generatorf
- the sixth component generatorcombine
- a function to combine the results from the component generators- Returns:
- a
Generator<Out>
- See Also:
generateTuple(Generator, Generator, Generator, Generator, Generator, Generator)
-
generateProduct
public static <A,B,C,D,E,F,G,Out> Generator<Out> generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, Generator<G> g, com.jnape.palatable.lambda.functions.Fn7<A,B,C,D,E,F,G,Out> combine)
Creates aGenerator
that is a product of seven otherGenerators
.- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generatorE
- the type of the values generated by the fifth component generatorF
- the type of the values generated by the sixth component generatorG
- the type of the values generated by the seventh component generatorOut
- the type of the values to be ultimately yielded by the resultGenerator
(i.e, the return type of thecombine
function)- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generatore
- the fifth component generatorf
- the sixth component generatorg
- the seventh component generatorcombine
- a function to combine the results from the component generators- Returns:
- a
Generator<Out>
- See Also:
generateTuple(Generator, Generator, Generator, Generator, Generator, Generator, Generator)
-
generateProduct
public static <A,B,C,D,E,F,G,H,Out> Generator<Out> generateProduct(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, Generator<G> g, Generator<H> h, com.jnape.palatable.lambda.functions.Fn8<A,B,C,D,E,F,G,H,Out> combine)
Creates aGenerator
that is a product of eight otherGenerators
.- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generatorE
- the type of the values generated by the fifth component generatorF
- the type of the values generated by the sixth component generatorG
- the type of the values generated by the seventh component generatorH
- the type of the values generated by the eighth component generatorOut
- the type of the values to be ultimately yielded by the resultGenerator
(i.e, the return type of thecombine
function)- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generatore
- the fifth component generatorf
- the sixth component generatorg
- the seventh component generatorh
- the eighth component generatorcombine
- a function to combine the results from the component generators- Returns:
- a
Generator<Out>
- See Also:
generateTuple(Generator, Generator, Generator, Generator, Generator, Generator, Generator, Generator)
-
generateTuple
public static <A,B> Generator<com.jnape.palatable.lambda.adt.hlist.Tuple2<A,B>> generateTuple(Generator<A> a, Generator<B> b)
- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generator- Parameters:
a
- the first component generatorb
- the second component generator- Returns:
- a
Generator<Tuple2<A, B>
- See Also:
generateProduct(Generator, Generator, Fn2)
-
generateTuple
public static <A,B,C> Generator<com.jnape.palatable.lambda.adt.hlist.Tuple3<A,B,C>> generateTuple(Generator<A> a, Generator<B> b, Generator<C> c)
- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generator- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generator- Returns:
- a
Generator<Tuple3<A, B, C>
- See Also:
generateProduct(Generator, Generator, Generator, Fn3)
-
generateTuple
public static <A,B,C,D> Generator<com.jnape.palatable.lambda.adt.hlist.Tuple4<A,B,C,D>> generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d)
- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generator- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generator- Returns:
- a
Generator<Tuple4<A, B, C, D>
- See Also:
generateProduct(Generator, Generator, Generator, Generator, Fn4)
-
generateTuple
public static <A,B,C,D,E> Generator<com.jnape.palatable.lambda.adt.hlist.Tuple5<A,B,C,D,E>> generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e)
- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generatorE
- the type of the values generated by the fifth component generator- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generatore
- the fifth component generator- Returns:
- a
Generator<Tuple5<A, B, C, D, E>
- See Also:
generateProduct(Generator, Generator, Generator, Generator, Generator, Fn5)
-
generateTuple
public static <A,B,C,D,E,F> Generator<com.jnape.palatable.lambda.adt.hlist.Tuple6<A,B,C,D,E,F>> generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f)
- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generatorE
- the type of the values generated by the fifth component generatorF
- the type of the values generated by the sixth component generator- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generatore
- the fifth component generatorf
- the sixth component generator- Returns:
- a
Generator<Tuple6<A, B, C, D, E, F>
- See Also:
generateProduct(Generator, Generator, Generator, Generator, Generator, Generator, Fn6)
-
generateTuple
public static <A,B,C,D,E,F,G> Generator<com.jnape.palatable.lambda.adt.hlist.Tuple7<A,B,C,D,E,F,G>> generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, Generator<G> g)
- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generatorE
- the type of the values generated by the fifth component generatorF
- the type of the values generated by the sixth component generatorG
- the type of the values generated by the seventh component generator- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generatore
- the fifth component generatorf
- the sixth component generatorg
- the seventh component generator- Returns:
- a
Generator<Tuple7<A, B, C, D, E, F, G>
- See Also:
generateProduct(Generator, Generator, Generator, Generator, Generator, Generator, Generator, Fn7)
-
generateTuple
public static <A,B,C,D,E,F,G,H> Generator<com.jnape.palatable.lambda.adt.hlist.Tuple8<A,B,C,D,E,F,G,H>> generateTuple(Generator<A> a, Generator<B> b, Generator<C> c, Generator<D> d, Generator<E> e, Generator<F> f, Generator<G> g, Generator<H> h)
- Type Parameters:
A
- the type of the values generated by the first component generatorB
- the type of the values generated by the second component generatorC
- the type of the values generated by the third component generatorD
- the type of the values generated by the fourth component generatorE
- the type of the values generated by the fifth component generatorF
- the type of the values generated by the sixth component generatorG
- the type of the values generated by the seventh component generatorH
- the type of the values generated by the eighth component generator- Parameters:
a
- the first component generatorb
- the second component generatorc
- the third component generatord
- the fourth component generatore
- the fifth component generatorf
- the sixth component generatorg
- the seventh component generatorh
- the eighth component generator- Returns:
- a
Generator<Tuple8<A, B, C, D, E, F, G, H>
- See Also:
generateProduct(Generator, Generator, Generator, Generator, Generator, Generator, Generator, Generator, Fn8)
-
sequence
public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> sequence(java.lang.Iterable<Generator<A>> gs)
Converts a sequence ofGenerator
s to aGenerator
of sequences.- Type Parameters:
A
- the element type- Parameters:
gs
- a sequence of zero or moreGenerator<A>
s- Returns:
- a
Generator<ImmutableVector<A>>
-
sequenceNonEmpty
public static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> sequenceNonEmpty(software.kes.enhancediterables.NonEmptyIterable<Generator<A>> gs)
Converts a non-empty sequence ofGenerator
s to aGenerator
of non-empty sequences.- Type Parameters:
A
- the element type- Parameters:
gs
- a sequence of one or moreGenerator<A>
s- Returns:
- a
Generator<ImmutableNonEmptyVector<A>>
-
generateString
public static Generator<java.lang.String> generateString()
Creates aGenerator
that yieldsString
s of printable ASCII characters, with varying lengths.- Returns:
- a
Generator<String>
-
generateString
public static Generator<java.lang.String> generateString(int numberOfChunks, Generator<java.lang.String> chunkGenerator)
Creates aGenerator
that yieldsString
s by invoking anotherGenerator
a specific number of times, and concatenating the results.- Parameters:
numberOfChunks
- the number of chunks to generate and concatenatechunkGenerator
- the generator for each chunk to be concatenated- Returns:
- a
Generator<String>
-
generateString
public static Generator<java.lang.String> generateString(IntRange numberOfChunksRange, Generator<java.lang.String> chunkGenerator)
Creates aGenerator
that yieldsString
s by invoking anotherGenerator
a random number of times within a specific range, and concatenating the results.- Parameters:
numberOfChunksRange
- theIntRange
of the number of chunks to generate and concatenatechunkGenerator
- the generator for each chunk to be concatenated- Returns:
- a
Generator<String>
-
generateStringFromCharacters
public static Generator<java.lang.String> generateStringFromCharacters(Generator<java.lang.Character> g)
Creates aGenerator
that yieldsString
s by invoking aGenerator<Character>
a varying number of times, and concatenating the results.- Parameters:
g
- the generator for each character to be concatenated- Returns:
- a
Generator<String>
-
generateStringFromCharacters
public static Generator<java.lang.String> generateStringFromCharacters(software.kes.collectionviews.NonEmptyVector<java.lang.Character> characters)
Creates aGenerator
that yieldsString
s by choosing from a collection ofCharacter
s a varying number of times, and concatenating the results.- Parameters:
characters
- the characters to choose from- Returns:
- a
Generator<String>
-
generateStringFromCharacters
public static Generator<java.lang.String> generateStringFromCharacters(int length, Generator<java.lang.Character> g)
Creates aGenerator
that yieldsString
s by invoking aGenerator<Character>
a specific number of times, and concatenating the results.The length of the generated
String
s will always belength
.- Parameters:
g
- the generator for each character to be concatenated- Returns:
- a
Generator<String>
-
generateStringFromCharacters
public static Generator<java.lang.String> generateStringFromCharacters(int length, software.kes.collectionviews.NonEmptyVector<java.lang.Character> characters)
Creates aGenerator
that yieldsString
s by choosing from a collection ofCharacter
s a specific number of times, and concatenating the results.The length of the generated
String
s will always belength
.- Parameters:
characters
- the characters to choose from- Returns:
- a
Generator<String>
-
generateStringFromCharacters
public static Generator<java.lang.String> generateStringFromCharacters(IntRange lengthRange, Generator<java.lang.Character> g)
Creates aGenerator
that yieldsString
s by invoking aGenerator<Character>
a varying number of times within a specific range, and concatenating the results.The length of the generated
String
s will always be withinlengthRange
.- Parameters:
lengthRange
- theIntRange
of the length of the string to generateg
- the generator for each character to be concatenated- Returns:
- a
Generator<String>
-
generateStringFromCharacters
public static Generator<java.lang.String> generateStringFromCharacters(IntRange lengthRange, software.kes.collectionviews.NonEmptyVector<java.lang.Character> characters)
Creates aGenerator
that yieldsString
s by choosing from a collection ofCharacter
s a varying number of times within a specific range, and concatenating the results.The length of the generated
String
s will always be withinlengthRange
.- Parameters:
lengthRange
- theIntRange
of the length of the string to generatecharacters
- the characters to choose from- Returns:
- a
Generator<String>
-
generateString
@SafeVarargs public static Generator<java.lang.String> generateString(Generator<java.lang.String> first, Generator<java.lang.String>... more)
Creates aGenerator
that yieldsString
s by invoking one or moreGenerator<String>
s in order and concatenating the result.- Parameters:
first
- the generator of the first string to be concatenatedmore
- the generators of the remaining strings to be concatenated- Returns:
- a
Generator<String>
-
generateIdentifier
public static Generator<java.lang.String> generateIdentifier()
Creates aGenerator
that yieldsString
s that are legal Java identifiers. May also yield empty strings.- Returns:
- a
Generator<String>
- See Also:
generateIdentifier(int)
,generateIdentifier(IntRange)
-
generateIdentifier
public static Generator<java.lang.String> generateIdentifier(int length)
Creates aGenerator
that yieldsString
s that are legal Java identifiers of a specific length.- Parameters:
length
- the length of the identifiers to generate- Returns:
- a
Generator<String>
- See Also:
generateIdentifier()
,generateIdentifier(IntRange)
-
generateIdentifier
public static Generator<java.lang.String> generateIdentifier(IntRange lengthRange)
Creates aGenerator
that yieldsString
s that are legal Java identifiers with a length within a specific range.- Parameters:
lengthRange
- theIntRange
of the length of the identifiers to generate- Returns:
- a
Generator<String>
- See Also:
generateIdentifier()
,generateIdentifier(int)
-
generateAlphaString
public static Generator<java.lang.String> generateAlphaString()
Creates aGenerator
that yieldsString
s consisting of ASCII alphabetic characters, both lowercase and uppercase.- Returns:
- a
Generator<String>
- See Also:
generateAlphaString(int)
,generateAlphaString(IntRange)
-
generateAlphaString
public static Generator<java.lang.String> generateAlphaString(int length)
Creates aGenerator
that yieldsString
s consisting of ASCII alphabetic characters, both lowercase and uppercase, and with a specific length.- Parameters:
length
- the length of the strings to generate- Returns:
- a
Generator<String>
- See Also:
generateAlphaString()
,generateAlphaString(IntRange)
-
generateAlphaString
public static Generator<java.lang.String> generateAlphaString(IntRange lengthRange)
Creates aGenerator
that yieldsString
s consisting of ASCII alphabetic characters, both lowercase and uppercase, and with a length within a specific range.- Parameters:
lengthRange
- theIntRange
of the length of the strings to generate- Returns:
- a
Generator<String>
- See Also:
generateAlphaString()
,generateAlphaString(int)
-
generateAlphaUpperString
public static Generator<java.lang.String> generateAlphaUpperString()
Creates aGenerator
that yieldsString
s consisting of ASCII uppercase alphabetic characters.- Returns:
- a
Generator<String>
- See Also:
generateAlphaUpperString(int)
,generateAlphaUpperString(IntRange)
-
generateAlphaUpperString
public static Generator<java.lang.String> generateAlphaUpperString(int length)
Creates aGenerator
that yieldsString
s consisting of ASCII uppercase alphabetic characters, and with a specific length.- Parameters:
length
- the length of the strings to generate- Returns:
- a
Generator<String>
- See Also:
generateAlphaUpperString()
,generateAlphaUpperString(IntRange)
-
generateAlphaUpperString
public static Generator<java.lang.String> generateAlphaUpperString(IntRange lengthRange)
Creates aGenerator
that yieldsString
s consisting of ASCII uppercase alphabetic characters, and with a length within a specific range.- Parameters:
lengthRange
- theIntRange
of the length of the strings to generate- Returns:
- a
Generator<String>
- See Also:
generateAlphaUpperString(int)
,generateAlphaUpperString(IntRange)
-
generateAlphaLowerString
public static Generator<java.lang.String> generateAlphaLowerString()
Creates aGenerator
that yieldsString
s consisting of ASCII lowercase alphabetic characters.- Returns:
- a
Generator<String>
- See Also:
generateAlphaLowerString(int)
,generateAlphaLowerString(IntRange)
-
generateAlphaLowerString
public static Generator<java.lang.String> generateAlphaLowerString(int length)
Creates aGenerator
that yieldsString
s consisting of ASCII lowercase alphabetic characters, and with a specific length.- Parameters:
length
- the length of the strings to generate- Returns:
- a
Generator<String>
- See Also:
generateAlphaLowerString()
,generateAlphaLowerString(IntRange)
-
generateAlphaLowerString
public static Generator<java.lang.String> generateAlphaLowerString(IntRange lengthRange)
Creates aGenerator
that yieldsString
s consisting of ASCII lowercase alphabetic characters, and with a length within a specific range.- Parameters:
lengthRange
- theIntRange
of the length of the strings to generate- Returns:
- a
Generator<String>
- See Also:
generateAlphaLowerString(int)
,generateAlphaLowerString(IntRange)
-
generateAlphanumericString
public static Generator<java.lang.String> generateAlphanumericString()
Creates aGenerator
that yieldsString
s consisting of ASCII alphanumeric characters (A-Z, a-z, 0-9).- Returns:
- a
Generator<String>
- See Also:
generateAlphaLowerString(int)
,generateAlphaLowerString(IntRange)
-
generateAlphanumericString
public static Generator<java.lang.String> generateAlphanumericString(int length)
Creates aGenerator
that yieldsString
s consisting of ASCII alphanumeric characters (A-Z, a-z, 0-9), and with a specific length.- Parameters:
length
- the length of the strings to generate- Returns:
- a
Generator<String>
- See Also:
generateAlphaLowerString()
,generateAlphaLowerString(IntRange)
-
generateAlphanumericString
public static Generator<java.lang.String> generateAlphanumericString(IntRange lengthRange)
Creates aGenerator
that yieldsString
s consisting of ASCII alphanumeric characters (A-Z, a-z, 0-9), and with a length within a specific range.- Parameters:
lengthRange
- theIntRange
of the length of the strings to generate- Returns:
- a
Generator<String>
- See Also:
generateAlphaLowerString(int)
,generateAlphaLowerString(IntRange)
-
concatStrings
public static Generator<java.lang.String> concatStrings(java.lang.Iterable<Generator<java.lang.String>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<String>
s and concatenating the results.- Parameters:
components
- a sequence ofGenerator<String>
s to be invoked to generate the components of the output- Returns:
- a
Generator<String>
- See Also:
concatStrings(String, Iterable)
,concatStrings(Generator, Iterable)
-
concatStrings
public static Generator<java.lang.String> concatStrings(java.lang.String separator, java.lang.Iterable<Generator<java.lang.String>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<String>
s and concatenating the results, separating them with a specific separator.- Parameters:
separator
- aString
that will be inserted between each of the components of the outputcomponents
- a sequence ofGenerator<String>
s to be invoked to generate the components of the output- Returns:
- a
Generator<String>
- See Also:
concatStrings(Iterable)
,concatStrings(Generator, Iterable)
-
concatStrings
public static Generator<java.lang.String> concatStrings(Generator<java.lang.String> separator, java.lang.Iterable<Generator<java.lang.String>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<String>
s and concatenating the results, separating them by a separator that is also generated.- Parameters:
separator
- aGenerator<String>
to generate the separator strings. This generator is invoked every time a separator is called for (i.e., between the invocations of each component generator). Note that this can potentially result in a different separator used within the same result.components
- a sequence ofGenerator<String>
s to be invoked to generate the components of the output- Returns:
- a
Generator<String>
- See Also:
concatStrings(Iterable)
,concatStrings(String, Iterable)
-
concatMaybeStrings
public static Generator<java.lang.String> concatMaybeStrings(java.lang.Iterable<Generator<com.jnape.palatable.lambda.adt.Maybe<java.lang.String>>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<Maybe<String>>
s and concatenating the results.- Parameters:
components
- a sequence ofGenerator<Maybe<String>>
s to be invoked to generate the components of the output. If a generator outputs aMaybe.just(Object)
, it will be concatenated to the final output, otherwise ignored.- Returns:
- a
Generator<String>
- See Also:
concatMaybeStrings(String, Iterable)
,concatMaybeStrings(Generator, Iterable)
-
concatMaybeStrings
public static Generator<java.lang.String> concatMaybeStrings(java.lang.String separator, java.lang.Iterable<Generator<com.jnape.palatable.lambda.adt.Maybe<java.lang.String>>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<Maybe<String>>
s and concatenating the results, separating them with a specific separator.- Parameters:
separator
- aString
that will be inserted between each of the components of the output (but only those that yield aMaybe.just(Object)
components
- a sequence ofGenerator<Maybe<String>>
s to be invoked to generate the components of the output. If a generator outputs aMaybe#just
, it will be concatenated to the final output, otherwise ignored.- Returns:
- a
Generator<String>
- See Also:
concatMaybeStrings(Iterable)
,concatMaybeStrings(Generator, Iterable)
-
concatMaybeStrings
public static Generator<java.lang.String> concatMaybeStrings(Generator<java.lang.String> separator, java.lang.Iterable<Generator<com.jnape.palatable.lambda.adt.Maybe<java.lang.String>>> components)
Creates aGenerator
that yieldsString
s by invoking a sequence of componentGenerator<Maybe<String>>
s and concatenating the results, separating them by a separator that is also generated.- Parameters:
separator
- aGenerator<String>
to generate the separator strings. This generator is invoked every time a separator is called for (i.e., between the invocations of each component generator that yield aMaybe.just(Object)
). Note that this can potentially result in a different separator used within the same result.components
- a sequence ofGenerator<Maybe<String>>
s to be invoked to generate the components of the output. If a generator outputs aMaybe#just
, it will be concatenated to the final output, otherwise ignored.- Returns:
- a
Generator<String>
- See Also:
concatMaybeStrings(Iterable)
,concatMaybeStrings(String, Iterable)
-
stringGeneratorBuilder
public static StringGeneratorBuilder stringGeneratorBuilder()
Instantiates aStringGeneratorBuilder
.- Returns:
- a
StringGeneratorBuilder
-
generateNull
public static <A> Generator<A> generateNull()
Creates aGenerator
that, when invoked, always yieldsnull
of a specific type.- Type Parameters:
A
- the type of the output- Returns:
- a
Generator<A>
-
generateWithNulls
public static <A> Generator<A> generateWithNulls(Generator<A> gen)
- Type Parameters:
A
- the type of the output- Parameters:
gen
- the original generator- Returns:
- a
Generator<A>
-
generateWithNulls
public static <A> Generator<A> generateWithNulls(NullWeights weights, Generator<A> gen)
Creates aGenerator
that mixes occasionalnull
values into the output of an existingGenerator
, with a specific probability for null.- Type Parameters:
A
- the type of the output- Parameters:
weights
- the probability for a null value to occur in the outputgen
- the original generator- Returns:
- a
Generator<A>
-
generateUnit
public static Generator<com.jnape.palatable.lambda.adt.Unit> generateUnit()
Creates aGenerator
that, when invoked, always yieldsUnit.UNIT
.- Returns:
- a
Generator<Unit>
-
generateTrue
public static Generator<java.lang.Boolean> generateTrue()
Creates aGenerator
that, when invoked, always yieldstrue
.- Returns:
- a
Generator<Boolean>
-
generateFalse
public static Generator<java.lang.Boolean> generateFalse()
Creates aGenerator
that, when invoked, always yieldsfalse
.- Returns:
- a
Generator<Boolean>
-
generateMaybe
public static <A> Generator<com.jnape.palatable.lambda.adt.Maybe<A>> generateMaybe(Generator<A> gen)
Converts aGenerator
<A>
into aGenerator<Maybe<A>>
that most of the time yields ajust
, but will occasionally yield anothing
.- Type Parameters:
A
- the output type of the generator to convert- Parameters:
gen
- the generator to convert- Returns:
- a
Generator<Maybe<A>>
-
generateMaybe
public static <A> Generator<com.jnape.palatable.lambda.adt.Maybe<A>> generateMaybe(MaybeWeights weights, Generator<A> gen)
Converts aGenerator
<A>
into aGenerator<Maybe<A>>
, with custom probabilities for yieldingjust
vs.nothing
.- Type Parameters:
A
- the output type of the generator to convert- Parameters:
weights
- the probabilities forjust
vs.nothing
gen
- the generator to convert- Returns:
- a
Generator<Maybe<A>>
-
generateJust
public static <A> Generator<com.jnape.palatable.lambda.adt.Maybe<A>> generateJust(Generator<A> gen)
- Type Parameters:
A
- the output type of the generator to convert- Parameters:
gen
- the generator to convert- Returns:
- a
Generator<Maybe<A>>
-
generateNothing
public static <A> Generator<com.jnape.palatable.lambda.adt.Maybe<A>> generateNothing()
Creates aGenerator
that, when invoked, always yieldsMaybe.nothing()
.- Type Parameters:
A
- the output type of the generator to convert- Returns:
- a
Generator<Maybe<A>>
-
generateEither
public static <L,R> Generator<com.jnape.palatable.lambda.adt.Either<L,R>> generateEither(Generator<L> leftGen, Generator<R> rightGen)
- Type Parameters:
L
- the left typeR
- the right type- Parameters:
leftGen
- the generator of left valuesrightGen
- the generator of right values- Returns:
- a
Generator<Either<L, R>>
-
generateEither
public static <L,R> Generator<com.jnape.palatable.lambda.adt.Either<L,R>> generateEither(EitherWeights weights, Generator<L> leftGen, Generator<R> rightGen)
- Type Parameters:
L
- the left typeR
- the right type- Parameters:
weights
- the probabilities forleft
vs.right
leftGen
- the generator of left valuesrightGen
- the generator of right values- Returns:
- a
Generator<Either<L, R>>
-
generateLeft
public static <L,R> Generator<com.jnape.palatable.lambda.adt.Either<L,R>> generateLeft(Generator<L> gen)
- Type Parameters:
L
- the left typeR
- the right type- Parameters:
gen
- the generator of left values- Returns:
- a
Generator<Either<L, R>>
-
generateRight
public static <L,R> Generator<com.jnape.palatable.lambda.adt.Either<L,R>> generateRight(Generator<R> gen)
- Type Parameters:
L
- the left typeR
- the right type- Parameters:
gen
- the generator of right values- Returns:
- a
Generator<Either<L, R>>
-
generateThese
public static <A,B> Generator<com.jnape.palatable.lambda.adt.These<A,B>> generateThese(Generator<A> generatorA, Generator<B> generatorB)
Creates aGenerator
that yieldsThese
s, with equal probabilities for returning a value fromgeneratorA
,generatorB
, or a combination of both.- Type Parameters:
A
- the first possible typeB
- the second possible type- Parameters:
generatorA
- the generator of typeA
generatorB
- the generator of typeB
- Returns:
- a
Generator<These<A, B>>
-
generateThese
public static <A,B> Generator<com.jnape.palatable.lambda.adt.These<A,B>> generateThese(TernaryWeights weights, Generator<A> generatorA, Generator<B> generatorB)
Creates aGenerator
that yieldsThese
s, with custom probabilities for returning a value fromgeneratorA
,generatorB
, or a combination of both.- Type Parameters:
A
- the first possible typeB
- the second possible type- Parameters:
weights
- the probabilities for returning a value forgeneratorA
vs.generatorB
vs. bothgeneratorA
- the generator of typeA
generatorB
- the generator of typeB
- Returns:
- a
Generator<These<A, B>>
-
generateFromEnum
public static <A extends java.lang.Enum<A>> Generator<A> generateFromEnum(java.lang.Class<A> enumType)
Creates aGenerator
that chooses values from an enum.- Type Parameters:
A
- the enum type- Parameters:
enumType
- the class of the enum type- Returns:
- a
Generator<A>
-
chooseOneOf
@SafeVarargs public static <A> Generator<A> chooseOneOf(Generator<? extends A> first, Generator<? extends A>... more)
Creates aGenerator
that, when invoked, randomly selects from a list of candidateGenerator
s, (with equal probabilities for each). The output is then drawn from the chosenGenerator
.- Type Parameters:
A
- the output type- Parameters:
first
- the first candidateGenerator
more
- the remaining candidateGenerator
s- Returns:
- a
Generator<A>
-
chooseOneOfWeighted
@SafeVarargs public static <A> Generator<A> chooseOneOfWeighted(Weighted<? extends Generator<? extends A>> first, Weighted<? extends Generator<? extends A>>... more)
Creates aGenerator
that, when invoked, randomly selects from a list of candidateGenerator
s, (with custom probabilities for each). The output is then drawn from the chosenGenerator
.- Type Parameters:
A
- the output type- Parameters:
first
- the first weighted candidateGenerator
more
- the remaining weighted candidatesGenerator
s- Returns:
- a
Generator<A>
-
chooseOneOfValues
@SafeVarargs public static <A> Generator<A> chooseOneOfValues(A first, A... more)
Creates aGenerator
that, when invoked, randomly chooses an item from one or more candidate values, with an equal probability for each.- Type Parameters:
A
- the output type- Parameters:
first
- the first candidate valuemore
- the remaining candidate values- Returns:
- a
Generator<A>
-
chooseOneOfWeightedValues
@SafeVarargs public static <A> Generator<A> chooseOneOfWeightedValues(Weighted<? extends A> first, Weighted<? extends A>... more)
Creates aGenerator
that, when invoked, randomly chooses and item from one or more candidate values, with custom probabilities for each.- Type Parameters:
A
- the output type- Parameters:
first
- the first weighted candidate valuemore
- the remaining weighted candidate values- Returns:
- a
Generator<A>
-
chooseAtLeastOneOf
@SafeVarargs public static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> chooseAtLeastOneOf(Generator<? extends A> first, Generator<? extends A>... more)
Creates aGenerator
that, when invoked, chooses one or more of the supplied candidateGenerator
s. The chosenGenerator
s are then invoked, and the outputs are collected for the result.- Type Parameters:
A
- the output type- Parameters:
first
- the first candidateGenerator
more
- the remaining candidateGenerator
s- Returns:
- a
Generator<ImmutableNonEmptyVector<A>>
-
chooseAtLeastOneOfValues
@SafeVarargs public static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> chooseAtLeastOneOfValues(A first, A... more)
Creates aGenerator
that, when invoked, chooses one or more of the supplied candidate values, and returns a collection of all those chosen.- Type Parameters:
A
- the output type- Parameters:
first
- the first candidate valuemore
- the remaining candidate values- Returns:
- a
Generator<ImmutableNonEmptyVector<A>>
-
chooseSomeOf
@SafeVarargs public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> chooseSomeOf(Generator<? extends A> first, Generator<? extends A>... more)
Creates aGenerator
that, when invoked, chooses zero or more of the supplied candidateGenerator
s. The chosenGenerator
s are then invoked, and the outputs are collected for the result.- Type Parameters:
A
- the output type- Parameters:
first
- the first candidateGenerator
more
- the remaining candidateGenerator
s- Returns:
- a
Generator<ImmutableVector<A>>
-
chooseSomeOfValues
@SafeVarargs public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> chooseSomeOfValues(A first, A... more)
Creates aGenerator
that, when invoked, chooses zero or more of the supplied candidate values, and returns a collection of all those chosen.- Type Parameters:
A
- the output type- Parameters:
first
- the first candidateGenerator
more
- the remaining candidateGenerator
s- Returns:
- a
Generator<ImmutableVector<A>>
-
chooseOneValueFromCollection
public static <A> Generator<A> chooseOneValueFromCollection(java.lang.Iterable<A> candidates)
Creates aGenerator
that, when invoked, chooses a value from a collection, with an equal probability for each element.- Type Parameters:
A
- the output type- Parameters:
candidates
- the collection of candidate values. Must have at least one element.- Returns:
- a
Generator<A>
-
chooseOneFromCollection
public static <A> Generator<A> chooseOneFromCollection(java.lang.Iterable<Generator<? extends A>> candidates)
Creates aGenerator
that, when invoked, chooses aGenerator
from a collection of candidateGenerator
s (with an equal probability for each). The output is then drawn from the chosenGenerator
.- Type Parameters:
A
- the output type- Parameters:
candidates
- the collection of candidateGenerator
s. Must have at least one element.- Returns:
- a
Generator<A>
-
chooseOneFromCollectionWeighted
public static <A> Generator<A> chooseOneFromCollectionWeighted(java.lang.Iterable<Weighted<? extends Generator<? extends A>>> candidates)
Creates aGenerator
that, when invoked, chooses aGenerator
from a collection of candidateGenerator
s (with a custom probability for each). The output is then drawn from the chosenGenerator
.- Type Parameters:
A
- the output type- Parameters:
candidates
- the collection of weighted candidateGenerator
s. Must have at least one element.- Returns:
- a
Generator<A>
-
chooseOneValueFromDomain
public static <A> Generator<A> chooseOneValueFromDomain(software.kes.collectionviews.NonEmptyVector<A> domain)
Creates aGenerator
that, when invoked, chooses a value from a custom domain.- Type Parameters:
A
- the output type- Parameters:
domain
- the collection of candidates values- Returns:
- a
Generator<A>
-
chooseAtLeastOneValueFromCollection
public static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> chooseAtLeastOneValueFromCollection(java.util.Collection<A> candidates)
Creates aGenerator
that, when invoked, chooses one or more values from a collection and returns a collection of the values chosen.- Type Parameters:
A
- the output type- Parameters:
candidates
- the collection of candidate values. Must have at least one element.- Returns:
- a
Generator<A>
-
chooseAtLeastOneValueFromDomain
public static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> chooseAtLeastOneValueFromDomain(software.kes.collectionviews.NonEmptyVector<A> domain)
Creates aGenerator
that, when invoked, chooses one or more values from a custom domain and returns a collection of the values chosen.- Type Parameters:
A
- the output type- Parameters:
domain
- the collection of candidate values- Returns:
- a
Generator<A>
-
chooseSomeValuesFromCollection
public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> chooseSomeValuesFromCollection(java.util.Collection<A> candidates)
Creates aGenerator
that, when invoked, chooses zero or more values from a collection and returns a collection of the values chosen.- Type Parameters:
A
- the output type- Parameters:
candidates
- the collection of candidate values- Returns:
- a
Generator<A>
-
chooseSomeValuesFromDomain
public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> chooseSomeValuesFromDomain(software.kes.collectionviews.NonEmptyVector<A> domain)
Creates aGenerator
that, when invoked, chooses zero or more values from a custom domain and returns a collection of the values chosen.- Type Parameters:
A
- the output type- Parameters:
domain
- the collection of candidate values- Returns:
- a
Generator<A>
-
chooseEntryFromMap
public static <K,V> Generator<java.util.Map.Entry<K,V>> chooseEntryFromMap(java.util.Map<K,V> map)
- Type Parameters:
K
- the key typeV
- the value type- Parameters:
map
- a map with all candidate entries. Must contain at least one entry.- Returns:
- a
Generator<Map.Entry<K, V>>
-
chooseKeyFromMap
public static <K,V> Generator<K> chooseKeyFromMap(java.util.Map<K,V> map)
Creates aGenerator
that, when invoked, chooses a key from aMap
.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
map
- a map with all candidate keys. Must contain at least one key.- Returns:
- a
Generator<K>
-
chooseValueFromMap
public static <K,V> Generator<V> chooseValueFromMap(java.util.Map<K,V> map)
Creates aGenerator
that, when invoked, chooses a value from aMap
.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
map
- a map with all candidate values. Must contain at least one value.- Returns:
- a
Generator<V>
-
frequency
public static <A> Generator<A> frequency(FrequencyMap<A> frequencyMap)
Creates aGenerator
that chooses its values from aFrequencyMap
.- Type Parameters:
A
- the output type- Parameters:
frequencyMap
- theFrequencyMap
- Returns:
- a
Generator<A>
-
generateArrayList
public static <A> Generator<java.util.ArrayList<A>> generateArrayList(Generator<A> elements)
Creates aGenerator
that yieldsArrayList
s of various sizes.- Type Parameters:
A
- the element type- Parameters:
elements
- the generator for elements- Returns:
- a
Generator<ArrayList<A>>
-
generateNonEmptyArrayList
public static <A> Generator<java.util.ArrayList<A>> generateNonEmptyArrayList(Generator<A> elements)
Creates aGenerator
that yieldsArrayList
s of various sizes, with a minimum size of one.- Type Parameters:
A
- the element type- Parameters:
elements
- the generator for elements- Returns:
- a
Generator<ArrayList<A>>
-
generateArrayListOfSize
public static <A> Generator<java.util.ArrayList<A>> generateArrayListOfSize(int size, Generator<A> elements)
Creates aGenerator
that yieldsArrayList
s of a specific size.- Type Parameters:
A
- the element type- Parameters:
size
- the size of theArrayList
s returned; must be >= 0elements
- the generator for elements- Returns:
- a
Generator<ArrayList<A>>
-
generateArrayListOfSize
public static <A> Generator<java.util.ArrayList<A>> generateArrayListOfSize(IntRange sizeRange, Generator<A> elements)
Creates aGenerator
that yieldsArrayList
s of various sizes, within a specific range.- Type Parameters:
A
- the element type- Parameters:
sizeRange
- the size range of theArrayList
s returnedelements
- the generator for elements- Returns:
- a
Generator<ArrayList<A>>
-
generateHashSet
public static <A> Generator<java.util.HashSet<A>> generateHashSet(Generator<A> elements)
Creates aGenerator
that yieldsHashSet
s of various sizes.- Type Parameters:
A
- the element type- Parameters:
elements
- the generator for elements- Returns:
- a
Generator<HashSet<A>>
-
generateNonEmptyHashSet
public static <A> Generator<java.util.HashSet<A>> generateNonEmptyHashSet(Generator<A> elements)
Creates aGenerator
that yieldsHashSet
s of various sizes, with a minimum size of one.- Type Parameters:
A
- the element type- Parameters:
elements
- the generator for elements- Returns:
- a
Generator<HashSet<A>>
-
generateVector
public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> generateVector(Generator<A> elements)
Creates aGenerator
that yieldsImmutableVector
s of various sizes.- Type Parameters:
A
- the element type- Parameters:
elements
- the generator for elements- Returns:
- a
Generator<ImmutableVector<A>>
-
generateVectorOfSize
public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> generateVectorOfSize(int size, Generator<A> elements)
Creates aGenerator
that yieldsImmutableVector
s of a specific size.- Type Parameters:
A
- the element type- Parameters:
size
- the size of theImmutableVector
s returned; must be >= 0elements
- the generator for elements- Returns:
- a
Generator<ImmutableVector<A>>
-
generateVectorOfSize
public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> generateVectorOfSize(IntRange sizeRange, Generator<A> elements)
Creates aGenerator
that yieldsImmutableVector
s of a various sizes, within a specific range.- Type Parameters:
A
- the element type- Parameters:
sizeRange
- the size range of theImmutableVector
s returnedelements
- the generator for elements- Returns:
- a
Generator<ImmutableVector<A>>
-
generateNonEmptyVector
public static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> generateNonEmptyVector(Generator<A> elements)
Creates aGenerator
that yieldsImmutableNonEmptyVector
s of various sizes.- Type Parameters:
A
- the element type- Parameters:
elements
- the generator for elements- Returns:
- a
Generator<ImmutableNonEmptyVector<A>>
-
generateNonEmptyVectorOfSize
public static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> generateNonEmptyVectorOfSize(int size, Generator<A> elements)
Creates aGenerator
that yieldsImmutableNonEmptyVector
s of a specific size.- Type Parameters:
A
- the element type- Parameters:
size
- the size of theImmutableNonEmptyVector
s returned; must be >= 1elements
- the generator for elements- Returns:
- a
Generator<ImmutableNonEmptyVector<A>>
-
generateNonEmptyVectorOfSize
public static <A> Generator<software.kes.collectionviews.ImmutableNonEmptyVector<A>> generateNonEmptyVectorOfSize(IntRange sizeRange, Generator<A> elements)
Creates aGenerator
that yieldsImmutableNonEmptyVector
s of a various sizes, within a specific range.- Type Parameters:
A
- the element type- Parameters:
sizeRange
- the size range of theImmutableNonEmptyVector
s returnedelements
- the generator for elements- Returns:
- a
Generator<ImmutableNonEmptyVector<A>>
-
generateMap
public static <K,V> Generator<java.util.Map<K,V>> generateMap(Generator<K> generateKey, Generator<V> generateValue)
Creates aGenerator
that yieldsMap
s of various sizes.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
generateKey
- the generator for keysgenerateValue
- the generator for values- Returns:
- a
Generator<Map<K, V>>
-
generateMap
public static <K,V> Generator<java.util.Map<K,V>> generateMap(java.util.Collection<K> keys, Generator<V> generateValue)
Creates aGenerator
that yieldsMap
s with a given set of keys.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
keys
- the keys to populate in the output. All keys will be in the output.generateValue
- the generator for values- Returns:
- a
Generator<Map<K, V>>
-
generateMap
public static <K,V> Generator<java.util.Map<K,V>> generateMap(software.kes.collectionviews.Vector<K> keys, Generator<V> generateValue)
Creates aGenerator
that yieldsMap
s with a given set of keys.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
keys
- the keys to populate in the output. All keys will be in the output.generateValue
- the generator for values- Returns:
- a
Generator<Map<K, V>>
-
generateNonEmptyMap
public static <K,V> Generator<java.util.Map<K,V>> generateNonEmptyMap(Generator<K> generateKey, Generator<V> generateValue)
Creates aGenerator
that yieldsMap
s of various sizes, with a minimum size of one.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
generateKey
- the generator for keysgenerateValue
- the generator for values- Returns:
- a
Generator<Map<K, V>>
-
generateInfiniteIterable
public static <A> Generator<ValueSupply<A>> generateInfiniteIterable(Generator<A> elements)
Creates aGenerator
that yields infiniteIterable
s.- Type Parameters:
A
- the element type- Parameters:
elements
- the generator for elements- Returns:
- a
Generator<ValueSupply<A>>
-
generateShuffled
public static Generator<software.kes.collectionviews.Vector<java.lang.Integer>> generateShuffled(int count)
- Parameters:
count
- the number of elements in the output; must be >= 0.- Returns:
- a
Generator<Vector<Integer>>
-
generateShuffled
public static <A> Generator<software.kes.collectionviews.Vector<A>> generateShuffled(int count, com.jnape.palatable.lambda.functions.Fn1<java.lang.Integer,A> fn)
Creates aGenerator
that yieldsVector
s by shuffling the indices from0
..count-1
in random order, and mapping them to a given function.- Type Parameters:
A
- the element type- Parameters:
count
- the number of elements in the output; must be >= 0.fn
- a pure function that converts an integer from0
..count-1
to an element; should be side-effect free.- Returns:
- a
Generator<Vector<A>>
-
generateNonEmptyShuffled
public static <A> Generator<software.kes.collectionviews.NonEmptyVector<A>> generateNonEmptyShuffled(int count, com.jnape.palatable.lambda.functions.Fn1<java.lang.Integer,A> fn)
Creates aGenerator
that yieldsNonEmptyVector
s by shuffling the indices from0
..count-1
in random order, and mapping them to a given function.- Type Parameters:
A
- the element type- Parameters:
count
- the number of elements in the output; must be >= 1.fn
- a pure function that converts an integer from0
..count-1
to an element; should be side-effect free.- Returns:
- a
Generator<NonEmptyVector<A>>
-
generateShuffled
public static <A> Generator<software.kes.collectionviews.Vector<A>> generateShuffled(software.kes.enhancediterables.FiniteIterable<A> input)
Creates aGenerator
that yieldsVector
s by randomly shuffling the order of the elements in the input.- Type Parameters:
A
- the element type- Parameters:
input
- the input sequence. It is not altered, and is iterated at most once.- Returns:
- a
Generator<Vector<A>>
-
generateShuffled
public static <A> Generator<software.kes.collectionviews.NonEmptyVector<A>> generateShuffled(software.kes.enhancediterables.NonEmptyFiniteIterable<A> input)
Creates aGenerator
that yieldsNonEmptyVector
s by randomly shuffling the order of the elements in the input.- Type Parameters:
A
- the element type- Parameters:
input
- the input sequence. It is not altered, and is iterated at most once.- Returns:
- a
Generator<NonEmptyVector<A>>
-
generateShuffled
public static <A> Generator<software.kes.collectionviews.Vector<A>> generateShuffled(java.util.Collection<A> input)
Creates aGenerator
that yieldsVector
s by randomly shuffling the order of the elements in the input.- Type Parameters:
A
- the element type- Parameters:
input
- the input sequence. It is not altered, and is iterated at most once.- Returns:
- a
Generator<Vector<A>>
-
generateShuffled
public static <A> Generator<software.kes.collectionviews.Vector<A>> generateShuffled(A[] input)
Creates aGenerator
that yieldsVector
s by randomly shuffling the order of the elements in the input.- Type Parameters:
A
- the element type- Parameters:
input
- the input sequence. It is not altered, and is iterated at most once.- Returns:
- a
Generator<Vector<A>>
-
generateShuffled
public static <A> Generator<software.kes.collectionviews.Vector<A>> generateShuffled(software.kes.collectionviews.Vector<A> input)
Creates aGenerator
that yieldsVector
s by randomly shuffling the order of the elements in the input.- Type Parameters:
A
- the element type- Parameters:
input
- the inputVector
- Returns:
- a
Generator<Vector<A>>
-
generateShuffled
public static <A> Generator<software.kes.collectionviews.NonEmptyVector<A>> generateShuffled(software.kes.collectionviews.NonEmptyVector<A> input)
Creates aGenerator
that yieldsNonEmptyVector
s by randomly shuffling the order of the elements in the input.- Type Parameters:
A
- the element type- Parameters:
input
- the inputNonEmptyVector
- Returns:
- a
Generator<NonEmptyVector<A>>
-
choiceBuilder
public static <A> ChoiceBuilder1<A> choiceBuilder(Weighted<? extends Generator<? extends A>> firstChoice)
Creates aChoiceBuilder1
.- Type Parameters:
A
- the output type of the first choice- Parameters:
firstChoice
- a weightedGenerator
for the first choice- Returns:
- a
ChoiceBuilder1<A>
-
choiceBuilder
public static <A> ChoiceBuilder1<A> choiceBuilder(Generator<? extends A> firstChoice)
Creates aChoiceBuilder1
.- Type Parameters:
A
- the output type of the first choice- Parameters:
firstChoice
- aGenerator
for the first choice- Returns:
- a
ChoiceBuilder1<A>
-
choiceBuilderValue
public static <A> ChoiceBuilder1<A> choiceBuilderValue(Weighted<? extends A> firstChoice)
Creates aChoiceBuilder1
.- Type Parameters:
A
- the output type of the first choice- Parameters:
firstChoice
- a weighted value for the first choice- Returns:
- a
ChoiceBuilder1<A>
-
choiceBuilderValue
public static <A> ChoiceBuilder1<A> choiceBuilderValue(A firstChoice)
Creates aChoiceBuilder1
.- Type Parameters:
A
- the output type of the first choice- Parameters:
firstChoice
- a value for the first choice- Returns:
- a
ChoiceBuilder1<A>
-
generateChoice
public static <A,B> Generator<com.jnape.palatable.lambda.adt.choice.Choice2<A,B>> generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b)
Creates aGenerator
that yieldsChoice2
s.- Type Parameters:
A
- the output type of the first choiceB
- the output type of the second choice- Parameters:
a
- a weightedGenerator
for the first choiceb
- a weightedGenerator
for the second choice- Returns:
- a
Generator<Choice2<A, B>>
-
generateChoice
public static <A,B,C> Generator<com.jnape.palatable.lambda.adt.choice.Choice3<A,B,C>> generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c)
Creates aGenerator
that yieldsChoice3
s.- Type Parameters:
A
- the output type of the first choiceB
- the output type of the second choiceC
- the output type of the third choice- Parameters:
a
- a weightedGenerator
for the first choiceb
- a weightedGenerator
for the second choicec
- a weightedGenerator
for the third choice- Returns:
- a
Generator<Choice3<A, B, C>>
-
generateChoice
public static <A,B,C,D> Generator<com.jnape.palatable.lambda.adt.choice.Choice4<A,B,C,D>> generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d)
Creates aGenerator
that yieldsChoice4
s.- Type Parameters:
A
- the output type of the first choiceB
- the output type of the second choiceC
- the output type of the third choiceD
- the output type of the fourth choice- Parameters:
a
- a weightedGenerator
for the first choiceb
- a weightedGenerator
for the second choicec
- a weightedGenerator
for the third choiced
- a weightedGenerator
for the fourth choice- Returns:
- a
Generator<Choice4<A, B, C, D>>
-
generateChoice
public static <A,B,C,D,E> Generator<com.jnape.palatable.lambda.adt.choice.Choice5<A,B,C,D,E>> generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d, Weighted<? extends Generator<? extends E>> e)
Creates aGenerator
that yieldsChoice5
s.- Type Parameters:
A
- the output type of the first choiceB
- the output type of the second choiceC
- the output type of the third choiceD
- the output type of the fourth choiceE
- the output type of the fifth choice- Parameters:
a
- a weightedGenerator
for the first choiceb
- a weightedGenerator
for the second choicec
- a weightedGenerator
for the third choiced
- a weightedGenerator
for the fourth choicee
- a weightedGenerator
for the fifth choice- Returns:
- a
Generator<Choice5<A, B, C, D, E>>
-
generateChoice
public static <A,B,C,D,E,F> Generator<com.jnape.palatable.lambda.adt.choice.Choice6<A,B,C,D,E,F>> generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d, Weighted<? extends Generator<? extends E>> e, Weighted<? extends Generator<? extends F>> f)
Creates aGenerator
that yieldsChoice6
s.- Type Parameters:
A
- the output type of the first choiceB
- the output type of the second choiceC
- the output type of the third choiceD
- the output type of the fourth choiceE
- the output type of the fifth choiceF
- the output type of the sixth choice- Parameters:
a
- a weightedGenerator
for the first choiceb
- a weightedGenerator
for the second choicec
- a weightedGenerator
for the third choiced
- a weightedGenerator
for the fourth choicee
- a weightedGenerator
for the fifth choicef
- a weightedGenerator
for the sixth choice- Returns:
- a
Generator<Choice6<A, B, C, D, E, F>>
-
generateChoice
public static <A,B,C,D,E,F,G> Generator<com.jnape.palatable.lambda.adt.choice.Choice7<A,B,C,D,E,F,G>> generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d, Weighted<? extends Generator<? extends E>> e, Weighted<? extends Generator<? extends F>> f, Weighted<? extends Generator<? extends G>> g)
Creates aGenerator
that yieldsChoice7
s.- Type Parameters:
A
- the output type of the first choiceB
- the output type of the second choiceC
- the output type of the third choiceD
- the output type of the fourth choiceE
- the output type of the fifth choiceF
- the output type of the sixth choiceG
- the output type of the seventh choice- Parameters:
a
- a weightedGenerator
for the first choiceb
- a weightedGenerator
for the second choicec
- a weightedGenerator
for the third choiced
- a weightedGenerator
for the fourth choicee
- a weightedGenerator
for the fifth choicef
- a weightedGenerator
for the sixth choiceg
- a weightedGenerator
for the seventh choice- Returns:
- a
Generator<Choice7<A, B, C, D, E, F, G>>
-
generateChoice
public static <A,B,C,D,E,F,G,H> Generator<com.jnape.palatable.lambda.adt.choice.Choice8<A,B,C,D,E,F,G,H>> generateChoice(Weighted<? extends Generator<? extends A>> a, Weighted<? extends Generator<? extends B>> b, Weighted<? extends Generator<? extends C>> c, Weighted<? extends Generator<? extends D>> d, Weighted<? extends Generator<? extends E>> e, Weighted<? extends Generator<? extends F>> f, Weighted<? extends Generator<? extends G>> g, Weighted<? extends Generator<? extends H>> h)
Creates aGenerator
that yieldsChoice8
s.- Type Parameters:
A
- the output type of the first choiceB
- the output type of the second choiceC
- the output type of the third choiceD
- the output type of the fourth choiceE
- the output type of the fifth choiceF
- the output type of the sixth choiceG
- the output type of the seventh choiceH
- the output type of the eighth choice- Parameters:
a
- a weightedGenerator
for the first choiceb
- a weightedGenerator
for the second choicec
- a weightedGenerator
for the third choiced
- a weightedGenerator
for the fourth choicee
- a weightedGenerator
for the fifth choicef
- a weightedGenerator
for the sixth choiceg
- a weightedGenerator
for the seventh choiceh
- a weightedGenerator
for the eighth choice- Returns:
- a
Generator<Choice8<A, B, C, D, E, F, G, H>>
-
generateFn0
public static <R> Generator<com.jnape.palatable.lambda.functions.Fn0<R>> generateFn0(Generator<R> result)
Creates aGenerator
that yieldsFn0
s.- Type Parameters:
R
- the result type of the function- Parameters:
result
- aGenerator
for the result of the function- Returns:
- a
Generator<Fn0<R>>
-
generateFn1
public static <A,R> Generator<com.jnape.palatable.lambda.functions.Fn1<A,R>> generateFn1(Cogenerator<A> param1, Generator<R> result)
Creates aGenerator
that yieldsFn1
s. Generated functions will be pure and total.- Type Parameters:
A
- the type of the first parameter of the functionR
- the result type of the function- Parameters:
param1
- aCogenerator
for the first parameter of the functionresult
- aGenerator
for the result of the function- Returns:
- a
Generator<Fn1<A, R>>
-
generateFn2
public static <A,B,R> Generator<com.jnape.palatable.lambda.functions.Fn2<A,B,R>> generateFn2(Cogenerator<A> param1, Cogenerator<B> param2, Generator<R> result)
Creates aGenerator
that yields pureFn2
s. Generated functions will be pure and total.- Type Parameters:
A
- the type of the first parameter of the functionB
- the type of the second parameter of the functionR
- the result type of the function- Parameters:
param1
- aCogenerator
for the first parameter of the functionparam2
- aCogenerator
for the second parameter of the functionresult
- aGenerator
for the result of the function- Returns:
- a
Generator<Fn2<A, B, R>>
-
generateFn3
public static <A,B,C,R> Generator<com.jnape.palatable.lambda.functions.Fn3<A,B,C,R>> generateFn3(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Generator<R> result)
Creates aGenerator
that yields pureFn3
s. Generated functions will be pure and total.- Type Parameters:
A
- the type of the first parameter of the functionB
- the type of the second parameter of the functionC
- the type of the third parameter of the functionR
- the result type of the function- Parameters:
param1
- aCogenerator
for the first parameter of the functionparam2
- aCogenerator
for the second parameter of the functionparam3
- aCogenerator
for the third parameter of the functionresult
- aGenerator
for the result of the function- Returns:
- a
Generator<Fn3<A, B, C, R>>
-
generateFn4
public static <A,B,C,D,R> Generator<com.jnape.palatable.lambda.functions.Fn4<A,B,C,D,R>> generateFn4(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Generator<R> result)
Creates aGenerator
that yields pureFn4
s. Generated functions will be pure and total.- Type Parameters:
A
- the type of the first parameter of the functionB
- the type of the second parameter of the functionC
- the type of the third parameter of the functionD
- the type of the fourth parameter of the functionR
- the result type of the function- Parameters:
param1
- aCogenerator
for the first parameter of the functionparam2
- aCogenerator
for the second parameter of the functionparam3
- aCogenerator
for the third parameter of the functionparam4
- aCogenerator
for the fourth parameter of the functionresult
- aGenerator
for the result of the function- Returns:
- a
Generator<Fn4<A, B, C, D, R>>
-
generateFn5
public static <A,B,C,D,E,R> Generator<com.jnape.palatable.lambda.functions.Fn5<A,B,C,D,E,R>> generateFn5(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Cogenerator<E> param5, Generator<R> result)
Creates aGenerator
that yields pureFn5
s. Generated functions will be pure and total.- Type Parameters:
A
- the type of the first parameter of the functionB
- the type of the second parameter of the functionC
- the type of the third parameter of the functionD
- the type of the fourth parameter of the functionE
- the type of the fifth parameter of the functionR
- the result type of the function- Parameters:
param1
- aCogenerator
for the first parameter of the functionparam2
- aCogenerator
for the second parameter of the functionparam3
- aCogenerator
for the third parameter of the functionparam4
- aCogenerator
for the fourth parameter of the functionparam5
- aCogenerator
for the fifth parameter of the functionresult
- aGenerator
for the result of the function- Returns:
- a
Generator<Fn5<A, B, C, D, E, R>>
-
generateFn6
public static <A,B,C,D,E,F,R> Generator<com.jnape.palatable.lambda.functions.Fn6<A,B,C,D,E,F,R>> generateFn6(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Cogenerator<E> param5, Cogenerator<F> param6, Generator<R> result)
Creates aGenerator
that yields pureFn6
s. Generated functions will be pure and total.- Type Parameters:
A
- the type of the first parameter of the functionB
- the type of the second parameter of the functionC
- the type of the third parameter of the functionD
- the type of the fourth parameter of the functionE
- the type of the fifth parameter of the functionF
- the type of the sixth parameter of the functionR
- the result type of the function- Parameters:
param1
- aCogenerator
for the first parameter of the functionparam2
- aCogenerator
for the second parameter of the functionparam3
- aCogenerator
for the third parameter of the functionparam4
- aCogenerator
for the fourth parameter of the functionparam5
- aCogenerator
for the fifth parameter of the functionparam6
- aCogenerator
for the sixth parameter of the functionresult
- aGenerator
for the result of the function- Returns:
- a
Generator<Fn6<A, B, C, D, E, F, R>>
-
generateFn7
public static <A,B,C,D,E,F,G,R> Generator<com.jnape.palatable.lambda.functions.Fn7<A,B,C,D,E,F,G,R>> generateFn7(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Cogenerator<E> param5, Cogenerator<F> param6, Cogenerator<G> param7, Generator<R> result)
Creates aGenerator
that yields pureFn7
s. Generated functions will be pure and total.- Type Parameters:
A
- the type of the first parameter of the functionB
- the type of the second parameter of the functionC
- the type of the third parameter of the functionD
- the type of the fourth parameter of the functionE
- the type of the fifth parameter of the functionF
- the type of the sixth parameter of the functionG
- the type of the seventh parameter of the functionR
- the result type of the function- Parameters:
param1
- aCogenerator
for the first parameter of the functionparam2
- aCogenerator
for the second parameter of the functionparam3
- aCogenerator
for the third parameter of the functionparam4
- aCogenerator
for the fourth parameter of the functionparam5
- aCogenerator
for the fifth parameter of the functionparam6
- aCogenerator
for the sixth parameter of the functionparam7
- aCogenerator
for the seventh parameter of the functionresult
- aGenerator
for the result of the function- Returns:
- a
Generator<Fn7<A, B, C, D, E, F, G, R>>
-
generateFn8
public static <A,B,C,D,E,F,G,H,R> Generator<com.jnape.palatable.lambda.functions.Fn8<A,B,C,D,E,F,G,H,R>> generateFn8(Cogenerator<A> param1, Cogenerator<B> param2, Cogenerator<C> param3, Cogenerator<D> param4, Cogenerator<E> param5, Cogenerator<F> param6, Cogenerator<G> param7, Cogenerator<H> param8, Generator<R> result)
Creates aGenerator
that yields pureFn8
s. Generated functions will be pure and total.- Type Parameters:
A
- the type of the first parameter of the functionB
- the type of the second parameter of the functionC
- the type of the third parameter of the functionD
- the type of the fourth parameter of the functionE
- the type of the fifth parameter of the functionF
- the type of the sixth parameter of the functionG
- the type of the seventh parameter of the functionH
- the type of the eighth parameter of the functionR
- the result type of the function- Parameters:
param1
- aCogenerator
for the first parameter of the functionparam2
- aCogenerator
for the second parameter of the functionparam3
- aCogenerator
for the third parameter of the functionparam4
- aCogenerator
for the fourth parameter of the functionparam5
- aCogenerator
for the fifth parameter of the functionparam6
- aCogenerator
for the sixth parameter of the functionparam7
- aCogenerator
for the seventh parameter of the functionparam8
- aCogenerator
for the eighth parameter of the functionresult
- aGenerator
for the result of the function- Returns:
- a
Generator<Fn8<A, B, C, D, E, F, G, H, R>>
-
generateUUID
public static Generator<java.util.UUID> generateUUID()
Creates aGenerator
that yields version 4UUID
s.- Returns:
- a
Generator<UUID>
-
generateBigInteger
public static Generator<java.math.BigInteger> generateBigInteger()
Creates aGenerator
that yieldsBigInteger
s.- Returns:
- a
Generator<BigInteger>
-
generateBigInteger
public static Generator<java.math.BigInteger> generateBigInteger(BigIntegerRange range)
Creates aGenerator
that yieldsBigInteger
s within a specific range.- Parameters:
range
- theBigIntegerRange
of the values to generate- Returns:
- a
Generator<BigInteger>
-
generateBigDecimal
public static Generator<java.math.BigDecimal> generateBigDecimal()
Creates aGenerator
that yieldsBigDecimal
s.- Returns:
- a
Generator<BigDecimal>
-
generateBigDecimal
public static Generator<java.math.BigDecimal> generateBigDecimal(BigDecimalRange range)
Creates aGenerator
that yieldsBigDecimal
s within a specific range.- Parameters:
range
- theBigDecimalRange
of the values to generate- Returns:
- a
Generator<BigDecimal>
-
generateBigDecimal
public static Generator<java.math.BigDecimal> generateBigDecimal(Generator<java.lang.Integer> generateDecimalPlaces, BigDecimalRange range)
Creates aGenerator
that yieldsBigDecimal
s within a specific range, and with the number of decimal places determined by a specificGenerator
.- Parameters:
generateDecimalPlaces
- aGenerator
to determine the number of decimal places of the generated valuesrange
- theBigDecimalRange
of the values to generate- Returns:
- a
Generator<BigDecimal>
-
generateBigDecimal
public static Generator<java.math.BigDecimal> generateBigDecimal(int decimalPlaces, BigDecimalRange range)
Creates aGenerator
that yieldsBigDecimal
s within a specific range, and with a specific number of decimal places.- Parameters:
decimalPlaces
- the number of decimal places of the generated values- Returns:
- a
Generator<BigDecimal>
-
generateMonth
public static Generator<java.time.Month> generateMonth()
Creates aGenerator
that yieldsMonth
s.- Returns:
- a
Generator<Month>
-
generateDayOfWeek
public static Generator<java.time.DayOfWeek> generateDayOfWeek()
Creates aGenerator
that yieldsDayOfWeek
s.- Returns:
- a
Generator<DayOfWeek>
-
generateLocalDate
public static Generator<java.time.LocalDate> generateLocalDate()
Creates aGenerator
that yieldsLocalDate
s.- Returns:
- a
Generator<LocalDate>
-
generateLocalDate
public static Generator<java.time.LocalDate> generateLocalDate(LocalDateRange range)
Creates aGenerator
that yieldsLocalDate
s within a specific range.- Parameters:
range
- theLocalDateRange
of the values to generate- Returns:
- a
Generator<LocalDate>
-
generateLocalDateForYear
public static Generator<java.time.LocalDate> generateLocalDateForYear(java.time.Year year)
- Parameters:
year
- the year of the values to generate- Returns:
- a
Generator<LocalDate>
-
generateLocalDateForMonth
public static Generator<java.time.LocalDate> generateLocalDateForMonth(java.time.YearMonth yearMonth)
- Parameters:
yearMonth
- the year and month of the values to generate- Returns:
- a
Generator<LocalDate>
-
generateLocalTime
public static Generator<java.time.LocalTime> generateLocalTime()
Creates aGenerator
that yieldsLocalTime
s.- Returns:
- a
Generator<LocalTime>
-
generateLocalTime
public static Generator<java.time.LocalTime> generateLocalTime(LocalTimeRange range)
Creates aGenerator
that yieldsLocalTime
s within a specific range.- Parameters:
range
- theLocalTimeRange
of the values to generate- Returns:
- a
Generator<LocalTime>
-
generateLocalDateTime
public static Generator<java.time.LocalDateTime> generateLocalDateTime()
Creates aGenerator
that yieldsLocalDateTime
s.- Returns:
- a
Generator<LocalDateTime>
-
generateLocalDateTime
public static Generator<java.time.LocalDateTime> generateLocalDateTime(LocalDateRange dateRange)
Creates aGenerator
that yieldsLocalDateTime
s within a specific date range.- Parameters:
dateRange
- theLocalDateRange
of the values to generate- Returns:
- a
Generator<LocalDateTime>
-
generateLocalDateTime
public static Generator<java.time.LocalDateTime> generateLocalDateTime(LocalDateTimeRange range)
Creates aGenerator
that yieldsLocalDateTime
s within a specific range.- Parameters:
range
- theLocalDateTimeRange
of the values to generate- Returns:
- a
Generator<LocalDateTime>
-
generateDuration
public static Generator<java.time.Duration> generateDuration()
Creates aGenerator
that yieldsDuration
s.- Returns:
- a
Generator<Duration>
-
generateDuration
public static Generator<java.time.Duration> generateDuration(DurationRange range)
Creates aGenerator
that yieldsDuration
s with a specific range.- Parameters:
range
- theDurationRange
of the values to generate- Returns:
- a
Generator<Duration>
-
generateFromSemigroup
public static <A> Generator<A> generateFromSemigroup(com.jnape.palatable.lambda.semigroup.Semigroup<A> semigroup, Generator<A> gen)
Creates aGenerator
that builds its results by generating a random number of values (one or more) and combining them usingSemigroup
.- Type Parameters:
A
- the output type- Parameters:
semigroup
- theSemigroup
to apply. May be called zero or more times.gen
- theGenerator
of the values to feed through theSemigroup
- Returns:
- a
Generator<A>
-
generateNFromSemigroup
public static <A> Generator<A> generateNFromSemigroup(com.jnape.palatable.lambda.semigroup.Semigroup<A> semigroup, Generator<A> gen, int count)
Creates aGenerator
that builds its results by generating a specific number of values and combining them usingSemigroup
.- Type Parameters:
A
- the output type- Parameters:
semigroup
- theSemigroup
to applygen
- theGenerator
of the values to feed through theSemigroup
count
- the number of elements to feed through theSemigroup
; must be >= 1- Returns:
- a
Generator<A>
-
generateFromMonoid
public static <A> Generator<A> generateFromMonoid(com.jnape.palatable.lambda.monoid.Monoid<A> monoid, Generator<A> gen)
Creates aGenerator
that builds its results by generating a random number of values (zero or more) and combining them usingMonoid
.- Type Parameters:
A
- the output type- Parameters:
monoid
- theMonoid
to apply. May be called zero or more times.gen
- theGenerator
of the values to feed through theMonoid
- Returns:
- a
Generator<A>
-
generateNFromMonoid
public static <A> Generator<A> generateNFromMonoid(com.jnape.palatable.lambda.monoid.Monoid<A> monoid, Generator<A> gen, int count)
Creates aGenerator
that builds its results by generating a specific number of values and combining them usingMonoid
.- Type Parameters:
A
- the output type- Parameters:
monoid
- theMonoid
to applygen
- theGenerator
of the values to feed through theMonoid
count
- the number of elements to feed through theMonoid
; must be >= 0- Returns:
- a
Generator<A>
-
generateOrderedPair
public static <A extends java.lang.Comparable<A>> Generator<com.jnape.palatable.lambda.adt.hlist.Tuple2<A,A>> generateOrderedPair(Generator<A> elements)
Creates aGenerator
that yields ordered pairs of someComparable
type. The second element of the pair will be greater than or equal to the first element.- Type Parameters:
A
- the element type - must beComparable
- Parameters:
elements
- the generator for elements- Returns:
- a
Generator<Tuple2<A, A>>
-
generateOrderedSequence
public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> generateOrderedSequence(Generator<java.lang.Integer> countForEachElement, software.kes.collectionviews.ImmutableVector<A> orderedElems)
Creates aGenerator
that yields ordered sequences.- Type Parameters:
A
- the element type- Parameters:
countForEachElement
- aGenerator
that determines the count (zero or more) for each element. For each element inorderedElems
, this generator is invoked to yield a number, and the element is repeated in the output that number of times before moving on to the next element.orderedElems
- the ordered sequence of candidates- Returns:
- a
Generator<ImmutableVector<A>>
-
generateOrderedSequence
public static <A> Generator<software.kes.collectionviews.ImmutableVector<A>> generateOrderedSequence(IntRange countForEachElementRange, software.kes.collectionviews.ImmutableVector<A> orderedElems)
Creates aGenerator
that yields ordered sequences.- Type Parameters:
A
- the element type- Parameters:
countForEachElementRange
- theIntRange
of the count of each element in the output. For each element inorderedElems
, a random number in the range is selected, and the element is repeated in the output that number of times before moving on to the next element.orderedElems
- the ordered sequence of candidates- Returns:
- a
Generator<ImmutableVector<A>>
-
generateIntRange
public static Generator<IntRange> generateIntRange()
- Returns:
- a
Generator<IntRange>
-
generateIntRange
public static Generator<IntRange> generateIntRange(IntRange parentRange)
- Parameters:
parentRange
- theIntRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<IntRange>
-
generateLongRange
public static Generator<LongRange> generateLongRange()
- Returns:
- a
Generator<LongRange>
-
generateLongRange
public static Generator<LongRange> generateLongRange(LongRange parentRange)
- Parameters:
parentRange
- theLongRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<LongRange>
-
generateShortRange
public static Generator<ShortRange> generateShortRange()
Creates aGenerator
that yieldsShortRange
s.- Returns:
- a
Generator<ShortRange>
-
generateShortRange
public static Generator<ShortRange> generateShortRange(ShortRange parentRange)
Creates aGenerator
that yieldsShortRange
s, within a specific parent range.- Parameters:
parentRange
- theShortRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<ShortRange>
-
generateByteRange
public static Generator<ByteRange> generateByteRange()
- Returns:
- a
Generator<ByteRange>
-
generateByteRange
public static Generator<ByteRange> generateByteRange(ByteRange parentRange)
- Parameters:
parentRange
- theByteRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<ByteRange>
-
generateDoubleRange
public static Generator<DoubleRange> generateDoubleRange()
Creates aGenerator
that yieldsDoubleRange
s.- Returns:
- a
Generator<DoubleRange>
-
generateDoubleRange
public static Generator<DoubleRange> generateDoubleRange(DoubleRange parentRange)
Creates aGenerator
that yieldsDoubleRange
s, within a specific parent range.- Parameters:
parentRange
- theDoubleRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<DoubleRange>
-
generateFloatRange
public static Generator<FloatRange> generateFloatRange()
Creates aGenerator
that yieldsFloatRange
s.- Returns:
- a
Generator<FloatRange>
-
generateFloatRange
public static Generator<FloatRange> generateFloatRange(FloatRange parentRange)
Creates aGenerator
that yieldsFloatRange
s, within a specific parent range.- Parameters:
parentRange
- theFloatRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<FloatRange>
-
generateBigIntegerRange
public static Generator<BigIntegerRange> generateBigIntegerRange()
Creates aGenerator
that yieldsBigIntegerRange
s.- Returns:
- a
Generator<BigIntegerRange>
-
generateBigIntegerRange
public static Generator<BigIntegerRange> generateBigIntegerRange(BigIntegerRange parentRange)
Creates aGenerator
that yieldsBigIntegerRange
s, within a specific parent range.- Parameters:
parentRange
- theBigIntegerRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<BigIntegerRange>
-
generateBigDecimalRange
public static Generator<BigDecimalRange> generateBigDecimalRange()
Creates aGenerator
that yieldsBigDecimalRange
s.- Returns:
- a
Generator<BigDecimalRange>
-
generateBigDecimalRange
public static Generator<BigDecimalRange> generateBigDecimalRange(BigDecimalRange parentRange)
Creates aGenerator
that yieldsBigDecimalRange
s, within a specific parent range.- Parameters:
parentRange
- theBigDecimalRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<BigDecimalRange>
-
generateLocalDateRange
public static Generator<LocalDateRange> generateLocalDateRange()
Creates aGenerator
that yieldsLocalDateRange
s.- Returns:
- a
Generator<LocalDateRange>
-
generateLocalDateRange
public static Generator<LocalDateRange> generateLocalDateRange(LocalDateRange parentRange)
Creates aGenerator
that yieldsLocalDateRange
s, within a specific parent range.- Parameters:
parentRange
- theLocalDateRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<LocalDateRange>
-
generateLocalTimeRange
public static Generator<LocalTimeRange> generateLocalTimeRange()
Creates aGenerator
that yieldsLocalTimeRange
s.- Returns:
- a
Generator<LocalTimeRange>
-
generateLocalTimeRange
public static Generator<LocalTimeRange> generateLocalTimeRange(LocalTimeRange parentRange)
Creates aGenerator
that yieldsLocalTimeRange
s, within a specific parent range.- Parameters:
parentRange
- theLocalTimeRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<LocalTimeRange>
-
generateLocalDateTimeRange
public static Generator<LocalDateTimeRange> generateLocalDateTimeRange()
Creates aGenerator
that yieldsLocalDateTimeRange
s.- Returns:
- a
Generator<LocalDateTimeRange>
-
generateLocalDateTimeRange
public static Generator<LocalDateTimeRange> generateLocalDateTimeRange(LocalDateRange parentRange)
Creates aGenerator
that yieldsLocalDateTimeRange
s, within a specific parent range.- Parameters:
parentRange
- theLocalDateRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<LocalDateTimeRange>
-
generateLocalDateTimeRange
public static Generator<LocalDateTimeRange> generateLocalDateTimeRange(LocalDateTimeRange parentRange)
Creates aGenerator
that yieldsLocalDateTimeRange
s, within a specific parent range.- Parameters:
parentRange
- theLocalDateTimeRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<LocalDateTimeRange>
-
generateDurationRange
public static Generator<DurationRange> generateDurationRange()
Creates aGenerator
that yieldsDurationRange
s.- Returns:
- a
Generator<DurationRange>
-
generateDurationRange
public static Generator<DurationRange> generateDurationRange(DurationRange parentRange)
Creates aGenerator
that yieldsDurationRange
s, within a specific parent range.- Parameters:
parentRange
- theDurationRange
to restrict the output. The output ranges will either be equal to or fully subsumed by this range.- Returns:
- a
Generator<DurationRange>
-
-