Skip to content

POJO with nullable enum fields support in tables #684

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 6 commits into from

Conversation

mgurov
Copy link
Contributor

@mgurov mgurov commented Mar 15, 2014

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.

mgurov added 6 commits March 15, 2014 14:45
…hen they start with lower case letter. Testing this case to avoid regression when switching to localized enum convertor.
…ormat on the fly based on the type of expected/given object
… of mixed case enum member starting with lower case letter
mgurov pushed a commit to mgurov/cucumber-jvm that referenced this pull request Jun 17, 2014
@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant