class ConvertRecord {

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

        for (CSVRecord record : records) {
            if (record.size() < 2) break;

            String title = record.get(0);
            String text = record.get(1);

            Obligation oblig = new Obligation();
            oblig.setTitle(title);
            oblig.setText(text);

            // Parse boolean values

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

            String distributionString = record.get(3);
            if (!"NULL".equals(distributionString)) {
                boolean distribution = parseBoolean(distributionString);
                oblig.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(oblig::setExternalIds);
            }

            if (record.size() >= 6) {
                String obligationTypeStr = record.get(5);
                if (!"NULL".equals(obligationTypeStr)) {
                    ObligationType oblType = ThriftEnumUtils.enumByString(obligationTypeStr, ObligationType.class);
                    oblig.setObligationType(oblType);
                }
            }

            if (record.size() >= 7) {
                String obligationLevel = record.get(6);
                if (!"NULL".equals(obligationLevel)) {
                    ObligationLevel oblLevel = ThriftEnumUtils.enumByString(obligationLevel, ObligationLevel.class);
                    oblig.setObligationLevel(oblLevel);
                }
            }

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

    private  ConvertRecord();

}