Class Result

java.lang.Object
io.prismmc.prism.dashboard.Result

public final class Result extends Object
What an action answers: a message for the dashboard to show, whether the page is drawn again, the page to go to, and data for a view's script. Each method gives a new result.
return Result.ok("Saved");
return Result.error("No such item");
return Result.ok().navigate("item", Map.of("id", item.id()));
return Result.ok().data(Map.of("balance", balance)).refresh(false);
  • Method Details

    • ok

      public static Result ok()
      Returns:
      a success that says nothing; the page is drawn again
    • ok

      public static Result ok(String message)
      Parameters:
      message - what the dashboard shows, briefly
      Returns:
      a success; the page is drawn again
    • error

      public static Result error(String message)
      Parameters:
      message - what went wrong, shown longer than a success
      Returns:
      a failure; the page stays as it is
    • refresh

      public Result refresh(boolean refresh)
      Parameters:
      refresh - whether the page is drawn again after the action
      Returns:
      a new result
    • data

      public Result data(@Nullable Object data)
      Parameters:
      data - what a view's script gets from prism.call: anything Gson writes as JSON
      Returns:
      a new result
    • isOk

      public boolean isOk()
      Returns:
      whether the action did what was asked
    • message

      public @Nullable String message()
      Returns:
      what the dashboard shows, or null
    • refreshes

      public boolean refreshes()
      Returns:
      whether the page is drawn again
    • params

      public Map<String,String> params()
      Returns:
      the parameters of the page to open next
    • data

      public @Nullable Object data()
      Returns:
      the data for a view's script, or null