Interface Chain<T>

  • Type Parameters:
    T - The type of state to be transformed in a chain
    All Superinterfaces:
    java.lang.Iterable<T>

    @API(status=EXPERIMENTAL,
         since="1.7.0")
    public interface Chain<T>
    extends java.lang.Iterable<T>
    A chain represents a series of states of type T in which the previous state is somehow transformed into the next state. Transformers are used to transform a state into the next state. The term chain is used in relation to mathematical concepts like Markov chains.

    State instances can be mutable or immutable.

    Chains can be generated through startWith(Supplier).

    See Also:
    Transformer
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  Chain.ChainFacade  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.util.Iterator<T> iterator()  
      int maxTransformations()
      The maximum number of transformations that a chain can go through.
      java.util.Iterator<T> start()
      The Iterator will iterate through elements representing states in order, i.e. their number is one higher than the number of transformations applied to the initial state.
      static <T> ChainArbitrary<T> startWith​(java.util.function.Supplier<? extends T> initialSupplier)
      Create arbitrary for chains with a certain initial state.
      java.util.List<java.lang.String> transformations()
      Return list of all applied transformations as far as iterators have been used.
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Method Detail

      • startWith

        static <T> ChainArbitrary<T> startWith​(java.util.function.Supplier<? extends T> initialSupplier)
        Create arbitrary for chains with a certain initial state.
        Type Parameters:
        T - The type of state to be transformed through the chain.
        Parameters:
        initialSupplier - function to create the initial state object
        Returns:
        new arbitrary instance
      • start

        java.util.Iterator<T> start()
        The Iterator will iterate through elements representing states in order, i.e. their number is one higher than the number of transformations applied to the initial state.

        Mind that the next state element can depend on both the previous state and (pseudo-)randomness. Several iterators must always produce the same "chain" of states. Each iterator will start with a new instance of the initial state.

        Returns:
        an iterator through all states
      • iterator

        default java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>
      • transformations

        java.util.List<java.lang.String> transformations()
        Return list of all applied transformations as far as iterators have been used.

        For a chain that has not been iterated through this list is empty.

        Returns:
        list of describing strings
      • maxTransformations

        int maxTransformations()
        The maximum number of transformations that a chain can go through.
        Returns:
        a number >= 1