Interface ValueReference<T,​N extends ConfigurationNode>

  • Type Parameters:
    T - the type of value to return
    N - the type of node
    All Superinterfaces:
    Publisher<T>

    public interface ValueReference<T,​N extends ConfigurationNode>
    extends Publisher<T>
    A pointer to a node within a configuration tree.

    This value will update automatically with changes to the underlying configuration file. Subscribers will be provided the current value upon subscription, followed by any changes.

    Since:
    4.0.0
    • Nested Class Summary

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      @Nullable T get()
      Get the current value at this node.
      N node()
      Get the node this value reference points to.
      boolean set​(@Nullable T value)
      Set the new value of this node.
      boolean setAndSave​(@Nullable T value)
      Set the new value of this node and save the underlying configuration.
      Publisher<java.lang.Boolean> setAndSaveAsync​(@Nullable T value)
      Set the new value of this node and save the underlying configuration asynchronously on the executor of the owning ConfigurationReference.
      boolean update​(java.util.function.Function<@Nullable T,​? extends T> action)
      Update this value and the underlying node, without saving.
      Publisher<java.lang.Boolean> updateAsync​(java.util.function.Function<@Nullable T,​? extends T> action)
      Update, performing the action and save on the executor of the owning ConfigurationReference.
    • Method Detail

      • get

        @Nullable T get()
        Get the current value at this node.

        Any deserialization failures will be submitted to the owning ConfigurationReference's error callback

        Returns:
        the deserialized value, or null if deserialization fails.
        Since:
        4.0.0
      • set

        boolean set​(@Nullable T value)
        Set the new value of this node. The configuration won't be saved.

        Any serialization errors will be provided to the error callback of the owning ConfigurationReference

        Parameters:
        value - the value
        Returns:
        true if successful, false if serialization fails
        Since:
        4.0.0
      • setAndSave

        boolean setAndSave​(@Nullable T value)
        Set the new value of this node and save the underlying configuration.

        Any serialization errors will be provided to the error callback of the owning ConfigurationReference

        Parameters:
        value - the value
        Returns:
        true if successful, false if serialization fails
        Since:
        4.0.0
      • setAndSaveAsync

        Publisher<java.lang.Boolean> setAndSaveAsync​(@Nullable T value)
        Set the new value of this node and save the underlying configuration asynchronously on the executor of the owning ConfigurationReference.

        Any serialization errors will be submitted to subscribers of the returned Publisher

        Parameters:
        value - the value
        Returns:
        true if successful, false if serialization fails
        Since:
        4.0.0
      • update

        boolean update​(java.util.function.Function<@Nullable T,​? extends T> action)
        Update this value and the underlying node, without saving.

        Any serialization errors will be provided to the error callback of the owning ConfigurationReference

        Parameters:
        action - to transform this node's value
        Returns:
        whether this update was successful
        Since:
        4.0.0
      • updateAsync

        Publisher<java.lang.Boolean> updateAsync​(java.util.function.Function<@Nullable T,​? extends T> action)
        Update, performing the action and save on the executor of the owning ConfigurationReference. Any errors that occur while saving will be passed along to any subscribers.

        The updated value will only be exposed if the changes are successful.

        Parameters:
        action - to transform this node's value
        Returns:
        whether this update was successful
        Since:
        4.0.0
      • node

        N node()
        Get the node this value reference points to.
        Returns:
        the node
        Since:
        4.0.0