@Override
    public <K, V> Map<K, V> toMap(DataTable dataTable, Type keyType, Type valueType) {
        requireNonNull(dataTable, "dataTable may not be null");
        requireNonNull(keyType, "keyType may not be null");
        requireNonNull(valueType, "valueType may not be null");

        if (dataTable.isEmpty()) {
            return emptyMap();
        }
        DataTable keyColumn = dataTable.columns(0, 1);
        DataTable valueColumns = dataTable.columns(1);

        String firstHeaderCell = keyColumn.cell(0, 0);
        boolean firstHeaderCellIsBlank = firstHeaderCell == null || firstHeaderCell.isEmpty();
        List<K> keys = convertEntryKeys(keyType, keyColumn, valueType, firstHeaderCellIsBlank);

        if (valueColumns.isEmpty()) {
            return createMap(keyType, keys, valueType, nCopies(keys.size(), null));
        }

        boolean keysImplyTableRowTransformer = keys.size() == dataTable.height() - 1;
        List<V> values = convertEntryValues(valueColumns, keyType, valueType, keysImplyTableRowTransformer);

        if (keys.size() != values.size()) {
            throw keyValueMismatchException(firstHeaderCellIsBlank, keys.size(), keyType, values.size(), valueType);
        }

        return createMap(keyType, keys, valueType, values);
    }
@Test
    void to_map_of_object_to_unknown_type__throws_exception__register_table_entry_transformer() {
        DataTable table = parse("",
            "| code | lat       | lon         |",
            "| KMSY | 29.993333 | -90.258056  |",
            "| KSFO | 37.618889 | -122.375    |",
            "| KSEA | 47.448889 | -122.309444 |",
            "| KJFK | 40.639722 | -73.778889  |");

        registry.defineDataTableType(new DataTableType(AirPortCode.class, AIR_PORT_CODE_TABLE_ENTRY_TRANSFORMER));

        CucumberDataTableException exception = assertThrows(
            CucumberDataTableException.class,
            () -> converter.toMap(table, AirPortCode.class, Coordinate.class));
        assertThat(exception.getMessage(), startsWith(format("" +
                "Can't convert DataTable to Map<%s, %s>.\n" +
                "The first cell was either blank or you have registered a TableEntryTransformer for the key type.",
            typeName(AirPortCode.class), typeName(Coordinate.class))));
    }