Deprecate MapBuilder#immutableMap

I'm not 100% sure we should remove it as part of the pull request to drop
ImmutableMap. It might be more prudent to change its return type to map
and its implementation to an unmodifiable copy of the map being built
and then remove all consumers after banning ImmutableMap.
This commit is contained in:
Nik Everett 2015-10-05 08:41:30 -04:00
parent 46d10f1b6f
commit f484290e5e
1 changed files with 7 additions and 0 deletions

View File

@ -83,6 +83,13 @@ public class MapBuilder<K, V> {
return this.map;
}
/**
* Build an immutable copy of the map under construction.
*
* @deprecated always copies the map under construction. prefer building a
* HashMap by hand and wrapping it in an unmodifiableMap
*/
@Deprecated
public ImmutableMap<K, V> immutableMap() {
// Note that this whole method is going to have to go next but we're changing it like this here just to keep the commit smaller.
return ImmutableMap.<K, V>builder().putAll(map).build();