Interface MockUnit<T>
-
- All Known Subinterfaces:
MockUnitDays,MockUnitDouble,MockUnitFloat,MockUnitInt,MockUnitLocalDate,MockUnitLong,MockUnitMonth,MockUnitString
- All Known Implementing Classes:
Actors,Actresses,Addresses,Bools,Cars,Celebrities,Chars,Constant,Constructor,Countries,Creatures,CreditCards,CSVs,CVVS,Days,Departments,Domains,Doubles,Emails,Factory,Filler,Floats,Formatter,Genders,IBANs,Industries,Ints,IntSeq,IPv4s,IPv6s,ISSNS,JazzArtists,LocalDates,Longs,LongSeq,Macs,Markovs,Mimes,Money,Months,Names,NaughtyStrings,ObjectMap,Passwords,Primes,Probabilities,Reflect,Regex,RockStars,Seq,Space,SQLInserts,SSCs,Strings,UKPrimeMinisters,URLs,Users,USPresidents,USStates,UUIDs,Words
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface MockUnit<T>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default MockUnit<T[]>array(java.lang.Class<T> cls, int size)Transforms aMockUnit<T>into aMockUnit<T[]>.default MockUnit<T[]>array(java.util.function.Supplier<T[]> arraySupplier)Transforms aMockUnit<T>into aMockUnit<T[]>.default MockUnit<java.util.Collection<T>>collection(int size)Transforms aMockUnit<T>into aMockUnit<Collection<T>>.default MockUnit<java.util.Collection<T>>collection(java.lang.Class<? extends java.util.Collection> collectionClass, int size)Deprecated.usecollection(Supplier, int)instead.default MockUnit<java.util.Collection<T>>collection(java.lang.Class<? extends java.util.Collection> collectionClass, MockUnitInt sizeUnit)Deprecated.usecollection(Supplier, MockUnitInt)instead.default MockUnit<java.util.Collection<T>>collection(java.util.function.Supplier<java.util.Collection<T>> collectionSupplier, int size)Transforms aMockUnit<T>into aMockUnit<Collection<T>>.default MockUnit<java.util.Collection<T>>collection(java.util.function.Supplier<java.util.Collection<T>> collectionSupplier, MockUnitInt sizeUnit)Transforms aMockUnit<T>into aMockUnit<Collection<T>>.default MockUnit<java.util.Collection<T>>collection(MockUnitInt sizeUnit)Transforms aMockUnit<T>into aMockUnit<Collection<T>>.default voidconsume(int times, java.util.function.BiConsumer<java.lang.Integer,T> biConsumer)Passes the arbitrary generated values to aBiConsumer<Integer, T>a number oftimes.default voidconsume(java.util.function.Consumer<T> consumer)Passes the arbitrary generated value to aConsumer<T>.default Tget()Returns the generated value as defined by the chain of constraints.default <R> Rget(java.util.function.Function<T,R> function)Returns the generated value, after it applies the suppliedFunction<T, R>default MockUnit<java.util.List<T>>list(int size)Transforms aMockUnit<T>into aMockUnit<List<T>>.default MockUnit<java.util.List<T>>list(java.lang.Class<? extends java.util.List> listClass, int size)Deprecated.uselist(Supplier, int)instead.default MockUnit<java.util.List<T>>list(java.lang.Class<? extends java.util.List> listClass, MockUnitInt sizeUnit)Deprecated.uselist(Supplier, MockUnitInt)instead.default MockUnit<java.util.List<T>>list(java.util.function.Supplier<java.util.List<T>> listSupplier, int size)Transforms aMockUnit<T>into aMockUnit<List<T>>.default MockUnit<java.util.List<T>>list(java.util.function.Supplier<java.util.List<T>> listSupplier, MockUnitInt sizeUnit)Transforms aMockUnit<T>into aMockUnit<List<T>>.default MockUnit<java.util.List<T>>list(MockUnitInt sizeUnit)Transforms aMockUnit<T>into aMockUnit<List<T>>.default <R> MockUnit<R>map(java.util.function.Function<T,R> function)This method can be used in order to add intermediary processing before generating the value<T>.default MockUnit<java.util.Map<java.lang.Double,T>>mapKeys(double[] keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.default MockUnit<java.util.Map<java.lang.Integer,T>>mapKeys(int[] keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.default <R> MockUnit<java.util.Map<R,T>>mapKeys(int size, java.util.function.Supplier<R> keysSupplier)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenSupplier<R>.default MockUnit<java.util.Map<java.lang.Long,T>>mapKeys(long[] keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.default MockUnit<java.util.Map<java.lang.Double,T>>mapKeys(java.lang.Class<? extends java.util.Map> mapClass, double[] keys)Deprecated.usemapKeys(Supplier, double[])instead.default MockUnit<java.util.Map<java.lang.Integer,T>>mapKeys(java.lang.Class<? extends java.util.Map> mapClass, int[] keys)Deprecated.usemapKeys(Supplier, int[])instead.default <R> MockUnit<java.util.Map<R,T>>mapKeys(java.lang.Class<? extends java.util.Map> mapClass, int size, java.util.function.Supplier<R> keysSupplier)Deprecated.usemapKeys(Supplier, int, Supplier)instead.default MockUnit<java.util.Map<java.lang.Long,T>>mapKeys(java.lang.Class<? extends java.util.Map> mapClass, long[] keys)Deprecated.usemapKeys(Supplier, long[])instead.default <R> MockUnit<java.util.Map<R,T>>mapKeys(java.lang.Class<? extends java.util.Map> mapClass, java.lang.Iterable<R> keys)Deprecated.usemapKeys(Supplier, Iterable)instead.default <R> MockUnit<java.util.Map<R,T>>mapKeys(java.lang.Class<? extends java.util.Map> mapClass, MockUnitInt sizeUnit, java.util.function.Supplier<R> keysSupplier)Deprecated.usemapKeys(Supplier, MockUnitInt, Supplier)instead.default <R> MockUnit<java.util.Map<R,T>>mapKeys(java.lang.Class<? extends java.util.Map> mapClass, R[] keys)Deprecated.usemapKeys(Supplier, Object[])instead.default <R> MockUnit<java.util.Map<R,T>>mapKeys(java.lang.Iterable<R> keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenIterable<R>.default MockUnit<java.util.Map<java.lang.Double,T>>mapKeys(java.util.function.Supplier<java.util.Map<java.lang.Double,T>> mapSupplier, double[] keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.default MockUnit<java.util.Map<java.lang.Integer,T>>mapKeys(java.util.function.Supplier<java.util.Map<java.lang.Integer,T>> mapSupplier, int[] keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.default MockUnit<java.util.Map<java.lang.Long,T>>mapKeys(java.util.function.Supplier<java.util.Map<java.lang.Long,T>> mapSupplier, long[] keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.default <R> MockUnit<java.util.Map<R,T>>mapKeys(java.util.function.Supplier<java.util.Map<R,T>> mapSupplier, int size, java.util.function.Supplier<R> keySupplier)Transforms aMockUnit<T>into aMockUnit<Map<R,T>where the keys are generated from a givenSupplier<R>.default <R> MockUnit<java.util.Map<R,T>>mapKeys(java.util.function.Supplier<java.util.Map<R,T>> mapSupplier, java.lang.Iterable<R> keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenIterable<R>.default <R> MockUnit<java.util.Map<R,T>>mapKeys(java.util.function.Supplier<java.util.Map<R,T>> mapSupplier, MockUnitInt sizeUnit, java.util.function.Supplier<R> keySupplier)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenSupplier<R>.default <R> MockUnit<java.util.Map<R,T>>mapKeys(java.util.function.Supplier<java.util.Map<R,T>> mapSupplier, R[] keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenIterable<R>.default <R> MockUnit<java.util.Map<R,T>>mapKeys(MockUnitInt sizeUnit, java.util.function.Supplier<R> keysSupplier)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenSupplier<R>.default <R> MockUnit<java.util.Map<R,T>>mapKeys(R[] keys)Transforms aMockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.default MockUnitDoublemapToDouble(java.util.function.ToDoubleFunction<T> function)This method is used to transform aMockUnitinto aMockUnitDouble.default MockUnitIntmapToInt(java.util.function.ToIntFunction<T> function)This method is used to transform aMockUnitinto aMockUnitInt.default MockUnitLocalDatemapToLocalDate(java.util.function.Function<T,java.time.LocalDate> dateTransformer)This method is used to transform aMockUnitinto aMOckUnitLocaldate.default MockUnitLongmapToLong(java.util.function.ToLongFunction<T> function)This method is used to transform aMockUnitinto aMockUnitLong.default MockUnitStringmapToString()This method is used to transform aMockUnitinto aMockUnitStringby calling theObject.toString()method.default MockUnitStringmapToString(java.util.function.Function<T,java.lang.String> function)This method is used to transform a MockUnit into a MockUnitString.default MockUnit<java.util.Map<T,java.lang.Double>>mapVals(double[] values)Transforms aMockUnit<T>into aMockUnit<T,R>where the values are generated from an array.default MockUnit<java.util.Map<T,java.lang.Integer>>mapVals(int[] values)Transforms aMockUnit<T>into aMockUnit<T,Integer>where the values are generated from an array.default <R> MockUnit<java.util.Map<T,R>>mapVals(int size, java.util.function.Supplier<R> valuesSupplier)Transforms aMockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.default MockUnit<java.util.Map<T,java.lang.Long>>mapVals(long[] values)Transforms aMockUnit<T>into aMockUnit<T,R>where the values are generated from an array.default MockUnit<java.util.Map<T,java.lang.Double>>mapVals(java.lang.Class<? extends java.util.Map> mapClass, double[] values)Deprecated.usemapVals(Supplier, double[])instead.default MockUnit<java.util.Map<T,java.lang.Integer>>mapVals(java.lang.Class<? extends java.util.Map> mapClass, int[] values)Deprecated.usemapVals(Supplier, int[])instead.default <R> MockUnit<java.util.Map<T,R>>mapVals(java.lang.Class<? extends java.util.Map> mapClass, int size, java.util.function.Supplier<R> valuesSupplier)Deprecated.usemapVals(Supplier, int, Supplier)instead.default MockUnit<java.util.Map<T,java.lang.Long>>mapVals(java.lang.Class<? extends java.util.Map> mapClass, long[] values)Deprecated.usemapVals(Supplier, long[])insteaddefault <R> MockUnit<java.util.Map<T,R>>mapVals(java.lang.Class<? extends java.util.Map> mapClass, java.lang.Iterable<R> values)Deprecated.usemapVals(Supplier, Iterable)instead.default <R> MockUnit<java.util.Map<T,R>>mapVals(java.lang.Class<? extends java.util.Map> mapClass, MockUnitInt sizeUnit, java.util.function.Supplier<R> valuesSupplier)Deprecated.usemapVals(Supplier, MockUnitInt, Supplier)instead.default <R> MockUnit<java.util.Map<T,R>>mapVals(java.lang.Class<? extends java.util.Map> mapClass, R[] values)Deprecated.usemapVals(Supplier, Object[])instead.default <R> MockUnit<java.util.Map<T,R>>mapVals(java.lang.Iterable<R> values)Transforms aMockUnit<T>into aMockUnit<T,R>where the values are generated from aIterable<R>.default MockUnit<java.util.Map<T,java.lang.Double>>mapVals(java.util.function.Supplier<java.util.Map<T,java.lang.Double>> mapSupplier, double[] values)Transforms aMockUnit<T>into aMockUnit<T,Double>where the values are generated from an array.default MockUnit<java.util.Map<T,java.lang.Integer>>mapVals(java.util.function.Supplier<java.util.Map<T,java.lang.Integer>> mapSupplier, int[] values)Transforms aMockUnit<T>into aMockUnit<T,Integer>where the values are generated from an array.default MockUnit<java.util.Map<T,java.lang.Long>>mapVals(java.util.function.Supplier<java.util.Map<T,java.lang.Long>> mapSupplier, long[] values)Transforms aMockUnit<T>into aMockUnit<T,Long>where the values are generated from an array.default <R> MockUnit<java.util.Map<T,R>>mapVals(java.util.function.Supplier<java.util.Map<T,R>> mapSupplier, int size, java.util.function.Supplier<R> valuesSupplier)Transforms aMockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.default <R> MockUnit<java.util.Map<T,R>>mapVals(java.util.function.Supplier<java.util.Map<T,R>> mapSupplier, java.lang.Iterable<R> values)Transforms aMockUnit<T>into aMockUnit<T,R>where the values generated from aIterable<R>.default <R> MockUnit<java.util.Map<T,R>>mapVals(java.util.function.Supplier<java.util.Map<T,R>> mapSupplier, MockUnitInt sizeUnit, java.util.function.Supplier<R> valuesSupplier)Transforms aMockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.default <R> MockUnit<java.util.Map<T,R>>mapVals(java.util.function.Supplier<java.util.Map<T,R>> mapSupplier, R[] values)Transforms aMockUnit<T>into aMockUnit<T,R>where the values are generated from an array.default <R> MockUnit<java.util.Map<T,R>>mapVals(MockUnitInt sizeUnit, java.util.function.Supplier<R> valuesSupplier)Transforms aMockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.default <R> MockUnit<java.util.Map<T,R>>mapVals(R[] values)Transforms aMockUnit<T>into aMockUnit<T,R>where the values are generated from an array.default voidserialize(java.lang.String path)Serializes the generated value<T>into a file.default MockUnit<java.util.Set<T>>set(int size)Transforms aMockUnit<T>into aMockUnit<Set<T>>.default MockUnit<java.util.Set<T>>set(java.lang.Class<? extends java.util.Set> setClass, int size)Deprecated.since 0.4.2 useset(Supplier, int)insteaddefault MockUnit<java.util.Set<T>>set(java.lang.Class<? extends java.util.Set> setClass, MockUnitInt sizeUnit)Deprecated.useset(Supplier, MockUnitInt)instead.default MockUnit<java.util.Set<T>>set(java.util.function.Supplier<java.util.Set<T>> setSupplier, int size)Transforms aMockUnit<T>into aMockUnit<Set<T>>.default MockUnit<java.util.Set<T>>set(java.util.function.Supplier<java.util.Set<T>> setSupplier, MockUnitInt sizeUnit)Transforms aMockUnit<T>into aMockUnit<Set<T>>.default MockUnit<java.util.Set<T>>set(MockUnitInt sizeUnit)Transforms aMockUnit<T>into aMockUnit<Set<T>>.default MockUnit<java.util.stream.Stream<T>>stream()Transforms aMockUnit<T>into aMockUnit<Stream<T>>.java.util.function.Supplier<T>supplier()This is the sole abstract method of the interface.default Tval()Returns the generated value as defined by the chain of constraints.default <R> Rval(java.util.function.Function<T,R> function)Returns the generated value, after it applies the suppliedFunction<T, R>default java.lang.StringvalStr()Before retrieving the generated value, this method callsObject.toString()on<T>.default java.lang.StringvalStr(java.lang.String valueIfNull)The method is callingObject.toString()of the generated value.
-
-
-
Method Detail
-
supplier
java.util.function.Supplier<T> supplier()
This is the sole abstract method of the interface. Needs to be implemented every-time a MockUnit is implemented.- Returns:
- A
Supplier<T>.
-
val
default T val()
Returns the generated value as defined by the chain of constraints. This is a closing method.
Each subsequent call will trigger the generating mechanism and potentially will return a distinct value from the previous one.
- Returns:
- The generated value.
-
get
default T get()
Returns the generated value as defined by the chain of constraints. This is a closing method.
Each subsequent call will trigger the generating mechanism and potentially will return a distinct value from the previous one.
In some JVM languages val is a restricted keyword soget()was introduced as an alias for theval()method.- Returns:
- The generated value
-
serialize
default void serialize(java.lang.String path) throws java.io.IOExceptionSerializes the generated value
<T>into a file.The method uses the standard Java serialization mechanism.
Note: If the specified path is not accessible a
UncheckedIOExceptionis thrown.- Parameters:
path- The path of the file where to serialize the generated value.- Throws:
java.io.IOException- when the serialisation of the object is not achievable and the file cannot be written on the disk
-
val
default <R> R val(java.util.function.Function<T,R> function)
Returns the generated value, after it applies the supplied
Function<T, R>Each subsequent call will trigger the generating mechanism and potentially will return a distinct value from the previous one.
- Type Parameters:
R- The type of the newly returnedMockUnit. Can be the same as</T>- Parameters:
function- TheFunction<T,R>applied to the generated value.<T>and<R>can be the same type.- Returns:
- A new pre-processed arbitrary value of type
<R>.
-
get
default <R> R get(java.util.function.Function<T,R> function)
Returns the generated value, after it applies the supplied
Function<T, R>Each subsequent call will trigger the generating mechanism and potentially will return a distinct value from the previous one.
In some JVM languages val is a restricted keyword soget()was introduced as an alias for theval()method.- Type Parameters:
R- The type of the newly returnedMockUnit. Can be the same as</T>- Parameters:
function- TheFunction<T,R>applied to the generated value.<T>and<R>can be the same type.- Returns:
- A new pre-processed arbitrary value of type
<R>.
-
consume
default void consume(java.util.function.Consumer<T> consumer)
Passes the arbitrary generated value to a
Consumer<T>.- Parameters:
consumer- TheConsumer<T>method that will make use of the generated value<T>.
-
consume
default void consume(int times, java.util.function.BiConsumer<java.lang.Integer,T> biConsumer)Passes the arbitrary generated values to a
BiConsumer<Integer, T>a number oftimes.- Parameters:
times- The number of times we are going to call theBiConsumer.biConsumer- TheBiConsumerthat is going to consume the arbitrary generated value(s). The first parameter of theBiConsumerrepresents the step.
-
valStr
default java.lang.String valStr()
Before retrieving the generated value, this method calls
Object.toString()on<T>.If the generated value is null an empty string
("")is returned instead of throwingNullPointerException- Returns:
- The string representation of the generated value.
-
valStr
default java.lang.String valStr(java.lang.String valueIfNull)
The method is calling
Object.toString()of the generated value.If the generated value is
nullreturns thevalueIfNullparameter instead.- Parameters:
valueIfNull- The default value to be returned if the generated value is null.- Returns:
- The string representation of the generated value.
-
map
default <R> MockUnit<R> map(java.util.function.Function<T,R> function)
This method can be used in order to add intermediary processing before generating the value
<T>.- Type Parameters:
R- The type of the newly returnedMockUnit<R>.- Parameters:
function- TheFunction<T,R>applied to the generated value in the intermediary step.<T>and<R>can be the same type.- Returns:
- A new MockUnit
-
mapToInt
default MockUnitInt mapToInt(java.util.function.ToIntFunction<T> function)
This method is used to transform a
MockUnitinto aMockUnitInt.MockUnitIntis a super-type ofMockUnitspecialized in manipulating Integers.- Parameters:
function- TheFunction<T,Integer>applied to the generated value in the intermediary step.- Returns:
- A new
MockUnitInt.
-
mapToDouble
default MockUnitDouble mapToDouble(java.util.function.ToDoubleFunction<T> function)
This method is used to transform a
MockUnitinto aMockUnitDouble.MockUnitDoubleis a super-type ofMockUnitspecialized in manipulating Doubles.- Parameters:
function- TheFunction<T,Double>applied to the generated value in the intermediary step.- Returns:
- A new
MockUnitDouble
-
mapToLong
default MockUnitLong mapToLong(java.util.function.ToLongFunction<T> function)
This method is used to transform a
MockUnitinto aMockUnitLong.MockUnitLongis a super-type ofMockUnitspecialized in manipulating Longs.- Parameters:
function- TheFunction<T,Long>applied to the generated value in the intermediary step.- Returns:
- A new
MockUnitLong
-
mapToString
default MockUnitString mapToString(java.util.function.Function<T,java.lang.String> function)
This method is used to transform a MockUnit into a MockUnitString.
MockUnitString is a super-type of MockUnit containing more useful methods for manipulating Strings.
- Parameters:
function- The transformation method.- Returns:
- A new MockUnitString
-
mapToString
default MockUnitString mapToString()
This method is used to transform a
MockUnitinto aMockUnitStringby calling theObject.toString()method.MockUnitStringis a super-type ofMockUnitcontaining more useful methods for manipulating Strings.- Returns:
- A new
MockUnitString.
-
mapToLocalDate
default MockUnitLocalDate mapToLocalDate(java.util.function.Function<T,java.time.LocalDate> dateTransformer)
This method is used to transform a
MockUnitinto aMOckUnitLocaldate.- Parameters:
dateTransformer- The transformationFunction<T, LocalDate>- Returns:
- A new
MockUnitLocalDate
-
stream
default MockUnit<java.util.stream.Stream<T>> stream()
Transforms a
MockUnit<T>into aMockUnit<Stream<T>>.- Returns:
- A
MockUnit<Stream<T>>
-
list
@Deprecated default MockUnit<java.util.List<T>> list(java.lang.Class<? extends java.util.List> listClass, int size)
Deprecated.uselist(Supplier, int)instead.Transforms a
MockUnit<T>into aMockUnit<List<T>>.This method can used to generate fixed-length Lists containing arbitrary data.
- Parameters:
listClass- The type of List we are going to use as the internal implementation (Eg.: ArrayList.class)size- The size of the List- Returns:
- A new
MockUnit<List<T>>
-
list
default MockUnit<java.util.List<T>> list(java.util.function.Supplier<java.util.List<T>> listSupplier, int size)
Transforms a
MockUnit<T>into aMockUnit<List<T>>.Note: The
listSuppliershould not return NULL values. Otherwise a NullPointer exception is thrown.- Parameters:
listSupplier- The supplier that returns aList<T>size- The final size of the list.- Returns:
- A new
MockUnit<List<T>>.
-
list
@Deprecated default MockUnit<java.util.List<T>> list(java.lang.Class<? extends java.util.List> listClass, MockUnitInt sizeUnit)
Deprecated.uselist(Supplier, MockUnitInt)instead.Transforms a
MockUnit<T>into aMockUnit<List<T>>.This method can used to generate variable-length Lists containing arbitrary data.
- Parameters:
listClass- The type of List we are going to use as the internal implementation (Eg.: ArrayList.class)sizeUnit- The MockUnitInt used to generate the size of the List. If the MockUnitInt generates a negative value an exception will be thrown.- Returns:
- A new
MockUnit<List<T>>
-
list
default MockUnit<java.util.List<T>> list(java.util.function.Supplier<java.util.List<T>> listSupplier, MockUnitInt sizeUnit)
Transforms a
MockUnit<T>into aMockUnit<List<T>>.Note: The
listSuppliershould not return NULL values. Otherwise a NullPointer exception is thrown.- Parameters:
listSupplier- The supplier that returns aList<T>sizeUnit- The MockUnitInt used to generate the size of the List. If the MockUnitInt generates a negative value an exception will be thrown.- Returns:
- A new
MockUnit<List<T>>
-
list
default MockUnit<java.util.List<T>> list(int size)
Transforms a
MockUnit<T>into aMockUnit<List<T>>.This method can used to generate fixed-length Lists containing arbitrary data.
NoteThe internal List implementation will be an
ArrayList.- Parameters:
size- The size of the list.- Returns:
- A new
MockUnit<List<T>>
-
list
default MockUnit<java.util.List<T>> list(MockUnitInt sizeUnit)
Transforms a
MockUnit<T>into aMockUnit<List<T>>.This method can used to generate variable-length Lists containing arbitrary data.
Note: The internal List implementation will be
ArrayList.- Parameters:
sizeUnit- The MockUnitInt used to generate the size of the List. If the MockUnitInt generates a negative value an exception will be thrown.- Returns:
- A new
MockUnit<List<T>>
-
set
@Deprecated default MockUnit<java.util.Set<T>> set(java.lang.Class<? extends java.util.Set> setClass, int size)
Deprecated.since 0.4.2 useset(Supplier, int)insteadTransforms a
MockUnit<T>into aMockUnit<Set<T>>.This method can be used to generate a fixed-length Set containing arbitrary data.
Note: The size represents the max size of the Set, but it's not guaranteed to be so, given the nature of the Set (it doesn't accept duplicates).
Note: If you are using a TreeSet.class as the implementing class you need to take in consideration it doesn't accept null values.
Note: The implementing set need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
setClass- TheSet<T>implementation we are going to use.size- The max size of the Set.- Returns:
- A new
MockUnit<Set<T>>
-
set
default MockUnit<java.util.Set<T>> set(java.util.function.Supplier<java.util.Set<T>> setSupplier, int size)
Transforms a
MockUnit<T>into aMockUnit<Set<T>>.This method can be used to generate a fixed-length Set containing arbitrary data.
Note: The
setSuppliershould not return NULL values. Otherwise a NullPointer exception is thrown.Note: The size represents the max size of the Set, but it's not guaranteed to be so, given the nature of the Set (it doesn't accept duplicates).
Note: If you are using a TreeSet.class as the implementing class you need to take in consideration it doesn't accept null values.
Note: The implementing set need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
setSupplier- The supplier that returns aSet<T>.size- The max size of the Set.- Returns:
- A new
MockUnit<Set<T>>
-
set
@Deprecated default MockUnit<java.util.Set<T>> set(java.lang.Class<? extends java.util.Set> setClass, MockUnitInt sizeUnit)
Deprecated.useset(Supplier, MockUnitInt)instead.Transforms a
MockUnit<T>into aMockUnit<Set<T>>.This method can be used to generate a variable-length Set containing arbitrary data.
Note: The size represents the max size of the Set, but it's not guaranteed to be so, given the nature of the Set (it doesn't accept duplicates).
Note: If you are using a TreeSet as the implementing class you need to take in consideration it doesn't accept null values.
Note: The implementing set need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
setClass- setSupplier The supplier that returns aSet<T>.sizeUnit- The MockUnitInt used to generate the size of the Set. If the MockUnitInt generates a negative value an exception will be thrown.- Returns:
- A new
MockUnit<Set<T>>
-
set
default MockUnit<java.util.Set<T>> set(java.util.function.Supplier<java.util.Set<T>> setSupplier, MockUnitInt sizeUnit)
Transforms a
MockUnit<T>into aMockUnit<Set<T>>.Note: The
setSuppliershould not return NULL values. Otherwise a NullPointer exception is thrown.This method can be used to generate a variable-length Set containing arbitrary data.
Note: The size represents the max size of the Set, but it's not guaranteed to be so, given the nature of the Set (it doesn't accept duplicates).
Note: If you are using a TreeSet as the implementing class you need to take in consideration it doesn't accept null values.
Note: The implementing set need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
setSupplier- TheSet<T>implementation we are going to use.sizeUnit- The MockUnitInt used to generate the size of the Set. If the MockUnitInt generates a negative value an exception will be thrown.- Returns:
- A new
MockUnit<Set<T>>
-
set
default MockUnit<java.util.Set<T>> set(int size)
Transforms a
MockUnit<T>into aMockUnit<Set<T>>.This method can be used to generate a fixed-length Set containing arbitrary data.
Note: The size represents the max size of the Set, but it's not guaranteed to be so, given the nature of the Set (it doesn't accept duplicates).
Note: The internal Set implementation is HashSet.
- Parameters:
size- The max size of the Set- Returns:
- A new
MockUnit<Set<T>>
-
set
default MockUnit<java.util.Set<T>> set(MockUnitInt sizeUnit)
Transforms a
MockUnit<T>into aMockUnit<Set<T>>.This method can be used to generate a fixed-length Set containing arbitrary data.
Note: The internal Set implementation is HashSet
Note: The size represents the max size of the Set, but it's not guaranteed to be so, given the nature of the Set.
- Parameters:
sizeUnit- The MockUnitInt used to generate the size of the Set. If the MockUnitInt generates a negative value an exception will be thrown.- Returns:
- A new
MockUnit<Set<T>>
-
collection
@Deprecated default MockUnit<java.util.Collection<T>> collection(java.lang.Class<? extends java.util.Collection> collectionClass, int size)
Deprecated.usecollection(Supplier, int)instead.Transforms a
MockUnit<T>into aMockUnit<Collection<T>>.This method can be used to generate a fixed-length Collection containing arbitrary data.
Note: The implementing collection need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
collectionClass- TheCollection<T>implementation we are going to use.size- The size of the collection. (If the collection is a Set, this is guaranteed to be the max size, not the actual one).- Returns:
- A new
MockUnit<Collection<T>>
-
collection
default MockUnit<java.util.Collection<T>> collection(java.util.function.Supplier<java.util.Collection<T>> collectionSupplier, int size)
Transforms a
MockUnit<T>into aMockUnit<Collection<T>>.This method can be used to generate a fixed-length Collection containing arbitrary data.
Note: The implementing collection need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
collectionSupplier- TheSupplier<Collection<T>>we are going to use to obtain the Collection instance.size- The size of the collection. (If the collection is a Set, this is guaranteed to be the max size, not the actual one).- Returns:
- A new
MockUnit<Collection<T>>
-
collection
@Deprecated default MockUnit<java.util.Collection<T>> collection(java.lang.Class<? extends java.util.Collection> collectionClass, MockUnitInt sizeUnit)
Deprecated.usecollection(Supplier, MockUnitInt)instead.Transforms a
MockUnit<T>into aMockUnit<Collection<T>>.This method can be used to generate a variable-length Collection containing arbitrary data.
Note: The implementing collection need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
collectionClass- TheCollection<T>implementation we are going to use.sizeUnit- The MockUnitInt used to generate the size of the Collection. If the MockUnitInt generates a negative value an exception will be thrown. (If the collection is a Set, this is guaranteed to be the max size, not the actual one).- Returns:
- A new
MockUnit<Collection<T>>
-
collection
default MockUnit<java.util.Collection<T>> collection(java.util.function.Supplier<java.util.Collection<T>> collectionSupplier, MockUnitInt sizeUnit)
Transforms a
MockUnit<T>into aMockUnit<Collection<T>>.This method can be used to generate a variable-length Collection containing arbitrary data.
Note: The implementing collection need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
collectionSupplier- TheSupplier<Collection<T>>we are going to use to obtain the Collection instance.sizeUnit- The MockUnitInt used to generate the size of the Collection. If the MockUnitInt generates a negative value an exception will be thrown. (If the collection is a Set, this is guaranteed to be the max size, not the actual one).- Returns:
- A new
MockUnit<Collection<T>>
-
collection
default MockUnit<java.util.Collection<T>> collection(int size)
Transforms a
MockUnit<T>into aMockUnit<Collection<T>>.This method can be used to generate a fixed-length Collection containing arbitrary data.
Note: The implementing collection is ArrayList.class.
- Parameters:
size- The size of the Collection. (If the collection is a Set, this guaranteed to be the max size, not the actual one).- Returns:
- A new
MockUnit<Collection<T>>
-
collection
default MockUnit<java.util.Collection<T>> collection(MockUnitInt sizeUnit)
Transforms a
MockUnit<T>into aMockUnit<Collection<T>>.This method can be used to generate a fixed-length Collection containing arbitrary data.
Note: The implementing collection is ArrayList.class.
- Parameters:
sizeUnit- The size of the Collection generated through a MockUnitInt.- Returns:
- A new
MockUnit<Collection<T>>
-
mapKeys
@Deprecated default <R> MockUnit<java.util.Map<R,T>> mapKeys(java.lang.Class<? extends java.util.Map> mapClass, int size, java.util.function.Supplier<R> keysSupplier)
Deprecated.usemapKeys(Supplier, int, Supplier)instead.Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenSupplier<R>.This method can be used to generate a fixed-length Map containing arbitrary data.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type of the Keys.- Parameters:
mapClass- The implementing class for the Map (eg.: HashMap).size- The size of the Map.keysSupplier- The supplier of the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default <R> MockUnit<java.util.Map<R,T>> mapKeys(java.util.function.Supplier<java.util.Map<R,T>> mapSupplier, int size, java.util.function.Supplier<R> keySupplier)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>where the keys are generated from a givenSupplier<R>.This method can be used to generate a fixed-length Map containing arbitrary data.
- Type Parameters:
R- The type of the Keys.- Parameters:
mapSupplier- TheSupplier<Map<R, T>used to instantiate theMap<R, T>.size- The size of the Map.keySupplier- The supplier of the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
@Deprecated default <R> MockUnit<java.util.Map<R,T>> mapKeys(java.lang.Class<? extends java.util.Map> mapClass, MockUnitInt sizeUnit, java.util.function.Supplier<R> keysSupplier)
Deprecated.usemapKeys(Supplier, MockUnitInt, Supplier)instead.Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenSupplier<R>.This method can be used to generate a variable-length Map containing arbitrary data.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type of the keys.- Parameters:
mapClass- The implementing class for the Map (eg.: HashMap).sizeUnit- The MockUnitInt used to generate the size of the Map. If the MockUnitInt generates a negative value an exception will be thrown.keysSupplier- The supplier of the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default <R> MockUnit<java.util.Map<R,T>> mapKeys(java.util.function.Supplier<java.util.Map<R,T>> mapSupplier, MockUnitInt sizeUnit, java.util.function.Supplier<R> keySupplier)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenSupplier<R>.This method can be used to generate a variable-length Map containing arbitrary data.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type of the keys.- Parameters:
mapSupplier- TheSupplier<Map<R, T>>that is used to obtain a Map instance.sizeUnit- The MockUnitInt used to generate the size of the Map. If the MockUnitInt generates a negative value an exception will be thrown.keySupplier- The supplier of the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default <R> MockUnit<java.util.Map<R,T>> mapKeys(int size, java.util.function.Supplier<R> keysSupplier)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenSupplier<R>.This method can be used to generate a fixed-length Map containing arbitrary data.
Note: The implementing Map is HashMap.
- Type Parameters:
R- The type of the keys.- Parameters:
size- The size of the Map.keysSupplier- The supplier of the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default <R> MockUnit<java.util.Map<R,T>> mapKeys(MockUnitInt sizeUnit, java.util.function.Supplier<R> keysSupplier)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenSupplier<R>.This method can be used to generate a variable-length Map containing arbitrary data.
Note: The implementing Map is HashMap.
- Type Parameters:
R- The type of the keys.- Parameters:
sizeUnit- The MockUnitInt used to generate the size of the Map. If the MockUnitInt generates a negative value an exception will be thrown.keysSupplier- The supplier of the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
@Deprecated default <R> MockUnit<java.util.Map<R,T>> mapKeys(java.lang.Class<? extends java.util.Map> mapClass, java.lang.Iterable<R> keys)
Deprecated.usemapKeys(Supplier, Iterable)instead.Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenIterable<R>.The size of the Map is determined by the supplied
Iterable<R>.Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type of the keys.- Parameters:
mapClass- The implementing class for the Map (eg.: HashMap.class).keys- TheIterable<R>used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default <R> MockUnit<java.util.Map<R,T>> mapKeys(java.util.function.Supplier<java.util.Map<R,T>> mapSupplier, java.lang.Iterable<R> keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenIterable<R>.The size of the Map is determined by the supplied
Iterable<R>.- Type Parameters:
R- The type of the keys.- Parameters:
mapSupplier- A supplier method returning aMap<R, T>.keys- TheIterable<R>used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default <R> MockUnit<java.util.Map<R,T>> mapKeys(java.lang.Iterable<R> keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenIterable<R>.The size of the Map is determined by the supplied
Iterable<R>.Note: The implementing Map is HashMap.
- Type Parameters:
R- The type of the keys.- Parameters:
keys- TheIterable<R>used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
@Deprecated default <R> MockUnit<java.util.Map<R,T>> mapKeys(java.lang.Class<? extends java.util.Map> mapClass, R[] keys)
Deprecated.usemapKeys(Supplier, Object[])instead.Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenIterable<R>.The size of the Map is determined by the supplied
Iterable<R>.Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type of the keys.- Parameters:
mapClass- The implementing class of the collection (eg.: LinkedList).keys- TheIterable<R>used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default <R> MockUnit<java.util.Map<R,T>> mapKeys(java.util.function.Supplier<java.util.Map<R,T>> mapSupplier, R[] keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a givenIterable<R>.The size of the Map is determined by the supplied
Iterable<R>.- Type Parameters:
R- The type of the keys.- Parameters:
mapSupplier- The supplier method returning aMap<R,T>.keys- TheIterable<R>used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default <R> MockUnit<java.util.Map<R,T>> mapKeys(R[] keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
Note: The map type is HashMap.
- Type Parameters:
R- The type of the keys.- Parameters:
keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
@Deprecated default MockUnit<java.util.Map<java.lang.Integer,T>> mapKeys(java.lang.Class<? extends java.util.Map> mapClass, int[] keys)
Deprecated.usemapKeys(Supplier, int[])instead.Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
mapClass- The type of the Map (eg.: HashMap.class).keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default MockUnit<java.util.Map<java.lang.Integer,T>> mapKeys(java.util.function.Supplier<java.util.Map<java.lang.Integer,T>> mapSupplier, int[] keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
- Parameters:
mapSupplier- The supplier method that returns aMap<Integer, T>.keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default MockUnit<java.util.Map<java.lang.Integer,T>> mapKeys(int[] keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
Note: The implementing Map is HashMap.
- Parameters:
keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
@Deprecated default MockUnit<java.util.Map<java.lang.Long,T>> mapKeys(java.lang.Class<? extends java.util.Map> mapClass, long[] keys)
Deprecated.usemapKeys(Supplier, long[])instead.Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
mapClass- The type of the Map (eg.: HashMap.class).keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default MockUnit<java.util.Map<java.lang.Long,T>> mapKeys(java.util.function.Supplier<java.util.Map<java.lang.Long,T>> mapSupplier, long[] keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
mapSupplier- The supplier method that returns aMap<Long, T>.keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default MockUnit<java.util.Map<java.lang.Long,T>> mapKeys(long[] keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
Note: The implementing Map is HashMap.
- Parameters:
keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
@Deprecated default MockUnit<java.util.Map<java.lang.Double,T>> mapKeys(java.lang.Class<? extends java.util.Map> mapClass, double[] keys)
Deprecated.usemapKeys(Supplier, double[])instead.Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
mapClass- The type of the Map (eg.: HashMap.class).keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default MockUnit<java.util.Map<java.lang.Double,T>> mapKeys(java.util.function.Supplier<java.util.Map<java.lang.Double,T>> mapSupplier, double[] keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
- Parameters:
mapSupplier- The supplier method that returns aMap<Double, T>.keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapKeys
default MockUnit<java.util.Map<java.lang.Double,T>> mapKeys(double[] keys)
Transforms a
MockUnit<T>into aMockUnit<Map<R,T>>where the keys are generated from a given array.The size of the Map is determined by the supplied array.
Note: The implementing Map is HashMap.
- Parameters:
keys- The array used to generate the keys.- Returns:
- A new
MockUnit<Map<R, T>>
-
mapVals
@Deprecated default <R> MockUnit<java.util.Map<T,R>> mapVals(java.lang.Class<? extends java.util.Map> mapClass, int size, java.util.function.Supplier<R> valuesSupplier)
Deprecated.usemapVals(Supplier, int, Supplier)instead.Transforms a
MockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.This method can be used to generate a variable-length Map containing arbitrary data.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type of the values.- Parameters:
mapClass- The type of the Map (eg.: HashMap.class).size- The size of the map.valuesSupplier- The supplier of the values.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default <R> MockUnit<java.util.Map<T,R>> mapVals(java.util.function.Supplier<java.util.Map<T,R>> mapSupplier, int size, java.util.function.Supplier<R> valuesSupplier)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.This method can be used to generate a variable-length Map containing arbitrary data.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type of the values.- Parameters:
mapSupplier- The supplier method that returns aMap<T, R>.size- The size of the map.valuesSupplier- The supplier of the values.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
@Deprecated default <R> MockUnit<java.util.Map<T,R>> mapVals(java.lang.Class<? extends java.util.Map> mapClass, MockUnitInt sizeUnit, java.util.function.Supplier<R> valuesSupplier)
Deprecated.usemapVals(Supplier, MockUnitInt, Supplier)instead.Transforms a
MockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.This method can be used to generate a variable-length Map containing arbitrary data.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type the values.- Parameters:
mapClass- The type of the Map (eg.: HashMap.class).sizeUnit- The MockUnitInt used to generate the size of the Map. If the MockUnitInt generates a negative value an exception will be thrown.valuesSupplier- The supplier of the values.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default <R> MockUnit<java.util.Map<T,R>> mapVals(java.util.function.Supplier<java.util.Map<T,R>> mapSupplier, MockUnitInt sizeUnit, java.util.function.Supplier<R> valuesSupplier)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.This method can be used to generate a variable-length Map containing arbitrary data.
- Type Parameters:
R- The type the values.- Parameters:
mapSupplier- The supplier method that returnsMap<T, R>.sizeUnit- The MockUnitInt used to generate the size of the Map. If the MockUnitInt generates a negative value an exception will be thrown.valuesSupplier- The supplier of the values.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default <R> MockUnit<java.util.Map<T,R>> mapVals(int size, java.util.function.Supplier<R> valuesSupplier)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.This method can be used to generate a fixed-length Map containing arbitrary data.
Note: The implementing Map is HashMap.
- Type Parameters:
R- The type the values.- Parameters:
size- The size of the map.valuesSupplier- The supplier of the values.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default <R> MockUnit<java.util.Map<T,R>> mapVals(MockUnitInt sizeUnit, java.util.function.Supplier<R> valuesSupplier)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values generated from aSupplier<R>.This method can be used to generate a variable-length Map containing arbitrary data.
Note: The implementing Map is HashMap.
- Type Parameters:
R- The type the values.- Parameters:
sizeUnit- The MockUnitInt used to generate the size of the Map. If the MockUnitInt generates a negative value an exception will be thrown.valuesSupplier- The supplier of the values.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
@Deprecated default <R> MockUnit<java.util.Map<T,R>> mapVals(java.lang.Class<? extends java.util.Map> mapClass, java.lang.Iterable<R> values)
Deprecated.usemapVals(Supplier, Iterable)instead.Transforms a
MockUnit<T>into aMockUnit<T,R>where the values generated from aIterable<R>.The size of the Map is strictly determined by the size of the
Iterable<R>.Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type the values.- Parameters:
mapClass- The implementing class for the Map (eg.: HashMap.class).values- TheIterable<R>from where the values are selected in order.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default <R> MockUnit<java.util.Map<T,R>> mapVals(java.util.function.Supplier<java.util.Map<T,R>> mapSupplier, java.lang.Iterable<R> values)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values generated from aIterable<R>.The size of the Map is strictly determined by the size of the
Iterable<R>.- Type Parameters:
R- The type the values.- Parameters:
mapSupplier- The supplier returning theMap<T, R>that will hold the values.values- TheIterable<R>from where the values are selected in order.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default <R> MockUnit<java.util.Map<T,R>> mapVals(java.lang.Iterable<R> values)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values are generated from aIterable<R>.The size of the map is strictly determined by the size of the
Iterable<R>.Note: The implementing map used is HashMap.
- Type Parameters:
R- The type the values.- Parameters:
values- TheIterable<R>from where the values are selected in order.- Returns:
- A new
MockUnit<T,R>>
-
mapVals
@Deprecated default <R> MockUnit<java.util.Map<T,R>> mapVals(java.lang.Class<? extends java.util.Map> mapClass, R[] values)
Deprecated.usemapVals(Supplier, Object[])instead.Transforms a
MockUnit<T>into aMockUnit<T,R>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type the values.- Parameters:
mapClass- The implementing class for the Map (eg.: HashMap.class).values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default <R> MockUnit<java.util.Map<T,R>> mapVals(java.util.function.Supplier<java.util.Map<T,R>> mapSupplier, R[] values)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Type Parameters:
R- The type the values.- Parameters:
mapSupplier- The supplier method that returns theMap<T, R>.values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default <R> MockUnit<java.util.Map<T,R>> mapVals(R[] values)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
Note: The implementing map used is HashMap.
- Type Parameters:
R- The type the values.- Parameters:
values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
@Deprecated default MockUnit<java.util.Map<T,java.lang.Integer>> mapVals(java.lang.Class<? extends java.util.Map> mapClass, int[] values)
Deprecated.usemapVals(Supplier, int[])instead.Transforms a
MockUnit<T>into aMockUnit<T,R>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
mapClass- The implementing class for the Map (eg.: HashMap.class).values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default MockUnit<java.util.Map<T,java.lang.Integer>> mapVals(java.util.function.Supplier<java.util.Map<T,java.lang.Integer>> mapSupplier, int[] values)
Transforms a
MockUnit<T>into aMockUnit<T,Integer>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
- Parameters:
mapSupplier- The supplier method that returns aMap<T, Integer>.values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default MockUnit<java.util.Map<T,java.lang.Integer>> mapVals(int[] values)
Transforms a
MockUnit<T>into aMockUnit<T,Integer>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
Note: The implementing map used is HashMap.
- Parameters:
values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
@Deprecated default MockUnit<java.util.Map<T,java.lang.Long>> mapVals(java.lang.Class<? extends java.util.Map> mapClass, long[] values)
Deprecated.usemapVals(Supplier, long[])insteadTransforms a
MockUnit<T>into aMockUnit<T,Long>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
mapClass- The implementing class for the Map (eg.: HashMap.class).values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default MockUnit<java.util.Map<T,java.lang.Long>> mapVals(java.util.function.Supplier<java.util.Map<T,java.lang.Long>> mapSupplier, long[] values)
Transforms a
MockUnit<T>into aMockUnit<T,Long>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
- Parameters:
mapSupplier- The supplier method that returns aMap<T, Long>.values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default MockUnit<java.util.Map<T,java.lang.Long>> mapVals(long[] values)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
Note: The implementing map used is HashMap.
- Parameters:
values- The array.- Returns:
- A new
MockUnit<Map<T, R>>.
-
mapVals
@Deprecated default MockUnit<java.util.Map<T,java.lang.Double>> mapVals(java.lang.Class<? extends java.util.Map> mapClass, double[] values)
Deprecated.usemapVals(Supplier, double[])instead.Transforms a
MockUnit<T>into aMockUnit<T,Double>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
Note: The implementing Map need to have a NON-ARG constructor, otherwise it won't be instantiated.
- Parameters:
mapClass- The implementing class for the Map (eg.: HashMap.class).values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default MockUnit<java.util.Map<T,java.lang.Double>> mapVals(java.util.function.Supplier<java.util.Map<T,java.lang.Double>> mapSupplier, double[] values)
Transforms a
MockUnit<T>into aMockUnit<T,Double>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
- Parameters:
mapSupplier- The supplier method that returns aMap<T, Double>.values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
mapVals
default MockUnit<java.util.Map<T,java.lang.Double>> mapVals(double[] values)
Transforms a
MockUnit<T>into aMockUnit<T,R>where the values are generated from an array.The size of the map is strictly determined by the size of the array.
Note: The implementing map used is HashMap.
- Parameters:
values- The array.- Returns:
- A new
MockUnit<Map<T, R>>
-
array
default MockUnit<T[]> array(java.lang.Class<T> cls, int size)
Transforms a
MockUnit<T>into aMockUnit<T[]>.- Parameters:
cls- The type of the value generated by the MockUnit (eg. Student.class)size- The size of the array.- Returns:
- A new
MockUnit<T[]>.
-
-