summaryrefslogtreecommitdiff
path: root/platform/structuralsearch/source/com/intellij/tokenindex/TokenIndexKey.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/structuralsearch/source/com/intellij/tokenindex/TokenIndexKey.java')
-rw-r--r--platform/structuralsearch/source/com/intellij/tokenindex/TokenIndexKey.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/platform/structuralsearch/source/com/intellij/tokenindex/TokenIndexKey.java b/platform/structuralsearch/source/com/intellij/tokenindex/TokenIndexKey.java
new file mode 100644
index 000000000000..8c6ec1d93875
--- /dev/null
+++ b/platform/structuralsearch/source/com/intellij/tokenindex/TokenIndexKey.java
@@ -0,0 +1,60 @@
+package com.intellij.tokenindex;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Set;
+
+/**
+ * @author Eugene.Kudelevsky
+ */
+public class TokenIndexKey {
+ private final Set<String> myLanguages;
+ private final int myBlockId;
+
+ public TokenIndexKey(@NotNull Set<String> languages, int blockId) {
+ myLanguages = languages;
+ myBlockId = blockId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ TokenIndexKey that = (TokenIndexKey)o;
+
+ if (myBlockId != that.myBlockId) return false;
+ if (!myLanguages.equals(that.myLanguages)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = myLanguages.hashCode();
+ result = 31 * result + myBlockId;
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return myLanguages + ": " + myBlockId;
+ }
+
+ public Set<String> getLanguages() {
+ return myLanguages;
+ }
+
+ public boolean containsLanguage(String languageId) {
+ for (String language : myLanguages) {
+ if (language.contains(languageId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public int getBlockId() {
+ return myBlockId;
+ }
+}