Search in sources :

Example 6 with AvroArraySchema

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

the class AvscParser method parseCollectionSchema.

private AvroCollectionSchema parseCollectionSchema(JsonObjectExt objectNode, AvscFileParseContext context, AvroType avroType, CodeLocation codeLocation, JsonPropertiesContainer props) {
    switch(avroType) {
        case ARRAY:
            JsonValueExt arrayItemsNode = getRequiredNode(objectNode, "items", () -> "array declarations must have an items property");
            SchemaOrRef arrayItemSchema = parseSchemaDeclOrRef(arrayItemsNode, context, false);
            return new AvroArraySchema(codeLocation, arrayItemSchema, props);
        case MAP:
            JsonValueExt mapValuesNode = getRequiredNode(objectNode, "values", () -> "map declarations must have a values property");
            SchemaOrRef mapValueSchema = parseSchemaDeclOrRef(mapValuesNode, context, false);
            return new AvroMapSchema(codeLocation, mapValueSchema, props);
        default:
            throw new IllegalStateException("unhandled: " + avroType + " for object at " + codeLocation.getStart());
    }
}
Also used : AvroArraySchema(com.linkedin.avroutil1.model.AvroArraySchema) SchemaOrRef(com.linkedin.avroutil1.model.SchemaOrRef) AvroMapSchema(com.linkedin.avroutil1.model.AvroMapSchema) JsonValueExt(com.linkedin.avroutil1.parser.jsonpext.JsonValueExt)

Aggregations

AvroArraySchema (com.linkedin.avroutil1.model.AvroArraySchema)6 AvroMapSchema (com.linkedin.avroutil1.model.AvroMapSchema)4 AvroType (com.linkedin.avroutil1.model.AvroType)4 AvroSchema (com.linkedin.avroutil1.model.AvroSchema)3 SchemaOrRef (com.linkedin.avroutil1.model.SchemaOrRef)3 AvroArrayLiteral (com.linkedin.avroutil1.model.AvroArrayLiteral)2 AvroBooleanLiteral (com.linkedin.avroutil1.model.AvroBooleanLiteral)2 AvroBytesLiteral (com.linkedin.avroutil1.model.AvroBytesLiteral)2 AvroDoubleLiteral (com.linkedin.avroutil1.model.AvroDoubleLiteral)2 AvroEnumLiteral (com.linkedin.avroutil1.model.AvroEnumLiteral)2 AvroEnumSchema (com.linkedin.avroutil1.model.AvroEnumSchema)2 AvroFixedLiteral (com.linkedin.avroutil1.model.AvroFixedLiteral)2 AvroFloatLiteral (com.linkedin.avroutil1.model.AvroFloatLiteral)2 AvroIntegerLiteral (com.linkedin.avroutil1.model.AvroIntegerLiteral)2 AvroLiteral (com.linkedin.avroutil1.model.AvroLiteral)2 AvroLongLiteral (com.linkedin.avroutil1.model.AvroLongLiteral)2 AvroNullLiteral (com.linkedin.avroutil1.model.AvroNullLiteral)2 AvroPrimitiveSchema (com.linkedin.avroutil1.model.AvroPrimitiveSchema)2 AvroRecordSchema (com.linkedin.avroutil1.model.AvroRecordSchema)2 AvroSchemaField (com.linkedin.avroutil1.model.AvroSchemaField)2