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 missing methods to ImmutableMapFactory #819

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add missing methods to ImmutableMapFactory #819

wants to merge 2 commits into from

Conversation

kedar-joshi
Copy link
Contributor

@kedar-joshi kedar-joshi commented Mar 8, 2020

Additional changes include -

  1. Replace usage of newly deprecated methods.
  2. Update interface Javadoc to align with deprecated
    implementation in (ImmutableMapFactoryImpl#ofMap).

Closes gh-738

Signed-off-by: Kedar Joshi kdar_joshi@yahoo.com

@kedar-joshi
Copy link
Contributor Author

I think I should also add @Since on new methods. Right ?

@nikhilnanivadekar
Copy link
Contributor

@kedar-joshi thanks for your contribution! Before I review the PR, a little bit of admin stuff so that it is easier for me when I write the release notes. Can you break the additional changes which you have done in separate commits, please? It is fine to have it in this PR, just separate commits, so that I can look at the history easily and compile the release notes. Also, the history remains clean.
Yes, please add since tag as well.
Please ping me when it is done, I will review it. Cheers!
Thanks for helping us out!

@kedar-joshi
Copy link
Contributor Author

Can you break the additional changes which you have ..

Sure.

@nikhilnanivadekar
Copy link
Contributor

There are build failures. Also the implementation is far easier than what you have right now. Please take a look in the review. Thanks for your contribution!

Copy link
Contributor

@motlin motlin left a comment

Choose a reason for hiding this comment

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

I'm marking this as "request changes" so we don't merge it yet, but let's chat about it. I'm not sure we should go this route.

/**
* @since 10.3.0
*/
<K, V> ImmutableMap<K, V> withMapIterable(MapIterable<K, V> mapIterable);
Copy link
Contributor

Choose a reason for hiding this comment

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

ImmutableMapFactoryImpl has a single deprecated method.

    /**
     * @deprecated use {@link #ofAll(Map)} instead (inlineable)
     */
    @Override
    @Deprecated
    public <K, V> ImmutableMap<K, V> ofMap(Map<K, V> map)
    {
        return this.ofAll(map);
    }

This does not bring the interface in line with the implementation. The one method that ought to be deprecated doesn't match the correct suggestion.

* @since 10.3.0
*/
@Override
public <K, V> ImmutableMap<K, V> withMap(Map<K, V> map)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like the change you're making is different than what the title says. You're really adding a new method called withMap and deprecating ofAll and withAll at the same time in favor of it.

Copy link
Contributor

Choose a reason for hiding this comment

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

In addition, this only changes ImmutableMapFactory. It misses other object maps (BiMap, hashing strategy) and primitive maps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like the change you're making is different than what the title says. You're really adding a new method called withMap and deprecating ofAll and withAll at the same time in favor of it.

@motlin I kept phrasing of the title similar to the original issue gh-738.

@nikhilnanivadekar
Copy link
Contributor

Looping in @donraab as he initially opened the issue.

@motlin motlin self-requested a review March 10, 2020 00:31
@motlin
Copy link
Contributor

motlin commented Mar 10, 2020

I see the context of gh-738 now, but the deprecation still doesn't make sense as written. The methods with bad generics are deprecated, but the new methods also have bad generics. There's no version of ofMap that's not deprecated.

I think we should experiment with pulling methods up to a super-interface to drive consistency (in a separate commit) to make this sort of thing enforced by the compiler.

@motlin
Copy link
Contributor

motlin commented Mar 10, 2020

Here's an example, to start the conversation: motlin@f9397b2

@motlin
Copy link
Contributor

motlin commented Mar 10, 2020

And here's a similar example for Maps. This one doesn't compile because the interfaces are truly not compatible.
motlin@07c81aa

Closes gh-738

Signed-off-by: Kedar Joshi <kdar_joshi@yahoo.com>
Signed-off-by: Kedar Joshi <kdar_joshi@yahoo.com>
@anishlukk123
Copy link

is this pull request abadoned?

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.

ImmutableMapFactory missing withMap, ofMapIterable and withMapIterable
4 participants