Interface TransformAction

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface TransformAction
    Represents an action to be performed that transforms a node in the configuration tree.
    Since:
    4.0.0
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      static TransformAction remove()
      Create a transform action that will remove the node at a specified path.
      static TransformAction rename​(java.lang.Object newKey)
      Rename a node
      static <V> TransformAction set​(io.leangen.geantyref.TypeToken<V> type, @Nullable V value)
      Create a transform action that will change the value of a node to one of the specified type.
      static <V> TransformAction set​(io.leangen.geantyref.TypeToken<V> type, java.util.function.Supplier<@Nullable V> valueSupplier)
      Create a transform action that will change the value of a node to one of the specified type.
      static <V> TransformAction set​(java.lang.Class<V> type, java.util.function.Supplier<V> valueSupplier)
      Create a transform action that will change the value of a node to one of the specified type.
      java.lang.Object @Nullable [] visitPath​(NodePath path, ConfigurationNode value)
      Called at a certain path, with the node at that path.
    • Method Detail

      • remove

        static TransformAction remove()
        Create a transform action that will remove the node at a specified path.
        Returns:
        new action
        Since:
        4.0.0
      • rename

        static TransformAction rename​(java.lang.Object newKey)
        Rename a node

        This transformation cannot be applied to the root node.

        Parameters:
        newKey - the new key
        Returns:
        new action
        Since:
        4.0.0
      • set

        static <V> TransformAction set​(io.leangen.geantyref.TypeToken<V> type,
                                       @Nullable V value)
        Create a transform action that will change the value of a node to one of the specified type.
        Type Parameters:
        V - value type
        Parameters:
        type - value type
        value - value
        Returns:
        new transformation action
        Since:
        4.0.0
      • set

        static <V> TransformAction set​(io.leangen.geantyref.TypeToken<V> type,
                                       java.util.function.Supplier<@Nullable V> valueSupplier)
        Create a transform action that will change the value of a node to one of the specified type.
        Type Parameters:
        V - value type
        Parameters:
        type - value type
        valueSupplier - supplier returning a value on each call
        Returns:
        new transformation action
        Since:
        4.0.0
      • set

        static <V> TransformAction set​(java.lang.Class<V> type,
                                       java.util.function.Supplier<V> valueSupplier)
        Create a transform action that will change the value of a node to one of the specified type.
        Type Parameters:
        V - value type
        Parameters:
        type - value type
        valueSupplier - supplier returning a value on each call
        Returns:
        new transformation action
        Since:
        4.0.0
      • visitPath

        java.lang.Object @Nullable [] visitPath​(NodePath path,
                                                ConfigurationNode value)
                                         throws ConfigurateException
        Called at a certain path, with the node at that path.

        Caution: The state of the path is only guaranteed to be accurate during a run of the transform function. Use NodePath.copy() if the path's state needs to be stored.

        Parameters:
        path - the path of the given node
        value - the node at the input path. May be modified
        Returns:
        a modified path, or null if the path is to stay the same
        Throws:
        ConfigurateException
        Since:
        4.0.0