com.github.debugthug.converters.StringNullConverter Maven / Gradle / Ivy
package com.github.debugthug.converters;
import org.apache.commons.lang.StringUtils;
import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
public class StringNullConverter extends AbstractSingleValueConverter {
@Override
@SuppressWarnings("rawtypes")
public boolean canConvert(Class cls) {
return cls.equals(String.class);
}
@Override
public Object fromString(String str) {
try {
if (StringUtils.equals(StringUtils.EMPTY, str))
str = "null";
}
catch (Exception e) {
e.printStackTrace();
}
return str;
}
}