Interface Chain<T>

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

@API(status=EXPERIMENTAL, since="1.7.0") public interface Chain<T> extends 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:
  • Nested Class Summary

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

    Modifier and Type
    Method
    Description
    default Iterator<T>
     
    int
    The maximum number of transformations that a chain can go through.
    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(Supplier<? extends T> initialSupplier)
    Create arbitrary for chains with a certain initial state.
    Return list of all applied transformations as far as iterators have been used.
    Return list of all used transformer instances.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • startWith

      static <T> ChainArbitrary<T> startWith(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

      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 Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • transformations

      List<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
    • transformers

      @API(status=EXPERIMENTAL, since="1.7.1") List<Transformer<T>> transformers()
      Return list of all used transformer instances.

      Checking transformer instances - e.g. if they are of a certain implementation type - only makes sense if the transformer's description string is NOT set explicitly.

      For a chain that has not been run this list is always empty.

      Returns:
      list of transformer instances
    • maxTransformations

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