Class HookOutcome<V>

java.lang.Object
dev.itsharshxd.zentrix.api.scenario.hook.HookOutcome<V>
Type Parameters:
V - the substituted value type of the hook

public final class HookOutcome<V> extends Object
What a scenario decided about one gameplay decision point.

Three answers are possible, and the difference matters for how a combination of scenarios resolves:

  • pass() — the scenario only observed, or modified the request in place. Zentrix keeps asking the remaining scenarios and finally falls back to its own behaviour.
  • replace(Object) — the scenario supplies the result itself. No lower-priority scenario is consulted and Zentrix's own behaviour is skipped.
  • cancel() — the behaviour must not happen at all. Again final.

Requests are mutable where a hook says so, which is what makes "observe, modify, extend" work without taking the decision away from anybody: a scenario can adjust the request and still pass.

Since:
1.6.0
  • Method Details

    • pass

      @NotNull public static <V> @NotNull HookOutcome<V> pass()
      Defer: keep consulting other scenarios, then Zentrix's own behaviour.
    • cancel

      @NotNull public static <V> @NotNull HookOutcome<V> cancel()
      Suppress the behaviour entirely; no other scenario is consulted.
    • replace

      @NotNull public static <V> @NotNull HookOutcome<V> replace(@Nullable V value)
      Take the decision over with this value; no other scenario is consulted.
    • kind

      @NotNull public @NotNull HookOutcome.Kind kind()
    • isPass

      public boolean isPass()
    • isCancelled

      public boolean isCancelled()
    • isReplacement

      public boolean isReplacement()
    • value

      @NotNull public @NotNull Optional<V> value()
      The substituted value, empty unless this outcome is a replacement carrying a value.
    • toString

      public String toString()
      Overrides:
      toString in class Object