Search in sources :

Example 11 with AvroSchemaField

use of com.linkedin.avroutil1.model.AvroSchemaField in project avro-util by linkedin.

the class AvscFileParseContext method resolveReferences.

private void resolveReferences(AvroSchema schema) {
    AvroType type = schema.type();
    switch(type) {
        case RECORD:
            AvroRecordSchema recordSchema = (AvroRecordSchema) schema;
            List<AvroSchemaField> fields = recordSchema.getFields();
            for (AvroSchemaField field : fields) {
                SchemaOrRef fieldSchema = field.getSchemaOrRef();
                resolveReferences(fieldSchema);
            }
            break;
        case UNION:
            AvroUnionSchema unionSchema = (AvroUnionSchema) schema;
            List<SchemaOrRef> types = unionSchema.getTypes();
            for (SchemaOrRef unionType : types) {
                resolveReferences(unionType);
            }
            break;
        case ARRAY:
            AvroArraySchema arraySchema = (AvroArraySchema) schema;
            SchemaOrRef arrayValuesType = arraySchema.getValueSchemaOrRef();
            resolveReferences(arrayValuesType);
            break;
        case MAP:
            AvroMapSchema mapSchema = (AvroMapSchema) schema;
            SchemaOrRef mapValuesType = mapSchema.getValueSchemaOrRef();
            resolveReferences(mapValuesType);
            break;
        default:
            break;
    }
}
Also used : AvroArraySchema(com.linkedin.avroutil1.model.AvroArraySchema) SchemaOrRef(com.linkedin.avroutil1.model.SchemaOrRef) AvroType(com.linkedin.avroutil1.model.AvroType) AvroMapSchema(com.linkedin.avroutil1.model.AvroMapSchema) AvroUnionSchema(com.linkedin.avroutil1.model.AvroUnionSchema) AvroRecordSchema(com.linkedin.avroutil1.model.AvroRecordSchema) AvroSchemaField(com.linkedin.avroutil1.model.AvroSchemaField)

Aggregations

AvroSchemaField (com.linkedin.avroutil1.model.AvroSchemaField)11 AvroRecordSchema (com.linkedin.avroutil1.model.AvroRecordSchema)10 Test (org.testng.annotations.Test)8 AvroSchema (com.linkedin.avroutil1.model.AvroSchema)4 SchemaOrRef (com.linkedin.avroutil1.model.SchemaOrRef)4 AvroArraySchema (com.linkedin.avroutil1.model.AvroArraySchema)3 AvroEnumSchema (com.linkedin.avroutil1.model.AvroEnumSchema)3 AvroMapSchema (com.linkedin.avroutil1.model.AvroMapSchema)3 AvroUnionSchema (com.linkedin.avroutil1.model.AvroUnionSchema)3 AvroFixedSchema (com.linkedin.avroutil1.model.AvroFixedSchema)2 AvroLiteral (com.linkedin.avroutil1.model.AvroLiteral)2 AvroLogicalType (com.linkedin.avroutil1.model.AvroLogicalType)2 AvroPrimitiveSchema (com.linkedin.avroutil1.model.AvroPrimitiveSchema)2 AvroType (com.linkedin.avroutil1.model.AvroType)2 JsonPropertiesContainer (com.linkedin.avroutil1.model.JsonPropertiesContainer)2 AvroSyntaxException (com.linkedin.avroutil1.parser.exceptions.AvroSyntaxException)2 BigDecimal (java.math.BigDecimal)2 LinkedHashMap (java.util.LinkedHashMap)2 JsonValue (javax.json.JsonValue)2 AvroJavaStringRepresentation (com.linkedin.avroutil1.model.AvroJavaStringRepresentation)1