Java Code Examples for org.apache.avro.LogicalTypes#LogicalTypeFactory

The following examples show how to use org.apache.avro.LogicalTypes#LogicalTypeFactory . 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
/**
 * Registers the logical types to be used in this run.
 * This must be called before the Schemas are parsed, or they will not be applied correctly.
 * Since {@link LogicalTypes} is a static registry, this may result in side-effects.
 */
private void registerLogicalTypes() {
    Map<String, Class<? extends LogicalTypes.LogicalTypeFactory>> logicalTypeFactoryMap = logicalTypeFactories.get();
    Set<Map.Entry<String, Class<? extends LogicalTypes.LogicalTypeFactory>>> logicalTypeFactoryEntries =
        logicalTypeFactoryMap.entrySet();
    for (Map.Entry<String, Class<? extends LogicalTypes.LogicalTypeFactory>> entry : logicalTypeFactoryEntries) {
        String logicalTypeName = entry.getKey();
        Class<? extends LogicalTypes.LogicalTypeFactory> logicalTypeFactoryClass = entry.getValue();
        try {
            LogicalTypes.LogicalTypeFactory logicalTypeFactory = logicalTypeFactoryClass.getDeclaredConstructor().newInstance();
            LogicalTypes.register(logicalTypeName, logicalTypeFactory);
        } catch (ReflectiveOperationException ex) {
            getLogger().error("Could not instantiate logicalTypeFactory class \"" + logicalTypeFactoryClass.getName() + "\"");
        }
    }
}
 
Example 2
Source File: GenerateAvroJavaTask.java    From gradle-avro-plugin with Apache License 2.0 4 votes vote down vote up
@Optional
@Input
public MapProperty<String, Class<? extends LogicalTypes.LogicalTypeFactory>> getLogicalTypeFactories() {
    return logicalTypeFactories;
}
 
Example 3
Source File: GenerateAvroJavaTask.java    From gradle-avro-plugin with Apache License 2.0 4 votes vote down vote up
public void setLogicalTypeFactories(Provider<? extends Map<? extends String,
    ? extends Class<? extends LogicalTypes.LogicalTypeFactory>>> provider) {
    this.logicalTypeFactories.set(provider);
}
 
Example 4
Source File: GenerateAvroJavaTask.java    From gradle-avro-plugin with Apache License 2.0 4 votes vote down vote up
public void setLogicalTypeFactories(Map<? extends String,
    ? extends Class<? extends LogicalTypes.LogicalTypeFactory>> logicalTypeFactories) {
    this.logicalTypeFactories.set(logicalTypeFactories);
}
 
Example 5
Source File: DefaultAvroExtension.java    From gradle-avro-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public MapProperty<String, Class<? extends LogicalTypes.LogicalTypeFactory>> getLogicalTypeFactories() {
    return logicalTypeFactories;
}
 
Example 6
Source File: DefaultAvroExtension.java    From gradle-avro-plugin with Apache License 2.0 4 votes vote down vote up
public void setLogicalTypeFactories(Provider<? extends Map<? extends String,
    ? extends Class<? extends LogicalTypes.LogicalTypeFactory>>> provider) {
    this.logicalTypeFactories.set(provider);
}
 
Example 7
Source File: DefaultAvroExtension.java    From gradle-avro-plugin with Apache License 2.0 4 votes vote down vote up
public void setLogicalTypeFactories(Map<? extends String,
    ? extends Class<? extends LogicalTypes.LogicalTypeFactory>> logicalTypeFactories) {
    this.logicalTypeFactories.set(logicalTypeFactories);
}
 
Example 8
Source File: DefaultAvroExtension.java    From gradle-avro-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public AvroExtension logicalTypeFactory(String typeName, Class<? extends LogicalTypes.LogicalTypeFactory> typeFactoryClass) {
    logicalTypeFactories.put(typeName, typeFactoryClass);
    return this;
}
 
Example 9
Source File: AvroExtension.java    From gradle-avro-plugin with Apache License 2.0 votes vote down vote up
MapProperty<String, Class<? extends LogicalTypes.LogicalTypeFactory>> getLogicalTypeFactories(); 
Example 10
Source File: AvroExtension.java    From gradle-avro-plugin with Apache License 2.0 votes vote down vote up
AvroExtension logicalTypeFactory(String typeName, Class<? extends LogicalTypes.LogicalTypeFactory> typeFactoryClass);