Skip to content

Commit

Permalink
1.更新部分代码
Browse files Browse the repository at this point in the history
Former-commit-id: 584eb61
Former-commit-id: 769ac79
  • Loading branch information
afkT committed Dec 17, 2021
1 parent 0056cfb commit 60fa1ab
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion lib/DevAssist/src/main/java/dev/base/DevHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@ public DevHistory<T> setListener(final Listener<T> listener) {
return this;
}

/**
* 清空当前数据
* @return {@link DevHistory}
*/
public DevHistory<T> cleanCurrent() {
return setCurrent(null, Action.SET_NULL);
}

/**
* 重置操作
* @return {@link DevHistory}
*/
public DevHistory<T> reset() {
return reset(true);
}

/**
* 重置操作
* @param setNull 是否设置 Current 为 null
* @return {@link DevHistory}
*/
public DevHistory<T> reset(final boolean setNull) {
clearBack().clearForward();
if (setNull) cleanCurrent();
return this;
}

// ============
// = 回退栈相关 =
// ============
Expand Down Expand Up @@ -364,6 +391,8 @@ private DevHistory<T> setCurrent(
final Action operate
) {
switch (operate) {
case SET_NULL: // 设置为 null 操作
break;
case SET_CURRENT: // 正常设置当前数据操作
// 清空前进栈数据
clearForward();
Expand Down Expand Up @@ -392,14 +421,17 @@ private DevHistory<T> setCurrent(
*/
private enum Action {

// 设置为 null 操作
SET_NULL,

// 正常设置当前数据操作
SET_CURRENT,

// 回退操作
GO_BACK,

// 前进操作
GO_FORWARD
GO_FORWARD,
}

/**
Expand Down

0 comments on commit 60fa1ab

Please sign in to comment.