Class AbstractStateZipper<T,​S extends Enum>

java.lang.Object
com.couchbase.client.core.state.AbstractStateMachine<S>
com.couchbase.client.core.state.AbstractStateZipper<T,​S>
All Implemented Interfaces:
Stateful<S>, StateZipper<T,​S>
Direct Known Subclasses:
EndpointStateZipper, ServiceStateZipper

public abstract class AbstractStateZipper<T,​S extends Enum>
extends AbstractStateMachine<S>
implements StateZipper<T,​S>
The default implementation of a StateZipper. The implementing class only needs to provide the zip function, as well as a initial state that is always used when no source stream is registered.
Since:
1.1.0
Author:
Michael Nitschinger
  • Constructor Details

    • AbstractStateZipper

      protected AbstractStateZipper​(S initialState)
  • Method Details

    • zipWith

      protected abstract S zipWith​(Collection<S> states)
      The zip function to map from N states to one that represents the state of the zipper.
      Parameters:
      states - all subscribed states.
      Returns:
      the zipped state which represents the zipper state.
    • register

      public void register​(T identifier, Stateful<S> upstream)
      Description copied from interface: StateZipper
      Register the given stream to be zipped into the state computation.
      Specified by:
      register in interface StateZipper<T,​S extends Enum>
      Parameters:
      identifier - the identifier used to uniquely identify the stream.
      upstream - the stateful compontent to be registered.
    • deregister

      public void deregister​(T identifier)
      Description copied from interface: StateZipper
      Deregisters a stream identified by the identifier from the state computation.
      Specified by:
      deregister in interface StateZipper<T,​S extends Enum>
      Parameters:
      identifier - the identifier used to uniquely identify the stream.
    • terminate

      public void terminate()
      Description copied from interface: StateZipper
      Terminate the zipper and deregister all registered streams.
      Specified by:
      terminate in interface StateZipper<T,​S extends Enum>
    • currentSubscriptions

      protected Map<T,​rx.Subscription> currentSubscriptions()
      Helper method to export the current internal subscriptions.
      Returns:
      the internally stored subscriptions.
    • currentStates

      protected Map<T,​S> currentStates()
      Helper method to export the current internal states. Should only be used for testing.
      Returns:
      the internally stored states.