Class Seq<T>

  • All Implemented Interfaces:
    MockUnit<T>

    public final class Seq<T>
    extends java.lang.Object
    implements MockUnit<T>
    • Method Detail

      • seq

        public static Seq<?> seq​(DictType dictType)

        Returns a new Seq<String> object that can be used to generate values by iterating through all the lines associated with a DictType

        Parameters:
        dictType - The DictType to iterate over
        Returns:
        A re-usable Seq<String>. The class implements MockUnitString
      • seq

        public static <T> Seq<T> seq​(java.lang.Iterable<T> iterable)

        Returns a new Seq<T> object that can be used to generate values by iterating trough the given Iterable<T> in order.

        Type Parameters:
        T - The type of both the resulting Seq<T> and the Iterable<T>
        Parameters:
        iterable - The Iterable<T> values.
        Returns:
        A re-usable Seq<T> object. The class implements MockUnit<T>
      • seq

        public static <T> Seq<T> seq​(T[] array)

        Returns a Seq<T> object that can be used to generate values by iterating through all the elements of an array in order.

        Type Parameters:
        T - The type of the array
        Parameters:
        array - The array to iterate over
        Returns:
        A re-usable Seq<T>. The class implement MockUnit<T>
      • fromDict

        public static Seq<java.lang.String> fromDict​(DictType dictType)

        Returns a new Seq<String> object that can be used to generate values by iterating through all the lines associated with a DictType

        Parameters:
        dictType - The DictType to iterate over
        Returns:
        A re-usable Seq<String>. The class implements MockUnitString
      • fromIterable

        public static <T> Seq<T> fromIterable​(java.lang.Iterable<T> iterable)

        Returns a new Seq<T> object that can be used to generate values by iterating trough the given Iterable<T> in order.

        Type Parameters:
        T - The type of both the resulting Seq<T> and the Iterable<T>
        Parameters:
        iterable - The Iterable<T> values.
        Returns:
        A re-usable Seq<T> object. The class implements MockUnit<T>
      • fromArray

        public static <T> Seq<T> fromArray​(T[] array)

        Returns a Seq<T> object that can be used to generate values by iterating through all the elements of an array in order.

        Type Parameters:
        T - The type of the array
        Parameters:
        array - The array to iterate over
        Returns:
        A re-usable Seq<T>. The class implement MockUnit<T>
      • cycle

        public Seq<T> cycle​(boolean value)

        Enables cycling through the elements if the finite source of elements is exhausted.

        For example if an array has 3 elements, and we create the sequence from it, after calling the get() 3 times, a null will be retrieved.

        Parameters:
        value - By default it's false
        Returns:
        The same Seq<?> object.
      • after

        public Seq<T> after​(T after)

        If cycle(boolean) is not enabled, the @param after is the default value generated by the sequence.

        Parameters:
        after - The default value after Sequence it's generated.
        Returns:
        The same Seq<T> object.
      • afterDoMock

        public Seq<T> afterDoMock​(MockUnit<T> after)

        If cycle(boolean) is not enabled, this method is used to generate values after the sequence is exhausted.

        Parameters:
        after - The MockUnit<T> to be used after the sequence is exhausted.
        Returns:
        The same Seq<T> object.
      • supplier

        public java.util.function.Supplier<T> supplier()
        Description copied from interface: MockUnit
        This is the sole abstract method of the interface. Needs to be implemented every-time a MockUnit is implemented.
        Specified by:
        supplier in interface MockUnit<T>
        Returns:
        A Supplier<T>.