Package software.amazon.smithy.build
Class JsonSubstitutions
java.lang.Object
software.amazon.smithy.build.JsonSubstitutions
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
Modifier and TypeMethodDescriptionReplaces strings in the given node.static JsonSubstitutions
Creates a substitutions instance from a Map.static JsonSubstitutions
create
(ObjectNode node) Creates a substitutions instance from an ObjectNode.
-
Method Details
-
create
Creates a substitutions instance from an ObjectNode.- Parameters:
node
- ObjectNode used to create the instance.- Returns:
- Returns the created JsonSubstitutions.
-
create
Creates a substitutions instance from a Map.- Parameters:
map
- Map used to create the instance.- Returns:
- Returns the created JsonSubstitutions.
-
apply
Replaces strings in the given node.- Parameters:
node
- Node to update.- Returns:
- Returns the updated node.
-