class ParseService {

    public <T> List<T> convertFileToTargetObject(MultipartFile file, Class<T> target) {
        if (file == null) {
            throw new TppException("No file uploaded!", 400);
        }
        try {
            InputStreamReader streamReader = new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8);
            CsvToBean<T> csvToBean = new CsvToBeanBuilder<T>(streamReader)
                                         .withType(target)
                                         .withIgnoreLeadingWhiteSpace(true)
                                         .build();
            return csvToBean.parse();
        } catch (IOException e) {
            log.error("Can't convert file to target class: {}", target.getSimpleName(), e);
            throw new TppException("Can't convert file to target class", 400);
        }
    }

}