|
9 | 9 | package org.elasticsearch; |
10 | 10 |
|
11 | 11 | import org.elasticsearch.common.Strings; |
12 | | -import org.elasticsearch.common.collect.ImmutableOpenIntMap; |
13 | | -import org.elasticsearch.common.collect.ImmutableOpenMap; |
14 | 12 | import org.elasticsearch.common.io.stream.StreamInput; |
15 | 13 | import org.elasticsearch.common.io.stream.StreamOutput; |
16 | 14 | import org.elasticsearch.core.RestApiVersion; |
|
24 | 22 | import java.lang.reflect.Modifier; |
25 | 23 | import java.util.ArrayList; |
26 | 24 | import java.util.Collections; |
| 25 | +import java.util.HashMap; |
27 | 26 | import java.util.List; |
28 | 27 | import java.util.Locale; |
| 28 | +import java.util.Map; |
29 | 29 | import java.util.Objects; |
30 | 30 |
|
31 | 31 | public class Version implements Comparable<Version>, ToXContentFragment { |
@@ -112,12 +112,12 @@ public class Version implements Comparable<Version>, ToXContentFragment { |
112 | 112 | public static final Version V_8_3_0 = new Version(8_03_00_99, org.apache.lucene.util.Version.LUCENE_9_1_0); |
113 | 113 | public static final Version CURRENT = V_8_3_0; |
114 | 114 |
|
115 | | - private static final ImmutableOpenIntMap<Version> idToVersion; |
116 | | - private static final ImmutableOpenMap<String, Version> stringToVersion; |
| 115 | + private static final Map<Integer, Version> idToVersion; |
| 116 | + private static final Map<String, Version> stringToVersion; |
117 | 117 |
|
118 | 118 | static { |
119 | | - final ImmutableOpenIntMap.Builder<Version> builder = ImmutableOpenIntMap.builder(); |
120 | | - final ImmutableOpenMap.Builder<String, Version> builderByString = ImmutableOpenMap.builder(); |
| 119 | + final Map<Integer, Version> builder = new HashMap<>(); |
| 120 | + final Map<String, Version> builderByString = new HashMap<>(); |
121 | 121 |
|
122 | 122 | for (final Field declaredField : Version.class.getFields()) { |
123 | 123 | if (declaredField.getType().equals(Version.class)) { |
@@ -158,8 +158,8 @@ public class Version implements Comparable<Version>, ToXContentFragment { |
158 | 158 | + "]"; |
159 | 159 | builder.put(V_EMPTY_ID, V_EMPTY); |
160 | 160 | builderByString.put(V_EMPTY.toString(), V_EMPTY); |
161 | | - idToVersion = builder.build(); |
162 | | - stringToVersion = builderByString.build(); |
| 161 | + idToVersion = Map.copyOf(builder); |
| 162 | + stringToVersion = Map.copyOf(builderByString); |
163 | 163 | } |
164 | 164 |
|
165 | 165 | public static Version readVersion(StreamInput in) throws IOException { |
|
0 commit comments