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.5.RELEASE
Show newest version
package com.feingto.cloud.domain.converters;

import com.feingto.cloud.dto.apis.ParameterDTO;
import com.feingto.cloud.kit.json.JSON;
import org.apache.commons.collections.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.isNotEmpty(attribute) ? JSON.obj2json(attribute) : null;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy