org.swiftboot.util.pref.StringListConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swiftboot-utils Show documentation
Show all versions of swiftboot-utils Show documentation
Utils library for enterprise applications
The newest version!
package org.swiftboot.util.pref;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Converter for string List, you can create your own implementation.
*
* @author allen
*/
public class StringListConverter extends StringConverter> {
@Override
public List deserialize(String prefValue) {
if (StringUtils.isNotBlank(prefValue)) {
String[] split = StringUtils.split(prefValue, ",");
if (split != null && split.length > 0) {
List ret = new ArrayList<>(split.length);
Collections.addAll(ret, split);
return ret;
}
}
return null;
}
@Override
public String serialize(List valueObject) {
return StringUtils.join(valueObject, ",");
}
}