Class JsonSubstitutions


  • public final class JsonSubstitutions
    extends java.lang.Object
    Finds string set in a Node object string value and replaces them with a corresponding Node.

    Each key represents a string to search for, and each value represents what to replace the string with. A value can be any type of Node, allowing for strings to be changed to objects, arrays, etc. Partial string matches are not currently supported.

    For example, given the following values to replace:

    {"FOO": {"bar": "baz"}}

    and the following Node value:

    {"hello": "FOO", "baz": "do not replace FOO"},

    the resulting Node will become:

    {"hello": {"bar: "baz"}, "baz": "do not replace FOO"}.

    Notice that "do not replace FOO" was not modified because the entire string did not literally match the string "FOO".

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      software.amazon.smithy.model.node.Node apply​(software.amazon.smithy.model.node.Node node)
      Replaces strings in the given node.
      static JsonSubstitutions create​(java.util.Map<java.lang.String,​software.amazon.smithy.model.node.Node> map)
      Creates a substitutions instance from a Map.
      static JsonSubstitutions create​(software.amazon.smithy.model.node.ObjectNode node)
      Creates a substitutions instance from an ObjectNode.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public static JsonSubstitutions create​(software.amazon.smithy.model.node.ObjectNode node)
        Creates a substitutions instance from an ObjectNode.
        Parameters:
        node - ObjectNode used to create the instance.
        Returns:
        Returns the created JsonSubstitutions.
      • create

        public static JsonSubstitutions create​(java.util.Map<java.lang.String,​software.amazon.smithy.model.node.Node> map)
        Creates a substitutions instance from a Map.
        Parameters:
        map - Map used to create the instance.
        Returns:
        Returns the created JsonSubstitutions.
      • apply

        public software.amazon.smithy.model.node.Node apply​(software.amazon.smithy.model.node.Node node)
        Replaces strings in the given node.
        Parameters:
        node - Node to update.
        Returns:
        Returns the updated node.