class RecordStructureAggregator {

    public List<RecordStructure> aggregate(final List<Structure> structures,
            final Map<String, RecordStructureDocumentation> recordStructureDocumentation) {
        if (structures == null) {
            throw new IllegalArgumentException("Structures cannot be null.");
        }

        if (recordStructureDocumentation == null) {
            throw new IllegalArgumentException("Record structure documentation cannot be null.");
        }

        final List<RecordStructure> records = new ArrayList<RecordStructure>(structures.size());
        for (final Structure structure : structures) {
            final String structureName = structure.getName();
            if (recordStructureDocumentation.containsKey(structureName)) {
                final RecordStructureDocumentation documentation = recordStructureDocumentation.get(structureName);
                records.add(new RecordStructure(structureName, toRecordMembers(structure, documentation.getFields()),
                        documentation.getDescription(), documentation.getStructureType()));
            } else {
                records.add(new RecordStructure(structureName,
                        toRecordMembers(structure, Collections.<Field> emptyList())));
            }
        }

        return records;
    }

}