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

The following examples show how to use org.apache.avro.generic.GenericData.StringType. 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 File: GenerateAvroJavaTask.java    From gradle-avro-plugin with 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 File: TestWriteAvroResultWithSchema.java    From nifi with 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 File: TestWriteAvroResultWithSchema.java    From nifi with 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 File: GenerateAvroJavaTask.java    From gradle-avro-plugin with Apache License 2.0 4 votes vote down vote up
public void setStringType(GenericData.StringType stringType) {
    setStringType(stringType.name());
}