|
| 1 | +package io.zenwave360.sdk.plugins; |
| 2 | + |
| 3 | +import io.zenwave360.sdk.doc.DocumentedOption; |
| 4 | +import org.apache.avro.Conversion; |
| 5 | +import org.apache.avro.LogicalTypes; |
| 6 | + |
| 7 | +import java.io.File; |
| 8 | +import java.util.ArrayList; |
| 9 | +import java.util.List; |
| 10 | + |
| 11 | +public class AvroCompilerProperties { |
| 12 | + |
| 13 | + @DocumentedOption(description = "Avro schema file or folder containing avro schemas") |
| 14 | + public File sourceDirectory; |
| 15 | + |
| 16 | + @DocumentedOption(description = "Avro schema files or folders containing avro schemas") |
| 17 | + public List<String> imports; |
| 18 | + |
| 19 | + @DocumentedOption(description = "A set of Ant-like inclusion patterns used to select files from the source tree that are to be processed. By default, the pattern **\\/*.avsc is used to include all avro schema files.") |
| 20 | + public List<String> includes = List.of("**/*.avsc"); |
| 21 | + |
| 22 | + @DocumentedOption(description = "A set of Ant-like exclusion patterns used to prevent certain files from being processed. By default, this set is empty such that no files are excluded.") |
| 23 | + public List<String> excludes; |
| 24 | + |
| 25 | + public String templateDirectory = "/org/apache/avro/compiler/specific/templates/java/classic/"; |
| 26 | + public String stringType = "CharSequence"; |
| 27 | + public String fieldVisibility = "PRIVATE"; |
| 28 | + public boolean createOptionalGetters = false; |
| 29 | + public boolean gettersReturnOptional = false; |
| 30 | + public boolean optionalGettersForNullableFieldsOnly = false; |
| 31 | + public boolean createSetters = true; |
| 32 | + public boolean createNullSafeAnnotations = false; |
| 33 | + public String nullSafeAnnotationNullable = "org.jetbrains.annotations.Nullable"; |
| 34 | + public String nullSafeAnnotationNotNull = "org.jetbrains.annotations.NotNull"; |
| 35 | + public boolean enableDecimalLogicalType = false; |
| 36 | + public String outputCharacterEncoding = "UTF-8"; |
| 37 | + public List<String> velocityToolsClassesNames = new ArrayList<>(); |
| 38 | + public String recordSpecificClass = "org.apache.avro.specific.SpecificRecordBase"; |
| 39 | + public String errorSpecificClass = "org.apache.avro.specific.SpecificExceptionBase"; |
| 40 | + |
| 41 | + @DocumentedOption(description = "Custom Logical Type Factories") |
| 42 | + public List<Class<? extends LogicalTypes.LogicalTypeFactory>> customLogicalTypeFactories; |
| 43 | + |
| 44 | + @DocumentedOption(description = "Custom Conversions") |
| 45 | + public List<Class<? extends Conversion<?>>> customConversions; |
| 46 | + |
| 47 | + public List<Object> instantiateAdditionalVelocityTools() { |
| 48 | + final List<Object> velocityTools = new ArrayList<>(velocityToolsClassesNames.size()); |
| 49 | + for (String velocityToolClassName : velocityToolsClassesNames) { |
| 50 | + try { |
| 51 | + Class<?> klass = Class.forName(velocityToolClassName); |
| 52 | + velocityTools.add(klass.getDeclaredConstructor().newInstance()); |
| 53 | + } catch (Exception e) { |
| 54 | + throw new RuntimeException(e); |
| 55 | + } |
| 56 | + } |
| 57 | + return velocityTools; |
| 58 | + } |
| 59 | +} |
0 commit comments