org.minijax.db.StringListConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minijax-db Show documentation
Show all versions of minijax-db Show documentation
Minijax database and entity model
package org.minijax.db;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter
public class StringListConverter implements AttributeConverter, String> {
@Override
public String convertToDatabaseColumn(final List list) {
if (list == null) {
return "";
}
return String.join(",", list);
}
@Override
public List convertToEntityAttribute(final String joined) {
if (joined == null) {
return new ArrayList<>();
}
return new ArrayList<>(Arrays.asList(joined.split(",")));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy