Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> Avro 1.7.6 Enums with fields


Copy link to this message
-
Re: Avro 1.7.6 Enums with fields
You can add attributes to the schema, e.g.:

{"type":"enum", "name":"MyEnum",
 "symbols":["FOO", "BAR", "BAZ"],
 "indexes":[10,11,12],
 "descriptions"["foo is...", "bar is..", "baz is"]
}

Then, if you generate specific code, you can access this with something like:

int fooIndex = MyEnum.getClassSchema().getJsonProp("indexes").get(FOO.ordinal()).getIntValue();

Doug

On Wed, Mar 5, 2014 at 8:45 PM, Daniel Jue <[EMAIL PROTECTED]> wrote: