class ConvertRecord {

    public static List<Todo> convertTodos(List<CSVRecord> records) {
        List<Todo> list = new ArrayList<>(records.size());

        for (CSVRecord record : records) {
            if (record.size() < 2) break;
            String id = record.get(0);
            String text = record.get(1);

            Todo todo = new Todo().setTodoId(Integer.parseInt(id)).setText(text);

            // Parse boolean values

            String developmentString = record.get(2);
            if (!"NULL".equals(developmentString)) {
                boolean development = parseBoolean(developmentString);
                todo.setDevelopment(development);
            }

            String distributionString = record.get(3);
            if (!"NULL".equals(distributionString)) {
                boolean distribution = parseBoolean(distributionString);
                todo.setDistribution(distribution);
            }

            if(record.size() >= 5) {
                Optional.ofNullable(record.get(4))
                        .filter(json -> ! "NULL".equals(json))
                        .map(json -> (Map<String, String>) gson.fromJson(json, new TypeToken<Map<String, String>>() { }.getType()))
                        .ifPresent(todo::setExternalIds);
            }

            list.add(todo);
        }
        return list;
    }

    private  ConvertRecord();

}