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