Sha256: ebf16ce0c3aa5fa34144169298bc300e0536ffb56d25eab3b1edaf43fa08c847

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

package org.embulk.filter.copy.util;

import org.embulk.spi.Column;
import org.embulk.spi.ColumnVisitor;
import org.embulk.spi.PageBuilder;
import org.embulk.spi.PageReader;

public class StandardColumnVisitor
    implements ColumnVisitor
{
    private final PageReader reader;
    private final PageBuilder builder;

    public StandardColumnVisitor(PageReader reader, PageBuilder builder)
    {
        this.reader = reader;
        this.builder = builder;
    }

    private void nullOr(Column column, Runnable runnable)
    {
        if (reader.isNull(column)) {
            builder.setNull(column);
            return;
        }
        runnable.run();
    }

    @Override
    public void booleanColumn(Column column)
    {
        nullOr(column, () -> builder.setBoolean(column, reader.getBoolean(column)));
    }

    @Override
    public void longColumn(Column column)
    {
        nullOr(column, () -> builder.setLong(column, reader.getLong(column)));
    }

    @Override
    public void doubleColumn(Column column)
    {
        nullOr(column, () -> builder.setDouble(column, reader.getDouble(column)));
    }

    @Override
    public void stringColumn(Column column)
    {
        nullOr(column, () -> builder.setString(column, reader.getString(column)));
    }

    @Override
    public void timestampColumn(Column column)
    {
        nullOr(column, () -> builder.setTimestamp(column, reader.getTimestamp(column)));
    }

    @Override
    public void jsonColumn(Column column)
    {
        nullOr(column, () -> builder.setJson(column, reader.getJson(column)));
    }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
embulk-filter-copy-0.0.2 src/main/java/org/embulk/filter/copy/util/StandardColumnVisitor.java