Sha256: 49f33a63f60724d83cc74e61e701b6583b461077bc5f7d0e71937a610d6f5345

Contents?: true

Size: 759 Bytes

Versions: 3

Compression:

Stored size: 759 Bytes

Contents

package org.embulk.formatter.avro.converter;

import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericEnumSymbol;

import java.util.List;

public class AvroEnumConverter extends AbstractAvroValueConverter {
    private List<String> enumSymbols;

    AvroEnumConverter(Schema schema, List<String> enumSymbols) {
        super(schema);
        this.enumSymbols = enumSymbols;
    }

    @Override
    public GenericEnumSymbol stringColumn(String value) {
        if (enumSymbols.contains(value)) {
            return new GenericData.EnumSymbol(avroSchema, value);
        } else {
            throw new RuntimeException(String.format("%s is not in %s", value, enumSymbols.toString()));
        }
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
embulk-formatter-avro-0.2.1 src/main/java/org/embulk/formatter/avro/converter/AvroEnumConverter.java
embulk-formatter-avro-0.1.1 src/main/java/org/embulk/formatter/avro/converter/AvroEnumConverter.java
embulk-formatter-avro-0.1.0 src/main/java/org/embulk/formatter/avro/converter/AvroEnumConverter.java