Java Code Examples for org.apache.avro.generic.GenericData.StringType

The following examples show how to use org.apache.avro.generic.GenericData.StringType. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: gradle-avro-plugin   Source File: GenerateAvroJavaTask.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public GenerateAvroJavaTask(ObjectFactory objects) {
    super();
    this.outputCharacterEncoding = objects.property(String.class);
    this.stringType = objects.property(String.class).convention(DEFAULT_STRING_TYPE);
    this.fieldVisibility = objects.property(String.class).convention(DEFAULT_FIELD_VISIBILITY);
    this.templateDirectory = objects.property(String.class);
    this.createOptionalGetters = objects.property(Boolean.class).convention(DEFAULT_CREATE_OPTIONAL_GETTERS);
    this.gettersReturnOptional = objects.property(Boolean.class).convention(DEFAULT_GETTERS_RETURN_OPTIONAL);
    this.optionalGettersForNullableFieldsOnly = objects.property(Boolean.class)
        .convention(DEFAULT_OPTIONAL_GETTERS_FOR_NULLABLE_FIELDS_ONLY);
    this.createSetters = objects.property(Boolean.class).convention(DEFAULT_CREATE_SETTERS);
    this.enableDecimalLogicalType = objects.property(Boolean.class).convention(DEFAULT_ENABLE_DECIMAL_LOGICAL_TYPE);
    this.stringTypeProvider = getStringType()
        .map(input -> Enums.parseCaseInsensitive(OPTION_STRING_TYPE, StringType.values(), input));
    this.fieldVisibilityProvider = getFieldVisibility()
        .map(input -> Enums.parseCaseInsensitive(OPTION_FIELD_VISIBILITY, FieldVisibility.values(), input));
    this.logicalTypeFactories = objects.mapProperty(String.class, Constants.LOGICAL_TYPE_FACTORY_TYPE.getConcreteClass())
        .convention(DEFAULT_LOGICAL_TYPE_FACTORIES);
    this.customConversions = objects.listProperty(Constants.CONVERSION_TYPE.getConcreteClass()).convention(DEFAULT_CUSTOM_CONVERSIONS);
    this.resolver = new SchemaResolver(getProject(), getLogger());
}
 
Example 2
Source Project: nifi   Source File: TestWriteAvroResultWithSchema.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected GenericRecord readRecord(final InputStream in, final Schema schema) throws IOException {
    final DataFileStream<GenericRecord> dataFileStream = new DataFileStream<>(in, new GenericDatumReader<>());
    final Schema avroSchema = dataFileStream.getSchema();
    GenericData.setStringType(avroSchema, StringType.String);
    final GenericRecord avroRecord = dataFileStream.next();

    return avroRecord;
}
 
Example 3
Source Project: nifi   Source File: TestWriteAvroResultWithSchema.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected List<GenericRecord> readRecords(final InputStream in, final Schema schema, final int recordCount) throws IOException {
    final DataFileStream<GenericRecord> dataFileStream = new DataFileStream<>(in, new GenericDatumReader<>());
    final Schema avroSchema = dataFileStream.getSchema();
    GenericData.setStringType(avroSchema, StringType.String);

    List<GenericRecord> records = new ArrayList<>();
    for (int i = 0; i < recordCount; i++) {
        records.add(dataFileStream.next());
    }

    return records;
}
 
Example 4
Source Project: gradle-avro-plugin   Source File: GenerateAvroJavaTask.java    License: Apache License 2.0 4 votes vote down vote up
public void setStringType(GenericData.StringType stringType) {
    setStringType(stringType.name());
}