/*
 * Copyright 2000-2014 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.openapi.extensions;

import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.Map;

/**
 * @author max
 */
public class PluginId implements Comparable<PluginId> {
  public static final PluginId[] EMPTY_ARRAY = new PluginId[0];

  private static final Map<String, PluginId> ourRegisteredIds = new HashMap<String, PluginId>();

  private final String myIdString;

  private PluginId(String idString) {
    myIdString = idString;
  }

  @Override
  public int compareTo(@NotNull PluginId o) {
    return myIdString.compareTo(o.myIdString);
  }

  @NotNull
  public static synchronized PluginId getId(String idString) {
    PluginId pluginId = ourRegisteredIds.get(idString);
    if (pluginId == null) {
      pluginId = new PluginId(idString);
      ourRegisteredIds.put(idString, pluginId);
    }
    return pluginId;
  }

  @NonNls
  public String getIdString() {
    return myIdString;
  }

  @Override
  public String toString() {
    return getIdString();
  }

  public static synchronized Map<String, PluginId> getRegisteredIds() {
    return new HashMap<String, PluginId>(ourRegisteredIds);
  }
}

@@ -636,16 +636,43 @@
 sions;%0A%0A
+import gnu.trove.THashMap;%0A
 import o
@@ -750,34 +750,51 @@
 ll;%0A
-%0A
 import 
-java.util.HashMap;
+org.jetbrains.annotations.Nullable;%0A
 %0Aimp
@@ -1021,24 +1021,25 @@
 edIds = new 
+T
 HashMap%3CStri
@@ -1327,16 +1327,25 @@
 d getId(
+@NotNull 
 String i
@@ -1556,24 +1556,302 @@
 ginId;%0A  %7D%0A%0A
+  @Nullable%0A  public static synchronized PluginId findId(@NotNull String... idStrings) %7B%0A    for (String idString : idStrings) %7B%0A      PluginId pluginId = ourRegisteredIds.get(idString);%0A      if (pluginId != null) %7B%0A        return pluginId;%0A      %7D%0A    %7D%0A    return null;%0A  %7D%0A%0A
   @NonNls%0A  
@@ -1980,16 +1980,27 @@
 );%0A  %7D%0A%0A
+  @NotNull%0A
   public
@@ -2078,16 +2078,17 @@
 urn new 
+T
 HashMap%3C

use trove map, handy method to avoid new map creation