cucumber/cucumber-jvm — pull request #684 by mgurov (2014-03-15 14:27:31+00:00)
Title: POJO with nullable enum fields support in tables

The issue I encountered is that there is no way to omit specifying enum value when this enum is a part of the POJO.

The reason for that is that the xstream's EnumConverter doesn't check for null or empty string before asking for `valueOf()`. Cucumber has it's own implementation (ConverterWithEnumFormat) which does handle nulls and empty strings in the expected way, and on top of this allows user to be more flexible in specifying enum value (upper-case, lower-case, capitalised). Unfortunately, this custom enum converter is not used when converting to POJOs.

The solution I suggest via this PR is to register a new DynamicEnumConverter class which would in turn instantiate needed ConverterWithEnumFormat based on the enum class expectations. The PR also contains a fix for a small defect in the ConverterWithEnumFormat where an enum value of mixed case which starts with lowercase letter would not be supported by any of the formats.

I haven't updated the change log as see this change as pretty minor. Please let me know if this is not the case.

Potential regression: the original XStream's EnumConverter has a special support for "polymorphic enums" which is missing from the proposed implementation. Due to lack of knowledge, I could not reproduce the case by tests, so leaving a simple implementation for now.