Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add extra safety to unmarshaling to enums. #38

Merged
merged 1 commit into from
Oct 3, 2014

Conversation

broady
Copy link
Contributor

@broady broady commented Oct 3, 2014

Removes existing TravelModeAdapter, AddressTypeAdapter and AddressComponentTypeAdapter, replaces them with generic SafeEnumAdapter.

Add tests that check converting UNKNOWN to a UrlValue throws an exception.

@broady
Copy link
Contributor Author

broady commented Oct 3, 2014

Fixes #30 and #31 better.

* @param unknownValue the value to return if the value cannot be found.
*/
public SafeEnumAdapter(E unknownValue) {
if (unknownValue == null) throw new IllegalArgumentException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheeky. The style guide says no (but I say yes).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too.

@markmcd
Copy link
Contributor

markmcd commented Oct 3, 2014

LGTM

@domesticmouse
Copy link
Contributor

lgtm

Removes existing TravelModeAdapter, AddressTypeAdapter and AddressComponentTypeAdapter, replaces them with generic SafeEnumAdapter.

Add tests that check converting UNKNOWN to a UrlValue throws an exception.
broady added a commit that referenced this pull request Oct 3, 2014
Add extra safety to unmarshaling to enums.
@broady broady merged commit 0a2ee82 into googlemaps:master Oct 3, 2014
@broady broady mentioned this pull request Oct 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants