All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.transferwise.tasks.TaskDataSerializer Maven / Gradle / Ivy

The newest version!
package com.transferwise.tasks;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.transferwise.common.baseutils.ExceptionUtils;
import java.nio.charset.StandardCharsets;
import org.springframework.beans.factory.annotation.Autowired;

public class TaskDataSerializer implements ITaskDataSerializer {

  @Autowired
  private ObjectMapper objectMapper;

  @Override
  public byte[] serialize(String data) {
    return data == null ? null : data.getBytes(StandardCharsets.UTF_8);
  }

  @Override
  public byte[] serializeToJson(Object data) {
    return data == null ? null : ExceptionUtils.doUnchecked(() -> objectMapper.writeValueAsBytes(data));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy