Package com.couchbase.client.core.state
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionHelper method to export the current internal states.Helper method to export the current internal subscriptions.void
deregister
(T identifier) Deregisters a stream identified by the identifier from the state computation.void
Register the given stream to be zipped into the state computation.void
Terminate the zipper and deregister all registered streams.protected abstract S
zipWith
(Collection<S> states) The zip function to map from N states to one that represents the state of the zipper.Methods inherited from class com.couchbase.client.core.state.AbstractStateMachine
hasSubscribers, isState, state, states, transitionState
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.couchbase.client.core.state.Stateful
hasSubscribers, isState, state, states
-
Constructor Details
-
AbstractStateZipper
-
-
Method Details
-
zipWith
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
Description copied from interface:StateZipper
Register the given stream to be zipped into the state computation.- Specified by:
register
in interfaceStateZipper<T,
S extends Enum> - Parameters:
identifier
- the identifier used to uniquely identify the stream.upstream
- the stateful compontent to be registered.
-
deregister
Description copied from interface:StateZipper
Deregisters a stream identified by the identifier from the state computation.- Specified by:
deregister
in interfaceStateZipper<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 interfaceStateZipper<T,
S extends Enum>
-
currentSubscriptions
Helper method to export the current internal subscriptions.- Returns:
- the internally stored subscriptions.
-
currentStates
Helper method to export the current internal states. Should only be used for testing.- Returns:
- the internally stored states.
-