Class MapperUtils
java.lang.Object
io.micronaut.openapi.visitor.MapperUtils
Helpers for using the
JsonMapper of the selected OpenApiMapperProvider.
Mapping failures are rethrown as UncheckedIOException.- Since:
- 8.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TconvertValue(io.micronaut.json.JsonMapper mapper, @Nullable Object value, io.micronaut.core.type.Argument<T> type) static <T> TconvertValue(io.micronaut.json.JsonMapper mapper, @Nullable Object value, Class<T> type) static booleanstatic io.micronaut.json.tree.JsonNodestatic <T> TreadValue(io.micronaut.json.JsonMapper mapper, String content, io.micronaut.core.type.Argument<T> type) static <T> Tstatic <T> Tstatic @Nullable StringstringValue(@Nullable io.micronaut.json.tree.JsonNode node) static <T> TtreeToValue(io.micronaut.json.JsonMapper mapper, io.micronaut.json.tree.JsonNode tree, io.micronaut.core.type.Argument<T> type) static <T> TtreeToValue(io.micronaut.json.JsonMapper mapper, io.micronaut.json.tree.JsonNode tree, Class<T> type) static <T> TupdateValue(io.micronaut.json.JsonMapper mapper, T valueToUpdate, io.micronaut.json.tree.JsonNode tree) Updates a value from a tree, seeOpenApiMapperProvider.updateValue(JsonMapper, T, JsonNode).static io.micronaut.json.tree.JsonNodevalueToTree(io.micronaut.json.JsonMapper mapper, @Nullable Object value) static io.micronaut.json.tree.JsonNodestatic io.micronaut.json.tree.JsonNodestatic voidwriteValue(io.micronaut.json.JsonMapper mapper, Writer writer, @Nullable Object value) static StringwriteValueAsString(io.micronaut.json.JsonMapper mapper, @Nullable Object value)
-
Method Details
-
readValue
-
readValue
@Nullable public static <T> T readValue(io.micronaut.json.JsonMapper mapper, String content, io.micronaut.core.type.Argument<T> type) -
readValue
-
readTree
public static io.micronaut.json.tree.JsonNode readTree(io.micronaut.json.JsonMapper mapper, String content) -
valueToTree
public static io.micronaut.json.tree.JsonNode valueToTree(io.micronaut.json.JsonMapper mapper, @Nullable @Nullable Object value) -
treeToValue
@Nullable public static <T> T treeToValue(io.micronaut.json.JsonMapper mapper, io.micronaut.json.tree.JsonNode tree, Class<T> type) -
treeToValue
@Nullable public static <T> T treeToValue(io.micronaut.json.JsonMapper mapper, io.micronaut.json.tree.JsonNode tree, io.micronaut.core.type.Argument<T> type) -
convertValue
-
convertValue
@Nullable public static <T> T convertValue(io.micronaut.json.JsonMapper mapper, @Nullable @Nullable Object value, io.micronaut.core.type.Argument<T> type) -
writeValueAsString
-
writeValue
-
updateValue
public static <T> T updateValue(io.micronaut.json.JsonMapper mapper, T valueToUpdate, io.micronaut.json.tree.JsonNode tree) Updates a value from a tree, seeOpenApiMapperProvider.updateValue(JsonMapper, T, JsonNode).- Type Parameters:
T- The value type- Parameters:
mapper- The mappervalueToUpdate- The value to updatetree- The tree- Returns:
- The updated value, possibly a new instance
-
stringValue
@Nullable public static @Nullable String stringValue(@Nullable @Nullable io.micronaut.json.tree.JsonNode node) - Parameters:
node- A node, possiblynull- Returns:
- The string value of a string node, the text of any other scalar node, otherwise
null
-
has
- Parameters:
node- An object nodename- The property name- Returns:
- Whether the object has the property
-
without
public static io.micronaut.json.tree.JsonNode without(io.micronaut.json.tree.JsonNode node, String... names) - Parameters:
node- An object nodenames- The properties to remove- Returns:
- A copy of the object without the given properties
-
with
public static io.micronaut.json.tree.JsonNode with(io.micronaut.json.tree.JsonNode node, String name, io.micronaut.json.tree.JsonNode value) - Parameters:
node- An object nodename- The property namevalue- The new value- Returns:
- A copy of the object with the property set to the value
-