Interface ObjectMapper

All Superinterfaces:
io.micronaut.json.JsonMapper
All Known Subinterfaces:
JacksonObjectMapper, ObjectMapper.CloseableObjectMapper
All Known Implementing Classes:
AbstractBsonMapper, BsonBinaryMapper, BsonJsonMapper, JacksonJsonMapper, JsonStreamMapper, OracleJdbcJsonBinaryObjectMapper, OracleJdbcJsonTextObjectMapper, PropertiesMapper

public interface ObjectMapper extends io.micronaut.json.JsonMapper
Sub-interface of JsonMapper with customizations.
Author:
graemerocher
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A closeable object mapper.
  • Method Summary

    Modifier and Type
    Method
    Description
    default ObjectMapper
    cloneWithConfiguration(@Nullable SerdeConfiguration configuration, @Nullable SerializationConfiguration serializationConfiguration, @Nullable DeserializationConfiguration deserializationConfiguration)
    Optional feature.
    default ObjectMapper
    cloneWithConfiguration(@Nullable SerdeConfiguration configuration, @Nullable SerializationConfiguration serializationConfiguration, @Nullable DeserializationConfiguration deserializationConfiguration, SerdeIntrospections introspections)
    Optional feature.
    default io.micronaut.json.JsonMapper
    cloneWithFeatures(io.micronaut.json.JsonFeatures features)
     
    create(Map<String,Object> configuration, String... packageNames)
    Creates a new custom ObjectMapper with additional beans (serializers, deserializers etc.) loaded from the given package locations.
    Get the default ObjectMapper instance.
    Returns the SerdeRegistry used by this object mapper, if possible.
    default <T> T
    updateValue(T valueToUpdate, io.micronaut.core.type.Argument<T> type, byte[] byteArray)
    Update an existing mutable value from JSON read from the supplied byte array.
    default <T> T
    updateValue(T valueToUpdate, io.micronaut.core.type.Argument<T> type, io.micronaut.core.io.buffer.ByteBuffer<?> byteBuffer)
    Update an existing mutable value from JSON read from the supplied byte buffer.
    default <T> T
    updateValue(T valueToUpdate, io.micronaut.core.type.Argument<T> type, InputStream inputStream)
    Update an existing mutable value from JSON read from the supplied input stream.
    default <T> T
    updateValue(T valueToUpdate, io.micronaut.core.type.Argument<T> type, @Nullable Object overrides)
    Update an existing mutable value from the supplied override value.
    default <T> T
    updateValue(T valueToUpdate, @Nullable Object overrides)
    Update an existing mutable value from the supplied override value.

    Methods inherited from interface io.micronaut.json.JsonMapper

    cloneWithViewClass, createReactiveParser, createSpecific, detectFeatures, getStreamConfig, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValueFromTree, readValueFromTree, updateValueFromTree, writeValue, writeValue, writeValueAsBytes, writeValueAsBytes, writeValueAsString, writeValueAsString, writeValueAsString, writeValueToTree, writeValueToTree
  • Method Details

    • updateValue

      default <T> T updateValue(T valueToUpdate, @Nullable Object overrides) throws IOException
      Update an existing mutable value from the supplied override value.

      The override value is converted to a JSON tree and applied through JsonMapper.updateValueFromTree(Object, JsonNode). Supported update semantics are implementation-specific; immutable, creator-only, and builder-only values may be rejected.

      Type Parameters:
      T - The value type
      Parameters:
      valueToUpdate - The existing value to update
      overrides - The override value containing fields to apply
      Returns:
      The updated valueToUpdate
      Throws:
      IOException - If an I/O or decoding error occurs
      Since:
      3.1
    • updateValue

      default <T> T updateValue(T valueToUpdate, io.micronaut.core.type.Argument<T> type, @Nullable Object overrides) throws IOException
      Update an existing mutable value from the supplied override value.

      The override value is converted to a JSON tree and applied through JsonMapper.updateValueFromTree(Object, JsonNode). Supported update semantics are implementation-specific; immutable, creator-only, and builder-only values may be rejected.

      Type Parameters:
      T - The value type
      Parameters:
      valueToUpdate - The existing value to update
      type - The type of the value to update
      overrides - The override value containing fields to apply
      Returns:
      The updated valueToUpdate
      Throws:
      IOException - If an I/O or decoding error occurs
      Since:
      3.1
    • updateValue

      default <T> T updateValue(T valueToUpdate, io.micronaut.core.type.Argument<T> type, InputStream inputStream) throws IOException
      Update an existing mutable value from JSON read from the supplied input stream.
      Type Parameters:
      T - The value type
      Parameters:
      valueToUpdate - The existing value to update
      type - The type of the value to update
      inputStream - The input stream containing JSON fields to apply
      Returns:
      The updated valueToUpdate
      Throws:
      IOException - If an I/O or decoding error occurs
      Since:
      3.1
    • updateValue

      default <T> T updateValue(T valueToUpdate, io.micronaut.core.type.Argument<T> type, byte[] byteArray) throws IOException
      Update an existing mutable value from JSON read from the supplied byte array.
      Type Parameters:
      T - The value type
      Parameters:
      valueToUpdate - The existing value to update
      type - The type of the value to update
      byteArray - The byte array containing JSON fields to apply
      Returns:
      The updated valueToUpdate
      Throws:
      IOException - If an I/O or decoding error occurs
      Since:
      3.1
    • updateValue

      default <T> T updateValue(T valueToUpdate, io.micronaut.core.type.Argument<T> type, io.micronaut.core.io.buffer.ByteBuffer<?> byteBuffer) throws IOException
      Update an existing mutable value from JSON read from the supplied byte buffer.
      Type Parameters:
      T - The value type
      Parameters:
      valueToUpdate - The existing value to update
      type - The type of the value to update
      byteBuffer - The byte buffer containing JSON fields to apply
      Returns:
      The updated valueToUpdate
      Throws:
      IOException - If an I/O or decoding error occurs
      Since:
      3.1
    • cloneWithFeatures

      default io.micronaut.json.JsonMapper cloneWithFeatures(io.micronaut.json.JsonFeatures features)
      Specified by:
      cloneWithFeatures in interface io.micronaut.json.JsonMapper
    • cloneWithConfiguration

      default ObjectMapper cloneWithConfiguration(@Nullable SerdeConfiguration configuration, @Nullable SerializationConfiguration serializationConfiguration, @Nullable DeserializationConfiguration deserializationConfiguration)
      Optional feature. Create a new ObjectMapper with the given configuration values. A null parameter indicates the old configuration should be used.
      Parameters:
      configuration - The SerdeConfiguration
      serializationConfiguration - The SerializationConfiguration
      deserializationConfiguration - The DeserializationConfiguration
      Returns:
      A new JsonMapper with the updated config
      Since:
      2.7.0
    • cloneWithConfiguration

      default ObjectMapper cloneWithConfiguration(@Nullable SerdeConfiguration configuration, @Nullable SerializationConfiguration serializationConfiguration, @Nullable DeserializationConfiguration deserializationConfiguration, SerdeIntrospections introspections)
      Optional feature. Create a new ObjectMapper with the given configuration values and introspections. A null configuration parameter indicates the old configuration should be used.
      Parameters:
      configuration - The SerdeConfiguration
      serializationConfiguration - The SerializationConfiguration
      deserializationConfiguration - The DeserializationConfiguration
      introspections - The SerdeIntrospections
      Returns:
      A new JsonMapper with the updated config and introspections
      Since:
      3.1.0
    • getSerdeRegistry

      default SerdeRegistry getSerdeRegistry()
      Returns the SerdeRegistry used by this object mapper, if possible.
      Returns:
      The serde registry
    • getDefault

      static ObjectMapper getDefault()
      Get the default ObjectMapper instance.

      Note that this method returns an ObjectMapper that does not include any custom defined serializers or deserializers and in general should be avoided outside a few niche cases that require static access.

      Where possible you should use dependency injection to instead retrieve the ObjectMapper from the application context.

      Returns:
      The default object mapper
      Since:
      1.3.0
    • create

      static ObjectMapper.CloseableObjectMapper create(Map<String,Object> configuration, String... packageNames)
      Creates a new custom ObjectMapper with additional beans (serializers, deserializers etc.) loaded from the given package locations.
      Parameters:
      configuration - The configuration
      packageNames - The package names
      Returns:
      The new object mapper
      Since:
      1.5.1