- 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 StreamletContext
context
protected StreamletScope<? extends O>
scope
protected int
version
-
Constructor Summary
Constructors Constructor Description AbstractStreamlet()
AbstractStreamlet(StreamletScope<? extends O> scope)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindInput(String key, Outlet<? extends I> input)
Connects theInlet
of thisStreamlet
, identified by the givenkey
, to theinput
from which theInlet
should acquire its state.protected void
didInvalidate()
void
didInvalidateInlet(Inlet<? extends I> inlet)
void
didInvalidateOutlet(Outlet<? super O> outlet)
protected void
didReconcile(int version)
void
didReconcileInlet(Inlet<? extends I> inlet, int version)
void
didReconcileOutlet(Outlet<? super O> outlet, int version)
void
disconnectInputs()
Disconnects allInlet
s dominated by thisStreamlet
in the dataflow dependency graph.static <I,O>
voiddisconnectInputs(Streamlet<I,O> streamlet, Class<?> streamletClass)
void
disconnectOutputs()
Disconnects allInlets
s dominated by thisStreamlet
in 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)
O
getOutput(String key)
O
getOutput(Outlet<? super O> outlet)
protected <I2 extends I>
Inlet<I2>inlet()
Inlet<I>
inlet(String key)
Returns theInlet
to thisStreamlet
identified by the givenkey
; returnsnull
if thisStreamlet
has no suchInlet
.protected <I2 extends I,O2>
Inoutlet<I2,O2>inoutlet()
void
invalidate()
Marks thisStreamlet
—and all of its outlets—as having stale state.static <I,O>
voidinvalidateOutlets(Streamlet<I,O> streamlet, Class<?> streamletClass)
protected void
onInvalidate()
protected void
onInvalidateOutlets()
protected void
onReconcile(int version)
protected void
onReconcileInlets(int version)
protected void
onReconcileOutlets(int version)
protected <O2> Outlet<O2>
outlet()
Outlet<O>
outlet(String key)
Returns theOutlet
of thisStreamlet
identified by the givenkey
; returnsnull
if thisStreamlet
has no suchOutlet
.void
reconcile(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)
void
setStreamletContext(StreamletContext context)
Sets the environment in which thisStreamlet
operates.void
setStreamletScope(StreamletScope<? extends O> scope)
Sets the lexically scoped parent of thisStreamlet
.StreamletContext
streamletContext()
Returns the environment in which thisStreamlet
operates.StreamletScope<? extends O>
streamletScope()
Returns the lexically scoped parent of thisStreamlet
.void
unbindInput(String key)
Disconnects theInlet
of thisStreamlet
, identified by the givenkey
, from itsinput
Outlet
, if connected.protected void
willInvalidate()
void
willInvalidateInlet(Inlet<? extends I> inlet)
void
willInvalidateOutlet(Outlet<? super O> outlet)
protected void
willReconcile(int version)
void
willReconcileInlet(Inlet<? extends I> inlet, int version)
void
willReconcileOutlet(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
-
streamletScope
public StreamletScope<? extends O> streamletScope()
Description copied from interface:Streamlet
Returns the lexically scoped parent of thisStreamlet
. Returnsnull
if thisStreamlet
has no lexical parent.- Specified by:
streamletScope
in interfaceStreamlet<I,O>
- Specified by:
streamletScope
in interfaceStreamletScope<I>
-
setStreamletScope
public void setStreamletScope(StreamletScope<? extends O> scope)
Description copied from interface:Streamlet
Sets the lexically scoped parent of thisStreamlet
.- Specified by:
setStreamletScope
in interfaceStreamlet<I,O>
-
streamletContext
public StreamletContext streamletContext()
Description copied from interface:Streamlet
Returns the environment in which thisStreamlet
operates.- Specified by:
streamletContext
in interfaceStreamlet<I,O>
- Specified by:
streamletContext
in interfaceStreamletScope<I>
-
setStreamletContext
public void setStreamletContext(StreamletContext context)
Description copied from interface:Streamlet
Sets the environment in which thisStreamlet
operates.- Specified by:
setStreamletContext
in interfaceStreamlet<I,O>
-
inlet
public Inlet<I> inlet(String key)
Description copied from interface:Streamlet
Returns theInlet
to thisStreamlet
identified by the givenkey
; returnsnull
if thisStreamlet
has no suchInlet
.
-
bindInput
public void bindInput(String key, Outlet<? extends I> input)
Description copied from interface:Streamlet
Connects theInlet
of thisStreamlet
, identified by the givenkey
, to theinput
from which theInlet
should acquire its state. Delegates toInlet.bindInput(Outlet)
on the identifiedInlet
.
-
unbindInput
public void unbindInput(String key)
Description copied from interface:Streamlet
Disconnects theInlet
of thisStreamlet
, identified by the givenkey
, from itsinput
Outlet
, if connected. Delegates toInlet.unbindInput()
on the identifiedInlet
.- Specified by:
unbindInput
in interfaceStreamlet<I,O>
-
outlet
public Outlet<O> outlet(String key)
Description copied from interface:Streamlet
Returns theOutlet
of thisStreamlet
identified by the givenkey
; returnsnull
if thisStreamlet
has no suchOutlet
.
-
outlet
protected <O2> Outlet<O2> outlet()
-
invalidate
public void invalidate()
Description copied from interface:Streamlet
Marks thisStreamlet
—and all of its outlets—as having stale state. Invalidating aStreamlet
will recursively invalidate all streamlets that transitively depend on the state of thisStreamlet
. Invalidating aStreamlet
does not cause its state to be recomputed. A subsequentStreamlet.reconcile(int)
call will reconcile the state of theStreamlet
.- Specified by:
invalidate
in interfaceStreamlet<I,O>
-
reconcile
public void reconcile(int version)
Description copied from interface:Streamlet
Reconciles the state of thisStreamlet
, if the version of thisStreamlet
's state differs from the targetversion
. To reconcile its state, theStreamlet
first 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:
getOutput
in interfaceGenericStreamlet<I,O>
-
disconnectInputs
public void disconnectInputs()
Description copied from interface:Streamlet
Disconnects allInlet
s dominated by thisStreamlet
in the dataflow dependency graph. Used to recursively clean up chains of combinators terminating at thisStreamlet
.- Specified by:
disconnectInputs
in interfaceStreamlet<I,O>
-
disconnectInputs
public static <I,O> void disconnectInputs(Streamlet<I,O> streamlet, Class<?> streamletClass)
-
disconnectOutputs
public void disconnectOutputs()
Description copied from interface:Streamlet
Disconnects allInlets
s dominated by thisStreamlet
in the dataflow graph. Used to recursively clean up chains of combinators originating from thisStreamlet
.- Specified by:
disconnectOutputs
in interfaceStreamlet<I,O>
-
disconnectOutputs
public static <I,O> void disconnectOutputs(Streamlet<I,O> streamlet, Class<?> streamletClass)
-
willInvalidateInlet
public void willInvalidateInlet(Inlet<? extends I> inlet)
- Specified by:
willInvalidateInlet
in interfaceGenericStreamlet<I,O>
-
didInvalidateInlet
public void didInvalidateInlet(Inlet<? extends I> inlet)
- Specified by:
didInvalidateInlet
in interfaceGenericStreamlet<I,O>
-
willReconcileInlet
public void willReconcileInlet(Inlet<? extends I> inlet, int version)
- Specified by:
willReconcileInlet
in interfaceGenericStreamlet<I,O>
-
didReconcileInlet
public void didReconcileInlet(Inlet<? extends I> inlet, int version)
- Specified by:
didReconcileInlet
in interfaceGenericStreamlet<I,O>
-
willInvalidateOutlet
public void willInvalidateOutlet(Outlet<? super O> outlet)
- Specified by:
willInvalidateOutlet
in interfaceGenericStreamlet<I,O>
-
didInvalidateOutlet
public void didInvalidateOutlet(Outlet<? super O> outlet)
- Specified by:
didInvalidateOutlet
in interfaceGenericStreamlet<I,O>
-
willReconcileOutlet
public void willReconcileOutlet(Outlet<? super O> outlet, int version)
- Specified by:
willReconcileOutlet
in interfaceGenericStreamlet<I,O>
-
didReconcileOutlet
public void didReconcileOutlet(Outlet<? super O> outlet, int version)
- Specified by:
didReconcileOutlet
in interfaceGenericStreamlet<I,O>
-
willInvalidate
protected void willInvalidate()
-
onInvalidate
protected void onInvalidate()
-
onInvalidateOutlets
protected void onInvalidateOutlets()
-
invalidateOutlets
public static <I,O> void invalidateOutlets(Streamlet<I,O> streamlet, Class<?> streamletClass)
-
didInvalidate
protected void didInvalidate()
-
willReconcile
protected void willReconcile(int version)
-
onReconcileInlets
protected void onReconcileInlets(int version)
-
reconcileInlets
public static <I,O> void reconcileInlets(int version, Streamlet<I,O> streamlet, Class<?> streamletClass)
-
onReconcile
protected void onReconcile(int version)
-
onReconcileOutlets
protected void onReconcileOutlets(int version)
-
reconcileOutlets
public static <I,O> void reconcileOutlets(int version, Streamlet<I,O> streamlet, Class<?> streamletClass)
-
didReconcile
protected void didReconcile(int version)
-
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)
-
-