Skip to content

Commit

Permalink
feat: add abstract chain action impl
Browse files Browse the repository at this point in the history
  • Loading branch information
wxasacoder committed Nov 11, 2024
1 parent bda5047 commit 4d462cf
Showing 1 changed file with 29 additions and 0 deletions.
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;
}
}

0 comments on commit 4d462cf

Please sign in to comment.