Kinetica   C#   API  Version 7.2.3.0
GenericEnum.cs
Go to the documentation of this file.
1 
18 using System;
19 using System.Collections.Generic;
20 using System.Text;
21 
22 namespace Avro.Generic
23 {
27  public class GenericEnum
28  {
29  public EnumSchema Schema { get; private set; }
30  private string value;
31  public string Value {
32  get { return value; }
33  set
34  {
35  if (! Schema.Contains(value)) throw new AvroException("Unknown value for enum: " + value + "(" + Schema + ")");
36  this.value = value;
37  }
38  }
39 
40  public GenericEnum(EnumSchema schema, string value)
41  {
42  this.Schema = schema;
43  this.Value = value;
44  }
45 
46  public override bool Equals(object obj)
47  {
48  if (obj == this) return true;
49  return (obj != null && obj is GenericEnum) ? Value.Equals((obj as GenericEnum).Value) : false;
50  }
51 
52  public override int GetHashCode()
53  {
54  return 17 * Value.GetHashCode();
55  }
56 
57  public override string ToString()
58  {
59  return "Schema: " + Schema + ", value: " + Value;
60  }
61 
62  }
63 }
The defualt class to hold values for enum schema in GenericReader and GenericWriter.
Definition: GenericEnum.cs:27
Class for enum type schemas
Definition: EnumSchema.cs:28
Base class for all schema types
Definition: Schema.cs:29
override string ToString()
Definition: GenericEnum.cs:57
GenericEnum(EnumSchema schema, string value)
Definition: GenericEnum.cs:40
override int GetHashCode()
Definition: GenericEnum.cs:52
override bool Equals(object obj)
Definition: GenericEnum.cs:46