All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clickhouse.r2dbc.ClickHouseRowMetadata Maven / Gradle / Ivy

There is a newer version: 0.7.1-patch1
Show newest version
package com.clickhouse.r2dbc;

import io.r2dbc.spi.ColumnMetadata;
import io.r2dbc.spi.RowMetadata;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;

public class ClickHouseRowMetadata implements RowMetadata {

    LinkedHashMap columnNameMetadataMap;

    ClickHouseRowMetadata(LinkedHashMap columnNameMetadataMap) {
        this.columnNameMetadataMap = columnNameMetadataMap;
    }

    @Override
    public ColumnMetadata getColumnMetadata(int i) {
        if (i > columnNameMetadataMap.size())
            throw new IllegalArgumentException("Given index is greater than size column metadata array.");
        return columnNameMetadataMap.entrySet().stream().skip(i - 1L).findFirst().get().getValue(); // NOSONAR
    }

    @Override
    public ColumnMetadata getColumnMetadata(String columnName) {
        return columnNameMetadataMap.get(columnName);
    }

    @Override
    public List getColumnMetadatas() {
        return Collections.unmodifiableList(new ArrayList<>(columnNameMetadataMap.values()));
    }

    // deprecated method
    public Collection getColumnNames() {
        return Collections.unmodifiableCollection(new ArrayList<>(columnNameMetadataMap.keySet()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy