Java Code Examples for com.fasterxml.jackson.databind.module.SimpleSerializers#addSerializer()

The following examples show how to use com.fasterxml.jackson.databind.module.SimpleSerializers#addSerializer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoneyModule.java    From jackson-datatype-money with MIT License 6 votes vote down vote up
@Override
public void setupModule(final SetupContext context) {
    final SimpleSerializers serializers = new SimpleSerializers();
    serializers.addSerializer(CurrencyUnit.class, new CurrencyUnitSerializer());
    serializers.addSerializer(MonetaryAmount.class, new MonetaryAmountSerializer(names, writer, formatFactory));
    context.addSerializers(serializers);

    final SimpleDeserializers deserializers = new SimpleDeserializers();
    deserializers.addDeserializer(CurrencyUnit.class, new CurrencyUnitDeserializer());
    deserializers.addDeserializer(MonetaryAmount.class, new MonetaryAmountDeserializer<>(amountFactory, names));
    // for reading into concrete implementation types
    deserializers.addDeserializer(Money.class, new MonetaryAmountDeserializer<>(moneyFactory, names));
    deserializers.addDeserializer(FastMoney.class, new MonetaryAmountDeserializer<>(fastMoneyFactory, names));
    deserializers.addDeserializer(RoundedMoney.class, new MonetaryAmountDeserializer<>(roundedMoneyFactory, names));
    context.addDeserializers(deserializers);
}
 
Example 2
Source File: SortJacksonModule.java    From spring-cloud-openfeign with Apache License 2.0 5 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
	SimpleSerializers serializers = new SimpleSerializers();
	serializers.addSerializer(Sort.class, new SortJsonComponent.SortSerializer());
	context.addSerializers(serializers);

	SimpleDeserializers deserializers = new SimpleDeserializers();
	deserializers.addDeserializer(Sort.class,
			new SortJsonComponent.SortDeserializer());
	context.addDeserializers(deserializers);
}
 
Example 3
Source File: JacksonPinpointModule.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
    SimpleSerializers serializers = new SimpleSerializers();
    serializers.addSerializer(ServiceType.class, new ServiceTypeSerializer());
    
    context.addSerializers(serializers);
}
 
Example 4
Source File: Jackson2ObjectMapperBuilderTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
	SimpleSerializers serializers = new SimpleSerializers();
	serializers.addSerializer(Integer.class, new CustomIntegerSerializer());
	context.addSerializers(serializers);
}
 
Example 5
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
	SimpleSerializers serializers = new SimpleSerializers();
	serializers.addSerializer(Integer.class, new CustomIntegerSerializer());
	context.addSerializers(serializers);
}
 
Example 6
Source File: Jackson2ObjectMapperBuilderTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
	SimpleSerializers serializers = new SimpleSerializers();
	serializers.addSerializer(Integer.class, new CustomIntegerSerializer());
	context.addSerializers(serializers);
}
 
Example 7
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
	SimpleSerializers serializers = new SimpleSerializers();
	serializers.addSerializer(Integer.class, new CustomIntegerSerializer());
	context.addSerializers(serializers);
}
 
Example 8
Source File: Jackson2ObjectMapperBuilderTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
	SimpleSerializers serializers = new SimpleSerializers();
	serializers.addSerializer(Integer.class, new CustomIntegerSerializer());
	context.addSerializers(serializers);
}
 
Example 9
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
	SimpleSerializers serializers = new SimpleSerializers();
	serializers.addSerializer(Integer.class, new CustomIntegerSerializer());
	context.addSerializers(serializers);
}
 
Example 10
Source File: JobJacksonModule.java    From haven-platform with Apache License 2.0 4 votes vote down vote up
private void addSerializers(SimpleSerializers serializers) {
    if(jobParameterDescriptionSerializer != null) {
        serializers.addSerializer(JobParameterDescription.class, jobParameterDescriptionSerializer);
    }
}
 
Example 11
Source File: DmJacksonModule.java    From haven-platform with Apache License 2.0 4 votes vote down vote up
private void addSerializers(SimpleSerializers serializers) {
    serializers.addSerializer(MimeType.class, new MimeTypeSerializer());
    serializers.addSerializer(Keeper.class, new KeeperSerializer());
}
 
Example 12
Source File: ProtobufModule.java    From jackson-datatype-protobuf with Apache License 2.0 4 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
  SimpleSerializers serializers = new SimpleSerializers();
  serializers.addSerializer(new MessageSerializer(config));
  serializers.addSerializer(new DurationSerializer());
  serializers.addSerializer(new FieldMaskSerializer());
  serializers.addSerializer(new ListValueSerializer());
  serializers.addSerializer(new NullValueSerializer());
  serializers.addSerializer(new StructSerializer());
  serializers.addSerializer(new TimestampSerializer());
  serializers.addSerializer(new ValueSerializer());
  serializers.addSerializer(new WrappedPrimitiveSerializer<>(DoubleValue.class));
  serializers.addSerializer(new WrappedPrimitiveSerializer<>(FloatValue.class));
  serializers.addSerializer(new WrappedPrimitiveSerializer<>(Int64Value.class));
  serializers.addSerializer(new WrappedPrimitiveSerializer<>(UInt64Value.class));
  serializers.addSerializer(new WrappedPrimitiveSerializer<>(Int32Value.class));
  serializers.addSerializer(new WrappedPrimitiveSerializer<>(UInt32Value.class));
  serializers.addSerializer(new WrappedPrimitiveSerializer<>(BoolValue.class));
  serializers.addSerializer(new WrappedPrimitiveSerializer<>(StringValue.class));
  serializers.addSerializer(new WrappedPrimitiveSerializer<>(BytesValue.class));

  context.addSerializers(serializers);

  context.addDeserializers(new MessageDeserializerFactory(config));
  SimpleDeserializers deserializers = new SimpleDeserializers();
  deserializers.addDeserializer(Duration.class, new DurationDeserializer());
  deserializers.addDeserializer(FieldMask.class, new FieldMaskDeserializer());
  deserializers.addDeserializer(ListValue.class, new ListValueDeserializer().buildAtEnd());
  deserializers.addDeserializer(NullValue.class, new NullValueDeserializer());
  deserializers.addDeserializer(Struct.class, new StructDeserializer().buildAtEnd());
  deserializers.addDeserializer(Timestamp.class, new TimestampDeserializer());
  deserializers.addDeserializer(Value.class, new ValueDeserializer().buildAtEnd());
  deserializers.addDeserializer(DoubleValue.class, wrappedPrimitiveDeserializer(DoubleValue.class));
  deserializers.addDeserializer(FloatValue.class, wrappedPrimitiveDeserializer(FloatValue.class));
  deserializers.addDeserializer(Int64Value.class, wrappedPrimitiveDeserializer(Int64Value.class));
  deserializers.addDeserializer(UInt64Value.class, wrappedPrimitiveDeserializer(UInt64Value.class));
  deserializers.addDeserializer(Int32Value.class, wrappedPrimitiveDeserializer(Int32Value.class));
  deserializers.addDeserializer(UInt32Value.class, wrappedPrimitiveDeserializer(UInt32Value.class));
  deserializers.addDeserializer(BoolValue.class, wrappedPrimitiveDeserializer(BoolValue.class));
  deserializers.addDeserializer(StringValue.class, wrappedPrimitiveDeserializer(StringValue.class));
  deserializers.addDeserializer(BytesValue.class, wrappedPrimitiveDeserializer(BytesValue.class));
  context.addDeserializers(deserializers);
  context.setMixInAnnotations(MessageOrBuilder.class, MessageOrBuilderMixin.class);
}