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

com.feingto.cloud.domain.converters.ParameterPersistenceConverters Maven / Gradle / Ivy

There is a newer version: 2.3.8.RELEASE
Show newest version
package com.feingto.cloud.domain.converters;

import com.feingto.cloud.core.json.JSON;
import com.feingto.cloud.dto.gateway.ParameterDTO;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import javax.persistence.AttributeConverter;
import java.util.ArrayList;
import java.util.List;

/**
 * List 持久层转换
 *
 * @author longfei
 */
public class ParameterPersistenceConverters implements AttributeConverter, String> {
    @Override
    public String convertToDatabaseColumn(List attribute) {
        return !CollectionUtils.isEmpty(attribute) ? JSON.build().obj2json(attribute) : null;
    }

    @Override
    public List convertToEntityAttribute(String dbData) {
        return StringUtils.hasLength(dbData) ? JSON.build().json2list(dbData, ParameterDTO.class) : new ArrayList<>();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy