Sha256: 346bcf19f7a9eb295a04df215dadb78ec2ba7be65a8b38cdfcfe42bcf296acdc

Contents?: true

Size: 1.97 KB

Versions: 104

Compression:

Stored size: 1.97 KB

Contents

package org.embulk.spi;

import java.util.List;
import java.util.Objects;
import com.google.common.collect.ImmutableList;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import org.embulk.spi.type.Type;

public class SchemaConfig
{
    private final List<ColumnConfig> columns;

    @JsonCreator
    public SchemaConfig(List<ColumnConfig> columns)
    {
        this.columns = columns;
    }

    @JsonValue
    public List<ColumnConfig> getColumns()
    {
        return columns;
    }

    public int size()
    {
        return columns.size();
    }

    public int getColumnCount()
    {
        return columns.size();
    }

    public ColumnConfig getColumn(int index)
    {
        return columns.get(index);
    }

    public String getColumnName(int index)
    {
        return getColumn(index).getName();
    }

    public Type getColumnType(int index)
    {
        return getColumn(index).getType();
    }

    public boolean isEmpty()
    {
        return columns.isEmpty();
    }

    public ColumnConfig lookupColumn(String name)
    {
        for (ColumnConfig c : columns) {
            if (c.getName().equals(name)) {
                return c;
            }
        }
        throw new SchemaConfigException(String.format("Column '%s' is not found", name));
    }

    public Schema toSchema()
    {
        ImmutableList.Builder<Column> builder = ImmutableList.builder();
        for (int i=0; i < columns.size(); i++) {
            builder.add(columns.get(i).toColumn(i));
        }
        return new Schema(builder.build());
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof SchemaConfig)) {
            return false;
        }
        SchemaConfig other = (SchemaConfig) obj;
        return Objects.equals(columns, other.columns);
    }

    @Override
    public int hashCode()
    {
        return Objects.hashCode(columns);
    }
}

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
embulk-0.8.39 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.39-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.38 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.38-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.37 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.37-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.36 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.36-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.35 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.35-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.34 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.34-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.33 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.33-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.32 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.32-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.31 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.31-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.30 embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java
embulk-0.8.30-java embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java