Interface NodeValue

All Known Implementing Classes:
NodeValue.Bot, NodeValue.Json, NodeValue.ValueList

public sealed interface NodeValue permits NodeValue.Json, NodeValue.Bot, NodeValue.ValueList
Sealed interface representing a value that can be passed between script nodes. Values are either JSON-serializable data or runtime bot references.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Runtime bot reference (not JSON-serializable).
    static final record 
    JSON-serializable value (strings, numbers, booleans, arrays, objects, null).
    static final record 
    List of NodeValues that may contain non-JSON values (e.g., Bot references).
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    asBoolean(boolean defaultValue)
    Gets this value as a boolean, or returns the default if not a boolean.
    default @Nullable BotConnection
    Gets this value as a BotConnection, or null if not a bot.
    default double
    asDouble(double defaultValue)
    Gets this value as a double, or returns the default if not a number.
    default int
    asInt(int defaultValue)
    Gets this value as an int, or returns the default if not a number.
    default @Nullable com.google.gson.JsonElement
    Gets the raw JsonElement if this is a Json value.
    default List<NodeValue>
    Gets this value as a list of NodeValues.
    default long
    asLong(long defaultValue)
    Gets this value as a long, or returns the default if not a number.
    default String
    asString(String defaultValue)
    Gets this value as a string, or returns the default if not a string.
    default List<String>
    Gets this value as a list of strings.
    static NodeValue
    fromJson(com.google.gson.JsonElement element)
    Creates a NodeValue from a JsonElement.
    default boolean
    Checks if this value is null.
    static NodeValue
    of(@Nullable Object value)
    Creates a NodeValue from any object, converting to the appropriate type.
    static NodeValue
    ofBoolean(boolean value)
    Creates a boolean NodeValue.
    static NodeValue
    Creates a bot NodeValue.
    static NodeValue
    Creates a list NodeValue.
    static NodeValue
    Creates a null NodeValue.
    static NodeValue
    Creates a number NodeValue.
    static NodeValue
    Creates a string NodeValue.
  • Method Details

    • of

      static NodeValue of(@Nullable Object value)
      Creates a NodeValue from any object, converting to the appropriate type.
    • ofNull

      static NodeValue ofNull()
      Creates a null NodeValue.
    • ofString

      static NodeValue ofString(String value)
      Creates a string NodeValue.
    • ofNumber

      static NodeValue ofNumber(Number value)
      Creates a number NodeValue.
    • ofBoolean

      static NodeValue ofBoolean(boolean value)
      Creates a boolean NodeValue.
    • ofList

      static NodeValue ofList(List<NodeValue> values)
      Creates a list NodeValue. If the list contains any non-Json values (e.g., Bot references), a ValueList is used to preserve them. Otherwise, a Json array is used.
    • ofBot

      static NodeValue ofBot(BotConnection bot)
      Creates a bot NodeValue.
    • fromJson

      static NodeValue fromJson(com.google.gson.JsonElement element)
      Creates a NodeValue from a JsonElement.
    • isNull

      default boolean isNull()
      Checks if this value is null.
    • asString

      default String asString(String defaultValue)
      Gets this value as a string, or returns the default if not a string.
    • asDouble

      default double asDouble(double defaultValue)
      Gets this value as a double, or returns the default if not a number.
    • asInt

      default int asInt(int defaultValue)
      Gets this value as an int, or returns the default if not a number.
    • asLong

      default long asLong(long defaultValue)
      Gets this value as a long, or returns the default if not a number.
    • asBoolean

      default boolean asBoolean(boolean defaultValue)
      Gets this value as a boolean, or returns the default if not a boolean.
    • asList

      default List<NodeValue> asList()
      Gets this value as a list of NodeValues.
    • asStringList

      default List<String> asStringList()
      Gets this value as a list of strings.
    • asBot

      default @Nullable BotConnection asBot()
      Gets this value as a BotConnection, or null if not a bot.
    • asJsonElement

      default @Nullable com.google.gson.JsonElement asJsonElement()
      Gets the raw JsonElement if this is a Json value.