/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.util.indexing;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

@ApiStatus.Experimental
public class IndexId<K, V> {
  @NotNull
  private final String myName;

  protected IndexId(@NotNull String name) {myName = name;}

  @NotNull
  public final String getName() {
    return myName;
  }

  public static <K, V> IndexId<K, V> create(String name) {
    return new IndexId<K, V>(name);
  }
}

@@ -631,16 +631,43 @@
 exing;%0A%0A
+import gnu.trove.THashMap;%0A
 import o
@@ -702,16 +702,16 @@
 Status;%0A
-
 import o
@@ -745,16 +745,39 @@
 tNull;%0A%0A
+import java.util.Map;%0A%0A
 @ApiStat
@@ -821,16 +821,121 @@
 K, V%3E %7B%0A
+  private static final Map%3CString, IndexId%3C?, ?%3E%3E ourInstances = new THashMap%3CString, IndexId%3C?, ?%3E%3E();%0A%0A
   @NotNu
@@ -1161,22 +1161,164 @@
 ) %7B%0A    
-return
+@SuppressWarnings(%22unchecked%22)%0A    IndexId%3CK, V%3E id = (IndexId%3CK, V%3E)ourInstances.get(name);%0A    if (id == null) %7B%0A      ourInstances.put(name, id =
  new Ind
@@ -1329,20 +1329,42 @@
 %3CK, V%3E(name)
+);%0A    %7D%0A    return id
 ;%0A  %7D%0A%7D%0A

IndexId-s should be singletons