com.transferwise.tasks.TaskDataSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tw-tasks-core Show documentation
Show all versions of tw-tasks-core Show documentation
Transferwise Tasks Executor - Fire and forget until Alert.
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));
}
}