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

Suggestion: Make KiwiMaps.newTreeMap return a SortedMap instead of just Map #484

Closed
chrisrohr opened this issue Dec 10, 2020 · 4 comments · Fixed by #487
Closed

Suggestion: Make KiwiMaps.newTreeMap return a SortedMap instead of just Map #484

chrisrohr opened this issue Dec 10, 2020 · 4 comments · Fixed by #487
Assignees
Labels
enhancement A request for change or improvement to an existing feature
Milestone

Comments

@chrisrohr
Copy link
Contributor

There are a number of instances where libraries need SortedMap instances and using newTreeMap returns a Map which causes compile time issues. Since TreeMap implements SortedMap which implements Map, this should work in most cases.

@chrisrohr chrisrohr added the enhancement A request for change or improvement to an existing feature label Dec 10, 2020
@sleberknight
Copy link
Member

Odd...I just looked at the original (internal) KiwiMaps and that method returns Mapnot SortedMap, so how did it work internally in the places where we now have been forced to cast to SortedMap?

@sleberknight
Copy link
Member

So I can remember, we first encountered the need to cast to a SortedMap in dropwizard-service-utilities in the HttpConnectionsHealthCheckTest

@sleberknight
Copy link
Member

Odd...I just looked at the original (internal) KiwiMaps and that method returns Mapnot SortedMap, so how did it work internally in the places where we now have been forced to cast to SortedMap?

I was wrong...it does return SortedMap, which is why it works...

@sleberknight
Copy link
Member

Signature should be:

public static <K extends Comparable, V> SortedMap<K, V> newTreeMap(Object... items)

@sleberknight sleberknight added this to the 0.18.0 milestone Dec 18, 2020
sleberknight added a commit that referenced this issue Dec 18, 2020
* Change newTreeMap to return SortedMap
* Change newConcurrentHashMap to return ConcurrentMap

Closes #484
Closes #486
chrisrohr pushed a commit that referenced this issue Dec 21, 2020
* Change newTreeMap to return SortedMap
* Change newConcurrentHashMap to return ConcurrentMap
* Use Comparable<? super K> instead of raw Comparable type
* Add a few sanity checking tests

Closes #484
Closes #486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A request for change or improvement to an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants