19 using System.Collections.Generic;
21 using Newtonsoft.Json.Linq;
22 using Newtonsoft.Json;
34 public IList<Schema>
Schemas {
get;
private set; }
50 List<Schema> schemas =
new List<Schema>();
51 IDictionary<string, string> uniqueSchemas =
new Dictionary<string, string>();
53 foreach (JToken jvalue
in jarr)
55 Schema unionType =
Schema.ParseJson(jvalue, names, encspace);
56 if (
null == unionType)
59 string name = unionType.
Name;
60 if (uniqueSchemas.ContainsKey(name))
63 uniqueSchemas.Add(name, name);
64 schemas.Add(unionType);
67 return new UnionSchema(schemas, props);
74 private UnionSchema(List<Schema> schemas, PropertyMap props) : base(
Type.Union, props)
77 throw new ArgumentNullException(
"schemas");
86 public Schema this[
int index]
100 protected internal override void WriteJson(Newtonsoft.Json.JsonTextWriter writer,
SchemaNames names,
string encspace)
102 writer.WriteStartArray();
104 schema.
WriteJson(writer, names, encspace);
105 writer.WriteEndArray();
139 if (obj ==
this)
return true;
145 for (
int i = 0; i <
Count; i++)
if (!that[i].
Equals(
this[i]))
return false;
146 return areEqual(that.Props,
this.Props);
static int getHashCode(object obj)
Hash code helper function
override bool CanRead(Schema writerSchema)
Checks if this schema can read data written by the given schema.
override int GetHashCode()
Hash code function
Base class for all unnamed schemas
Base class for all schema types
IList< Schema > Schemas
List of schemas in the union
internal override void WriteJson(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
Writes union schema in JSON format
Type
Enum for schema types
virtual internal void WriteJson(JsonTextWriter writer, SchemaNames names, string encspace)
Writes schema object in JSON format
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
override bool Equals(object obj)
Compares two union schema objects
int MatchingBranch(Schema s)
Returns the index of a branch that can read the data written by the given schema s.
A class that contains a list of named schemas.
Schema(Type type, PropertyMap props)
Constructor for schema class
static bool areEqual(object o1, object o2)
Compares two objects, null is equal to null
override int GetHashCode()
Hash code function
abstract string Name
The name of this schema.
int Count
Count of schemas in the union
Type Tag
Schema type property