
com.qiniu.convert.ObjectToString Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qsuits Show documentation
Show all versions of qsuits Show documentation
qiniu-suits is a efficient tools for qiniu api implemented by java8.
package com.qiniu.convert;
import com.qiniu.interfaces.IStringFormat;
import com.qiniu.interfaces.ITypeConvert;
import com.qiniu.util.JsonConvertUtils;
import java.io.IOException;
import java.util.*;
public abstract class ObjectToString implements ITypeConvert {
protected IStringFormat stringFormatter;
protected List errorList = new ArrayList<>();
public String convertToV(E line) throws IOException {
return stringFormatter.toFormatString(line);
}
public List convertToVList(List lineList) {
List stringList = new ArrayList<>();
if (lineList != null && lineList.size() > 0) {
for (E line : lineList) {
try {
stringList.add(stringFormatter.toFormatString(line));
} catch (Exception e) {
errorList.add(JsonConvertUtils.toJson(line) + "\t" + e.getMessage());
}
}
}
return stringList;
}
public int errorSize() {
return errorList.size();
}
public List consumeErrors() {
try {
return new ArrayList<>(errorList);
} finally {
errorList.clear();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy