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 ParameterType.fromEnum(Class enumClass) #423

Merged
merged 2 commits into from
Jul 27, 2018

Conversation

aslakhellesoy
Copy link
Contributor

Summary

Simplify creation of ParameterType from an enum class

Details

The enum constants' names are used to build a regexp for the match (red|green|blue), and the name is the simplified name of the enum class (Color).

Motivation and Context

See cucumber/cucumber-jvm#1393 (comment)

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@Test
public void converts_to_enum() {
ParameterTypeRegistry registry = new ParameterTypeRegistry(Locale.ENGLISH);
registry.defineParameterType(ParameterType.fromEnum(Mood.class));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a parameter type fromEnum or forEnum?

When using a static import I think registry.defineParameterType(forEnum(Mood.class)); reads a bit better.

Copy link
Contributor

Choose a reason for hiding this comment

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

OTOH: fromEnum is kinda the well known standard.

@mpkorstanje mpkorstanje merged commit bea3046 into master Jul 27, 2018
@mpkorstanje mpkorstanje deleted the cucumber-expressions-enum-simplification branch July 27, 2018 11:15
aslakhellesoy added a commit that referenced this pull request Aug 29, 2018
@lock
Copy link

lock bot commented Jul 27, 2019

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 Jul 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants