com.kenshoo.pl.entity.converters.StringSetValueConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of persistence-layer Show documentation
Show all versions of persistence-layer Show documentation
A Java persistence layer based on JOOQ for high performance and business flow support.
package com.kenshoo.pl.entity.converters;
import com.google.common.collect.ImmutableSet;
import com.kenshoo.pl.entity.ValueConverter;
import java.util.Set;
public class StringSetValueConverter implements ValueConverter, String> {
public final static StringSetValueConverter INSTANCE = new StringSetValueConverter();
@Override
public String convertTo(Set value) {
return value == null ? null : String.join(",", value);
}
@Override
public Set convertFrom(String value) {
return value == null ? null : ImmutableSet.copyOf(value.split(","));
}
@Override
public Class> getValueClass() {
//noinspection unchecked
return (Class) Set.class;
}
}