19 using System.Collections.Generic;
22 using Newtonsoft.Json.Linq;
23 using Newtonsoft.Json;
32 private static readonly HashSet<string> ReservedProps =
new HashSet<string>() {
"type",
"name",
"namespace",
"fields",
"items",
"size",
"symbols",
"values",
"aliases",
"order",
"doc",
"default" };
41 JObject jo = jtok as JObject;
42 foreach (JProperty prop
in jo.Properties())
44 if (ReservedProps.Contains(prop.Name))
46 if (!ContainsKey(prop.Name))
47 Add(prop.Name, prop.Value.ToString());
56 public void Set(
string key,
string value)
58 if (ReservedProps.Contains(key))
59 throw new AvroException(
"Can't set reserved property: " + key);
62 if (TryGetValue(key, out oldValue))
64 if (!oldValue.Equals(value))
throw new AvroException(
"Property cannot be overwritten: " + key);
76 foreach (KeyValuePair<string, string> kp
in this)
78 if (ReservedProps.Contains(kp.Key))
continue;
80 writer.WritePropertyName(kp.Key);
81 writer.WriteRawValue(kp.Value);
90 public override bool Equals(
object obj)
92 if (
this == obj)
return true;
97 if (this.Count != that.Count)
99 foreach (KeyValuePair<string, string> pair
in this)
101 if (!that.ContainsKey(pair.Key))
103 if (!pair.Value.Equals(that[pair.Key]))
117 int hash = this.Count;
119 foreach (KeyValuePair<string, string> pair
in this)
120 hash += (pair.Key.GetHashCode() + pair.Value.GetHashCode()) * index++;
void WriteJson(JsonTextWriter writer)
Writes the schema's custom properties in JSON format
void Set(string key, string value)
Adds a custom property to the schema
override bool Equals(object obj)
Function to compare equality of two PropertyMaps
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
override int GetHashCode()
Hashcode function
void Parse(JToken jtok)
Parses the custom properties from the given JSON object and stores them into the schema's list of cus...