How do I load a (static nested) enum value from YAML fixtures in the Play Framework?

Matthew Leon picture Matthew Leon · Dec 10, 2010 · Viewed 7k times · Source
public class Request extends Model {
    public static enum Category {
        First, Second, Third
    }
        public Category category;
}

I seem unable to properly create a Request with a Category in my YAML test fixtures / initial data. I've tried things like:

Request(areq):
    category: Request.Category.Third

And several other variations. Nothing really works. The SnakeYAML page gives me some tantalizing hints but I don't see how to properly reference my app's packages. What is the right syntax for this?

Answer

maslovalex picture maslovalex · Dec 15, 2010

Why don't you use just

...
category: Third

SnakeYAML should recognize type of category and convert Third string to Third value of Category enum during object construction.