javax.persistence.StringArrayToCommaDelimitedStringConverter Maven / Gradle / Ivy
package javax.persistence;
import org.springframework.util.StringUtils;
/**
* @see java.nio.charset.StandardCharsets#UTF_8
*/
@Converter
public class StringArrayToCommaDelimitedStringConverter implements AttributeConverter {
@Override
public String convertToDatabaseColumn(String[] attribute) {
if (attribute == null) {
return null;
}
return StringUtils.arrayToCommaDelimitedString(attribute);
}
@Override
public String[] convertToEntityAttribute(String dbData) {
if (dbData == null) {
return null;
}
return StringUtils.commaDelimitedListToStringArray(dbData);
}
}