Class MessageMarshallerModule

java.lang.Object
com.fasterxml.jackson.databind.Module
com.fasterxml.jackson.databind.module.SimpleModule
org.curioswitch.common.protobuf.json.MessageMarshallerModule
All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned, Serializable

public final class MessageMarshallerModule extends com.fasterxml.jackson.databind.module.SimpleModule
A Module which can be registered to an ObjectMapper to enable it to marshal protobuf using MessageMarshaller. If any modules registered after this one handle protobuf messages, they will be used even when marshalling nested messages within MessageMarshaller. This can be used to customize the marshalling of certain types when needed.

For example:


 MessageMarshaller marshaller = MessageMarshaller.builder()
     .register(MyMessage.getDefaultInstance())
     .build();
 ObjectMapper mapper = new ObjectMapper();
 mapper.registerModule(MessageMarshallerModule.of(marshaller));
 mapper.writeValueAsString(MyMessage.newBuilder().setValue("hello!").build());
 
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.Module

    com.fasterxml.jackson.databind.Module.SetupContext
  • Field Summary

    Fields inherited from class com.fasterxml.jackson.databind.module.SimpleModule

    _abstractTypes, _deserializerModifier, _deserializers, _hasExplicitName, _keyDeserializers, _keySerializers, _mixins, _name, _namingStrategy, _serializerModifier, _serializers, _subtypes, _valueInstantiators, _version
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.fasterxml.jackson.databind.Module
    of(MessageMarshaller marshaller)
    Returns a new Module which will use the provided MessageMarshaller to marshal protobuf messages.

    Methods inherited from class com.fasterxml.jackson.databind.module.SimpleModule

    _checkNotNull, addAbstractTypeMapping, addDeserializer, addKeyDeserializer, addKeySerializer, addSerializer, addSerializer, addValueInstantiator, getModuleName, getTypeId, registerSubtypes, registerSubtypes, registerSubtypes, setAbstractTypes, setDeserializerModifier, setDeserializers, setKeyDeserializers, setKeySerializers, setMixInAnnotation, setNamingStrategy, setSerializerModifier, setSerializers, setupModule, setValueInstantiators, version

    Methods inherited from class com.fasterxml.jackson.databind.Module

    getDependencies

    Methods inherited from class java.lang.Object

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

    • of

      public static com.fasterxml.jackson.databind.Module of(MessageMarshaller marshaller)
      Returns a new Module which will use the provided MessageMarshaller to marshal protobuf messages.