-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add abstract chain action impl
- Loading branch information
1 parent
bda5047
commit 4d462cf
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...mponent-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/AbsChainAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.alibaba.cola.statemachine.impl; | ||
|
||
import com.alibaba.cola.statemachine.Action; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author WUXIN | ||
* @date 2024/10/14 23:56:10 | ||
*/ | ||
public abstract class AbsChainAction<S,E,C> implements Action<S,E,C> { | ||
|
||
private Action next; | ||
|
||
@Override | ||
public void execute(S from, S to, E event, C context) { | ||
doExecute(from, to, event, context); | ||
if(Objects.nonNull(next)){ | ||
next.execute(from, to, event, context); | ||
} | ||
} | ||
|
||
protected abstract void doExecute(S from, S to, E event, C context); | ||
|
||
public AbsChainAction next(Action action){ | ||
this.next = action; | ||
return this; | ||
} | ||
} |