package org.sky.scientific.utils;

import lombok.Data;

import java.util.List;

@Data
public class ImportResult<T> {

	private final int rowIndex;
	private final boolean success;
	private final T data;
	private final List<String> errors;
	private final String rawData;

	private ImportResult(int rowIndex, boolean success, T data, List<String> errors, String rawData) {
		this.rowIndex = rowIndex;
		this.success = success;
		this.data = data;
		this.errors = errors;
		this.rawData = rawData;
	}

	public static <T> ImportResult<T> success(int rowIndex, T data) {
		return new ImportResult<>(rowIndex, true, data, null, null);
	}

	public static <T> ImportResult<T> error(int rowIndex, List<String> errors, String rawData) {
		return new ImportResult<>(rowIndex, false, null, errors, rawData);
	}

}
