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 lenient factory method in KiwiSort.Direction #770

Closed
sleberknight opened this issue Aug 31, 2022 · 0 comments · Fixed by #771
Closed

Add lenient factory method in KiwiSort.Direction #770

sleberknight opened this issue Aug 31, 2022 · 0 comments · Fixed by #771
Assignees
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

Add lenient factory method to KiwiSort.Direction that accepts a String, e.g. KiwiSort.Direction.fromString(str)

It should throw IllegalArgumentException if the given direction does not resolve to a valid KiwiSort.Direction, e.g. if given an invalid string like "foo".

Originally proposed in #707

@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Aug 31, 2022
@sleberknight sleberknight added this to the 2.3.0 milestone Aug 31, 2022
@sleberknight sleberknight self-assigned this Aug 31, 2022
sleberknight added a commit that referenced this issue Aug 31, 2022
The KiwiSort.Direction#fromString factory method is case-insensitive
and strips any leading or trailing whitespace. It is overloaded to
allow using with the default Locale or a specific one.

Closes #770
chrisrohr pushed a commit that referenced this issue Aug 31, 2022
The KiwiSort.Direction#fromString factory method is case-insensitive
and strips any leading or trailing whitespace. It is overloaded to
allow using with the default Locale or a specific one.

Closes #770
sleberknight added a commit that referenced this issue Sep 1, 2022
Instead of converting the given String value to uppercase
and having to deal with Locales, do a case-insensitive
comparison instead. To make this much easier, I just used
EnumUtils#getEnumIgnoreCase from commons-lang3.
Now, there is no need for allowing a Locale to be supplied
which was a really an implementation detail and should not
be part of the public API.

Refs #770 #772
sleberknight added a commit that referenced this issue Sep 1, 2022
Instead of converting the given String value to uppercase
and having to deal with Locales, do a case-insensitive
comparison instead. To make this much easier, I just used
EnumUtils#getEnumIgnoreCase from commons-lang3.
Now, there is no need for allowing a Locale to be supplied
which was a really an implementation detail and should not
be part of the public API.

Refs #770 #772
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant