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

de.adorsys.multibanking.jpa.converter.BookingSearchMapConverter Maven / Gradle / Ivy

There is a newer version: 5.5.43
Show newest version
package de.adorsys.multibanking.jpa.converter;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

import javax.persistence.AttributeConverter;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
public class BookingSearchMapConverter implements AttributeConverter>
        , String> {

    private final ObjectMapper objectMapper = new ObjectMapper();

    @Override
    public String convertToDatabaseColumn(Map> customerInfo) {
        try {
            return objectMapper.writeValueAsString(customerInfo);
        } catch (final JsonProcessingException e) {
            throw new IllegalStateException(e);
        }

    }

    @Override
    public Map> convertToEntityAttribute(String tanTransportTypesJson) {
        TypeReference>> typeRef
                = new TypeReference>>() {
        };

        try {
            return objectMapper.readValue(tanTransportTypesJson, typeRef);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy