Package cn.sliew.milky.common.chain
Interface Pipeline<K,V>
-
- All Known Implementing Classes:
DefaultPipeline
public interface Pipeline<K,V>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Pipeline<K,V>addAfter(String baseName, String name, Command<K,V> command)Inserts aCommandafter an existing command of this pipeline.Pipeline<K,V>addBefore(String baseName, String name, Command<K,V> command)Inserts aCommandbefore an existing command of this pipeline.Pipeline<K,V>addFirst(String name, Command<K,V> command)Inserts aPipelineProcessat the first position of this pipeline.Pipeline<K,V>addLast(String name, Command<K,V> command)Appends aPipelineProcessat the last position of this pipeline.PipelineProcess<K,V>context(Command<K,V> command)Returns the context object of the specifiedCommandin this pipeline.PipelineProcess<K,V>context(Class<? extends Command> commandType)Returns the context object of theCommandof the specified type in this pipeline.PipelineProcess<K,V>context(String name)Returns the context object of theCommandwith the specified name in this pipeline.PipelinefireEvent(Context<K,V> context, CompletableFuture<?> future)PipelinefireExceptionCaught(Context<K,V> context, Throwable cause, CompletableFuture<?> future)Command<K,V>first()Returns the firstCommandin this pipeline.PipelineProcess<K,V>firstContext()Returns the context of the firstCommandin this pipeline.<T extends Command<K,V>>
Tget(Class<T> commandType)Returns theCommandof the specified type in this pipeline.Command<K,V>get(String name)Returns theCommandwith the specified name in this pipeline.Command<K,V>last()Returns the lastCommandin this pipeline.PipelineProcess<K,V>lastContext()Returns the context of the lastCommandin this pipeline.List<String>names()Returns theListof the command names.Pipeline<K,V>remove(Command<K,V> command)Removes the specifiedCommandfrom this pipeline.Command<K,V>remove(Class commandType)Removes theCommandof the specified type from this pipeline.Command<K,V>remove(String name)Removes theCommandwith the specified name from this pipeline.Command<K,V>removeFirst()Removes the firstCommandin this pipeline.Command<K,V>removeLast()Removes the lastCommandin this pipeline.Map<String,Command<K,V>>toMap()Converts this pipeline into an orderedMapwhose keys are command names and whose values are commands.
-
-
-
Method Detail
-
addFirst
Pipeline<K,V> addFirst(String name, Command<K,V> command)
Inserts aPipelineProcessat the first position of this pipeline.- Parameters:
name- the name of the command to insert firstcommand- the command to insert first- Throws:
IllegalArgumentException- if there's an entry with the same name already in the pipelineNullPointerException- if the specified command isnull
-
addLast
Pipeline<K,V> addLast(String name, Command<K,V> command)
Appends aPipelineProcessat the last position of this pipeline.- Parameters:
name- the name of the command to appendcommand- the command to append- Throws:
IllegalArgumentException- if there's an entry with the same name already in the pipelineNullPointerException- if the specified command isnull
-
addBefore
Pipeline<K,V> addBefore(String baseName, String name, Command<K,V> command)
Inserts aCommandbefore an existing command of this pipeline.- Parameters:
baseName- the name of the existing commandname- the name of the command to insert beforecommand- the command to insert before- Throws:
NoSuchElementException- if there's no such entry with the specifiedbaseNameIllegalArgumentException- if there's an entry with the same name already in the pipelineNullPointerException- if the specified baseName or command isnull
-
addAfter
Pipeline<K,V> addAfter(String baseName, String name, Command<K,V> command)
Inserts aCommandafter an existing command of this pipeline.- Parameters:
baseName- the name of the existing commandname- the name of the command to insert aftercommand- the command to insert after- Throws:
NoSuchElementException- if there's no such entry with the specifiedbaseNameIllegalArgumentException- if there's an entry with the same name already in the pipelineNullPointerException- if the specified baseName or command isnull
-
remove
Pipeline<K,V> remove(Command<K,V> command)
Removes the specifiedCommandfrom this pipeline.- Parameters:
command- thePipelineProcessto remove- Throws:
NoSuchElementException- if there's no such command in this pipelineNullPointerException- if the specified command isnull
-
remove
Command<K,V> remove(String name)
Removes theCommandwith the specified name from this pipeline.- Parameters:
name- the name under which theCommandwas stored.- Returns:
- the removed command
- Throws:
NoSuchElementException- if there's no such command with the specified name in this pipelineNullPointerException- if the specified name isnull
-
remove
Command<K,V> remove(Class commandType)
Removes theCommandof the specified type from this pipeline.- Parameters:
commandType- the type of the command- Returns:
- the removed command
- Throws:
NoSuchElementException- if there's no such command of the specified type in this pipelineNullPointerException- if the specified command type isnull
-
removeFirst
Command<K,V> removeFirst()
Removes the firstCommandin this pipeline.- Returns:
- the removed command
- Throws:
NoSuchElementException- if this pipeline is empty
-
removeLast
Command<K,V> removeLast()
Removes the lastCommandin this pipeline.- Returns:
- the removed command
- Throws:
NoSuchElementException- if this pipeline is empty
-
first
Command<K,V> first()
Returns the firstCommandin this pipeline.- Returns:
- the first command.
nullif this pipeline is empty.
-
last
Command<K,V> last()
Returns the lastCommandin this pipeline.- Returns:
- the last command.
nullif this pipeline is empty.
-
get
Command<K,V> get(String name)
Returns theCommandwith the specified name in this pipeline.- Returns:
- the command with the specified name.
nullif there's no such command in this pipeline.
-
get
<T extends Command<K,V>> T get(Class<T> commandType)
Returns theCommandof the specified type in this pipeline.- Returns:
- the command of the specified command type.
nullif there's no such command in this pipeline.
-
firstContext
PipelineProcess<K,V> firstContext()
Returns the context of the firstCommandin this pipeline.- Returns:
- the context of the first command.
nullif this pipeline is empty.
-
lastContext
PipelineProcess<K,V> lastContext()
Returns the context of the lastCommandin this pipeline.- Returns:
- the context of the last command.
nullif this pipeline is empty.
-
context
PipelineProcess<K,V> context(Command<K,V> command)
Returns the context object of the specifiedCommandin this pipeline.- Returns:
- the context object of the specified command.
nullif there's no such command in this pipeline.
-
context
PipelineProcess<K,V> context(String name)
Returns the context object of theCommandwith the specified name in this pipeline.- Returns:
- the context object of the command with the specified name.
nullif there's no such command in this pipeline.
-
context
PipelineProcess<K,V> context(Class<? extends Command> commandType)
Returns the context object of theCommandof the specified type in this pipeline.- Returns:
- the context object of the command of the specified type.
nullif there's no such command in this pipeline.
-
toMap
Map<String,Command<K,V>> toMap()
Converts this pipeline into an orderedMapwhose keys are command names and whose values are commands.
-
fireEvent
Pipeline fireEvent(Context<K,V> context, CompletableFuture<?> future)
-
-