From f484290e5eb973d50164af77beff0625e99f2d33 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 5 Oct 2015 08:41:30 -0400 Subject: [PATCH] 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. --- .../java/org/elasticsearch/common/collect/MapBuilder.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/common/collect/MapBuilder.java b/core/src/main/java/org/elasticsearch/common/collect/MapBuilder.java index 290efb2a1a6..1ca305bc6ba 100644 --- a/core/src/main/java/org/elasticsearch/common/collect/MapBuilder.java +++ b/core/src/main/java/org/elasticsearch/common/collect/MapBuilder.java @@ -83,6 +83,13 @@ public class MapBuilder { 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 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.builder().putAll(map).build();