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 <teamp...@gmail.com> wrote:
> Hi, I'm kind of new to Avro, and I couldn't find an example on this by
> googling.  I have a Java enum that looks like this:
>
> public enum G_CanonicalPropertyType {
> FOO(10, "Foo", "foo is not food"),
> BAR(11, "Bar", "bar is like a snickers"),
> BAZ(12, "Baz", "baz is a widget with wings");
>
> private int index;
> private String friendlyName;
> private String description;
>  //then constructor and getters
> }
>
> Where the fields for each enum are important (there are also getters and
> setters for them)
>
> I'm trying to write an Avro avdl version of this, what's the best way?
>
> Thanks,
>
> Dan

Reply via email to