Interface Restate.State

Enclosing class:
Restate

public static interface Restate.State
Interface to interact with this Virtual Object/Workflow state.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clear(StateKey<?> key)
    Clears the state stored under key.
    void
    Clears all the state of this virtual object instance key-value state storage
    <T> Optional<T>
    get(StateKey<T> key)
    Gets the state stored under key, deserializing the raw value using the Serde in the StateKey.
    Gets all the known state keys for this virtual object instance.
    <T> void
    set(StateKey<T> key, @NonNull T value)
    Sets the given value under the given key, serializing the value using the Serde in the StateKey.
  • Method Details

    • get

      <T> Optional<T> get(StateKey<T> key)
      Gets the state stored under key, deserializing the raw value using the Serde in the StateKey.
      Parameters:
      key - identifying the state to get and its type.
      Returns:
      an Optional containing the stored state deserialized or an empty Optional if not set yet.
      Throws:
      RuntimeException - when the state cannot be deserialized.
    • set

      <T> void set(StateKey<T> key, @NonNull T value)
      Sets the given value under the given key, serializing the value using the Serde in the StateKey.
      Parameters:
      key - identifying the value to store and its type.
      value - to store under the given key. MUST NOT be null.
      Throws:
      IllegalStateException - if called from a Shared handler
    • clear

      void clear(StateKey<?> key)
      Clears the state stored under key.
      Parameters:
      key - identifying the state to clear.
      Throws:
      IllegalStateException - if called from a Shared handler
    • getAllKeys

      Collection<String> getAllKeys()
      Gets all the known state keys for this virtual object instance.
      Returns:
      the immutable collection of known state keys.
    • clearAll

      void clearAll()
      Clears all the state of this virtual object instance key-value state storage
      Throws:
      IllegalStateException - if called from a Shared handler