tech.simter.data.ImportedResult Maven / Gradle / Ivy
package tech.simter.data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* The result of imported
*
* @author cjw
*/
public class ImportedResult implements Serializable {
/**
* The total of success imported.
*/
public int successCount;
/**
* The total of ignore imported.
*/
public int ignoreCount;
private List columnNames;
private List errors;
/**
* Get the total of failure imported.
*
* @return the total of failure imported
*/
public int getErrorCount() {
return this.getErrors().size();
}
/**
* Get the total of all data to be imported.
*
* @return the total of all data to be imported
*/
public int getTotalCount() {
return successCount + this.getErrorCount() + ignoreCount;
}
/**
* Get the list contains column name.
*
* @return list contains column name
*/
public List getColumnNames() {
if (null == columnNames) columnNames = new ArrayList<>();
return columnNames;
}
/**
* Set the column name with specified list.
*
* @param columnNames list to be stored
*/
public void setColumnNames(List columnNames) {
this.columnNames = columnNames;
}
/**
* Add column names.
*
* @param columnNames column name to be append
* @return this instance
*/
public ImportedResult addColumnNames(String... columnNames) {
this.getColumnNames().addAll(Arrays.asList(columnNames));
return this;
}
/**
* Get the list contains detail of failure imported.
*
* @return list contains detail of failure imported
*/
public List getErrors() {
if (null == errors) errors = new ArrayList<>();
return errors;
}
/**
* Set the errors with specified list.
*
* @param errors list to be stored
*/
public void setErrors(List errors) {
this.errors = errors;
}
/**
* Add errors.
*
* @param errors error to be append
* @return this instance
*/
public ImportedResult addErrors(Error... errors) {
this.getErrors().addAll(Arrays.asList(errors));
return this;
}
/**
* The detail of failure imported.
*
* @author cjw
*/
public static class Error implements Serializable {
/**
* The index of error row.
*/
public int index;
/**
* The failure description.
*/
public String msg;
private List