-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#93): TriggerEvaluator#afterTrigger
- Loading branch information
Showing
13 changed files
with
234 additions
and
176 deletions.
There are no files selected for viewing
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
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
45 changes: 0 additions & 45 deletions
45
core/src/main/java/io/github/zero88/schedulerx/impl/AbstractTriggerEvaluator.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
core/src/main/java/io/github/zero88/schedulerx/impl/DefaultTriggerEvaluator.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,57 @@ | ||
package io.github.zero88.schedulerx.impl; | ||
|
||
import org.jetbrains.annotations.ApiStatus.Internal; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import io.github.zero88.schedulerx.trigger.Trigger; | ||
import io.github.zero88.schedulerx.trigger.TriggerContext; | ||
import io.github.zero88.schedulerx.trigger.TriggerEvaluator; | ||
import io.vertx.core.Future; | ||
|
||
@Internal | ||
public class DefaultTriggerEvaluator implements TriggerEvaluator { | ||
|
||
static TriggerEvaluator noop() { | ||
return new DefaultTriggerEvaluator(); | ||
} | ||
|
||
private TriggerEvaluator next; | ||
|
||
@Override | ||
public final @NotNull Future<TriggerContext> beforeTrigger(@NotNull Trigger trigger, | ||
@NotNull TriggerContext triggerContext, | ||
@Nullable Object externalId) { | ||
return this.internalBeforeTrigger(trigger, triggerContext, externalId) | ||
.flatMap(c -> next == null ? Future.succeededFuture(c) : next.beforeTrigger(trigger, c, externalId)); | ||
} | ||
|
||
@Override | ||
public final @NotNull Future<TriggerContext> afterTrigger(@NotNull Trigger trigger, | ||
@NotNull TriggerContext triggerContext, | ||
@Nullable Object externalId, long round) { | ||
// @formatter:off | ||
return this.internalAfterTrigger(trigger, triggerContext, externalId, round ) | ||
.flatMap(c -> next == null ? Future.succeededFuture(c) : next.afterTrigger(trigger, c, externalId, round)); | ||
// @formatter:on | ||
} | ||
|
||
@Override | ||
public final @NotNull TriggerEvaluator andThen(@Nullable TriggerEvaluator another) { | ||
this.next = another; | ||
return this; | ||
} | ||
|
||
protected Future<TriggerContext> internalBeforeTrigger(@NotNull Trigger trigger, | ||
@NotNull TriggerContext triggerContext, | ||
@Nullable Object externalId) { | ||
return Future.succeededFuture(triggerContext); | ||
} | ||
|
||
protected Future<TriggerContext> internalAfterTrigger(@NotNull Trigger trigger, | ||
@NotNull TriggerContext triggerContext, | ||
@Nullable Object externalId, long round) { | ||
return Future.succeededFuture(triggerContext); | ||
} | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.