- java.lang.Object
-
- swim.streamlet.AbstractStreamlet<I,O>
-
- All Implemented Interfaces:
GenericStreamlet<I,O>,Streamlet<I,O>,StreamletScope<O>
public abstract class AbstractStreamlet<I,O> extends Object implements GenericStreamlet<I,O>
-
-
Field Summary
Fields Modifier and Type Field Description protected StreamletContextcontextprotected StreamletScope<? extends O>scopeprotected intversion
-
Constructor Summary
Constructors Constructor Description AbstractStreamlet()AbstractStreamlet(StreamletScope<? extends O> scope)
-
Method Summary
Modifier and Type Method Description voidbindInput(String key, Outlet<? extends I> input)Connects theInletof thisStreamlet, identified by the givenkey, to theinputfrom which theInletshould acquire its state.protected voiddidInvalidate()voiddidInvalidateInlet(Inlet<? extends I> inlet)voiddidInvalidateOutlet(Outlet<? super O> outlet)protected voiddidReconcile(int version)voiddidReconcileInlet(Inlet<? extends I> inlet, int version)voiddidReconcileOutlet(Outlet<? super O> outlet, int version)voiddisconnectInputs()Disconnects allInlets dominated by thisStreamletin the dataflow dependency graph.static <I,O>
voiddisconnectInputs(Streamlet<I,O> streamlet, Class<?> streamletClass)voiddisconnectOutputs()Disconnects allInletss dominated by thisStreamletin the dataflow graph.static <I,O>
voiddisconnectOutputs(Streamlet<I,O> streamlet, Class<?> streamletClass)<I2 extends I>
I2getInput(String key)<I2 extends I>
I2getInput(String key, I2 orElse)<I2 extends I>
I2getInput(Inlet<I2> inlet)<I2 extends I>
I2getInput(Inlet<I2> inlet, I2 orElse)OgetOutput(String key)OgetOutput(Outlet<? super O> outlet)protected <I2 extends I>
Inlet<I2>inlet()Inlet<I>inlet(String key)Returns theInletto thisStreamletidentified by the givenkey; returnsnullif thisStreamlethas no suchInlet.protected <I2 extends I,O2>
Inoutlet<I2,O2>inoutlet()voidinvalidate()Marks thisStreamlet—and all of its outlets—as having stale state.static <I,O>
voidinvalidateOutlets(Streamlet<I,O> streamlet, Class<?> streamletClass)protected voidonInvalidate()protected voidonInvalidateOutlets()protected voidonReconcile(int version)protected voidonReconcileInlets(int version)protected voidonReconcileOutlets(int version)protected <O2> Outlet<O2>outlet()Outlet<O>outlet(String key)Returns theOutletof thisStreamletidentified by the givenkey; returnsnullif thisStreamlethas no suchOutlet.voidreconcile(int version)Reconciles the state of thisStreamlet, if the version of thisStreamlet's state differs from the targetversion.static <I,O>
voidreconcileInlets(int version, Streamlet<I,O> streamlet, Class<?> streamletClass)static <I,O>
voidreconcileOutlets(int version, Streamlet<I,O> streamlet, Class<?> streamletClass)static <I,O>
intreflectInletCount(Class<?> streamletClass)static <I,O>
Inlet<I>reflectInletField(Streamlet<I,O> streamlet, Field field)static <I,O>
Map.Entry<String,Inlet<I>>reflectInletIndex(int index, Streamlet<I,O> streamlet, Class<?> streamletClass)static <I,O>
Inlet<I>reflectInletKey(String key, Streamlet<I,O> streamlet, Class<?> streamletClass)static <I,O>
Inoutlet<I,O>reflectInoutletField(Streamlet<I,O> streamlet, Field field)static <I,O>
intreflectOutletCount(Class<?> streamletClass)static <I,O>
Outlet<O>reflectOutletField(Streamlet<I,O> streamlet, Field field)static <I,O>
Map.Entry<String,Outlet<O>>reflectOutletIndex(int index, Streamlet<I,O> streamlet, Class<?> streamletClass)static <I,O>
Outlet<O>reflectOutletKey(String key, Streamlet<I,O> streamlet, Class<?> streamletClass)voidsetStreamletContext(StreamletContext context)Sets the environment in which thisStreamletoperates.voidsetStreamletScope(StreamletScope<? extends O> scope)Sets the lexically scoped parent of thisStreamlet.StreamletContextstreamletContext()Returns the environment in which thisStreamletoperates.StreamletScope<? extends O>streamletScope()Returns the lexically scoped parent of thisStreamlet.voidunbindInput(String key)Disconnects theInletof thisStreamlet, identified by the givenkey, from itsinputOutlet, if connected.protected voidwillInvalidate()voidwillInvalidateInlet(Inlet<? extends I> inlet)voidwillInvalidateOutlet(Outlet<? super O> outlet)protected voidwillReconcile(int version)voidwillReconcileInlet(Inlet<? extends I> inlet, int version)voidwillReconcileOutlet(Outlet<? super O> outlet, int version)
-
-
-
Field Detail
-
scope
protected StreamletScope<? extends O> scope
-
context
protected StreamletContext context
-
version
protected int version
-
-
Constructor Detail
-
AbstractStreamlet
public AbstractStreamlet(StreamletScope<? extends O> scope)
-
AbstractStreamlet
public AbstractStreamlet()
-
-
Method Detail
-
disconnectInputs
public static <I,O> void disconnectInputs(Streamlet<I,O> streamlet, Class<?> streamletClass)
-
disconnectOutputs
public static <I,O> void disconnectOutputs(Streamlet<I,O> streamlet, Class<?> streamletClass)
-
invalidateOutlets
public static <I,O> void invalidateOutlets(Streamlet<I,O> streamlet, Class<?> streamletClass)
-
reconcileInlets
public static <I,O> void reconcileInlets(int version, Streamlet<I,O> streamlet, Class<?> streamletClass)
-
reconcileOutlets
public static <I,O> void reconcileOutlets(int version, Streamlet<I,O> streamlet, Class<?> streamletClass)
-
reflectInletCount
public static <I,O> int reflectInletCount(Class<?> streamletClass)
-
reflectOutletCount
public static <I,O> int reflectOutletCount(Class<?> streamletClass)
-
reflectInletIndex
public static <I,O> Map.Entry<String,Inlet<I>> reflectInletIndex(int index, Streamlet<I,O> streamlet, Class<?> streamletClass)
-
reflectOutletIndex
public static <I,O> Map.Entry<String,Outlet<O>> reflectOutletIndex(int index, Streamlet<I,O> streamlet, Class<?> streamletClass)
-
reflectInletKey
public static <I,O> Inlet<I> reflectInletKey(String key, Streamlet<I,O> streamlet, Class<?> streamletClass)
-
reflectOutletKey
public static <I,O> Outlet<O> reflectOutletKey(String key, Streamlet<I,O> streamlet, Class<?> streamletClass)
-
reflectInletField
public static <I,O> Inlet<I> reflectInletField(Streamlet<I,O> streamlet, Field field)
-
reflectOutletField
public static <I,O> Outlet<O> reflectOutletField(Streamlet<I,O> streamlet, Field field)
-
reflectInoutletField
public static <I,O> Inoutlet<I,O> reflectInoutletField(Streamlet<I,O> streamlet, Field field)
-
streamletScope
public StreamletScope<? extends O> streamletScope()
Description copied from interface:StreamletReturns the lexically scoped parent of thisStreamlet. Returnsnullif thisStreamlethas no lexical parent.- Specified by:
streamletScopein interfaceStreamlet<I,O>- Specified by:
streamletScopein interfaceStreamletScope<I>
-
setStreamletScope
public void setStreamletScope(StreamletScope<? extends O> scope)
Description copied from interface:StreamletSets the lexically scoped parent of thisStreamlet.- Specified by:
setStreamletScopein interfaceStreamlet<I,O>
-
streamletContext
public StreamletContext streamletContext()
Description copied from interface:StreamletReturns the environment in which thisStreamletoperates.- Specified by:
streamletContextin interfaceStreamlet<I,O>- Specified by:
streamletContextin interfaceStreamletScope<I>
-
setStreamletContext
public void setStreamletContext(StreamletContext context)
Description copied from interface:StreamletSets the environment in which thisStreamletoperates.- Specified by:
setStreamletContextin interfaceStreamlet<I,O>
-
inlet
public Inlet<I> inlet(String key)
Description copied from interface:StreamletReturns theInletto thisStreamletidentified by the givenkey; returnsnullif thisStreamlethas no suchInlet.
-
bindInput
public void bindInput(String key, Outlet<? extends I> input)
Description copied from interface:StreamletConnects theInletof thisStreamlet, identified by the givenkey, to theinputfrom which theInletshould acquire its state. Delegates toInlet.bindInput(Outlet)on the identifiedInlet.
-
unbindInput
public void unbindInput(String key)
Description copied from interface:StreamletDisconnects theInletof thisStreamlet, identified by the givenkey, from itsinputOutlet, if connected. Delegates toInlet.unbindInput()on the identifiedInlet.- Specified by:
unbindInputin interfaceStreamlet<I,O>
-
outlet
public Outlet<O> outlet(String key)
Description copied from interface:StreamletReturns theOutletof thisStreamletidentified by the givenkey; returnsnullif thisStreamlethas no suchOutlet.
-
outlet
protected <O2> Outlet<O2> outlet()
-
invalidate
public void invalidate()
Description copied from interface:StreamletMarks thisStreamlet—and all of its outlets—as having stale state. Invalidating aStreamletwill recursively invalidate all streamlets that transitively depend on the state of thisStreamlet. Invalidating aStreamletdoes not cause its state to be recomputed. A subsequentStreamlet.reconcile(int)call will reconcile the state of theStreamlet.- Specified by:
invalidatein interfaceStreamlet<I,O>
-
reconcile
public void reconcile(int version)
Description copied from interface:StreamletReconciles the state of thisStreamlet, if the version of thisStreamlet's state differs from the targetversion. To reconcile its state, theStreamletfirst invokesInlet.reconcileOutput(int)on each of its inlets, to ensure that its input states are up-to-date. It then recomputes its own state, in an implementation defined manner. Finally, it invokesOutlet.reconcileInput(int)on its outlets, causing all transitively dependent streamlets to reconcile their own state.
-
getOutput
public O getOutput(Outlet<? super O> outlet)
- Specified by:
getOutputin interfaceGenericStreamlet<I,O>
-
disconnectInputs
public void disconnectInputs()
Description copied from interface:StreamletDisconnects allInlets dominated by thisStreamletin the dataflow dependency graph. Used to recursively clean up chains of combinators terminating at thisStreamlet.- Specified by:
disconnectInputsin interfaceStreamlet<I,O>
-
disconnectOutputs
public void disconnectOutputs()
Description copied from interface:StreamletDisconnects allInletss dominated by thisStreamletin the dataflow graph. Used to recursively clean up chains of combinators originating from thisStreamlet.- Specified by:
disconnectOutputsin interfaceStreamlet<I,O>
-
willInvalidateInlet
public void willInvalidateInlet(Inlet<? extends I> inlet)
- Specified by:
willInvalidateInletin interfaceGenericStreamlet<I,O>
-
didInvalidateInlet
public void didInvalidateInlet(Inlet<? extends I> inlet)
- Specified by:
didInvalidateInletin interfaceGenericStreamlet<I,O>
-
willReconcileInlet
public void willReconcileInlet(Inlet<? extends I> inlet, int version)
- Specified by:
willReconcileInletin interfaceGenericStreamlet<I,O>
-
didReconcileInlet
public void didReconcileInlet(Inlet<? extends I> inlet, int version)
- Specified by:
didReconcileInletin interfaceGenericStreamlet<I,O>
-
willInvalidateOutlet
public void willInvalidateOutlet(Outlet<? super O> outlet)
- Specified by:
willInvalidateOutletin interfaceGenericStreamlet<I,O>
-
didInvalidateOutlet
public void didInvalidateOutlet(Outlet<? super O> outlet)
- Specified by:
didInvalidateOutletin interfaceGenericStreamlet<I,O>
-
willReconcileOutlet
public void willReconcileOutlet(Outlet<? super O> outlet, int version)
- Specified by:
willReconcileOutletin interfaceGenericStreamlet<I,O>
-
didReconcileOutlet
public void didReconcileOutlet(Outlet<? super O> outlet, int version)
- Specified by:
didReconcileOutletin interfaceGenericStreamlet<I,O>
-
willInvalidate
protected void willInvalidate()
-
onInvalidate
protected void onInvalidate()
-
onInvalidateOutlets
protected void onInvalidateOutlets()
-
didInvalidate
protected void didInvalidate()
-
willReconcile
protected void willReconcile(int version)
-
onReconcileInlets
protected void onReconcileInlets(int version)
-
onReconcile
protected void onReconcile(int version)
-
onReconcileOutlets
protected void onReconcileOutlets(int version)
-
didReconcile
protected void didReconcile(int version)
-
-