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

com.opencredo.concourse.cassandra.events.JsonSerialiser Maven / Gradle / Ivy

The newest version!
package com.opencredo.concourse.cassandra.events;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.function.Function;

final class JsonSerialiser implements Function {

    public static JsonSerialiser using(ObjectMapper objectMapper) {
        return new JsonSerialiser(objectMapper);
    }

    private final ObjectMapper objectMapper;

    private JsonSerialiser(ObjectMapper objectMapper) {
        this.objectMapper = objectMapper;
    }

    @Override
    public String apply(Object o) {
        try {
            return objectMapper.writeValueAsString(o);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy