da7cb07159c50a63192b7733f244e0618d1551ad
[idea/community.git] / platform / lang-impl / src / com / intellij / ide / actions / searcheverywhere / SearchEverywhereFoundElementInfo.java
1 // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 package com.intellij.ide.actions.searcheverywhere;
3
4 import java.util.Comparator;
5
6 /**
7  * Class containing info about found elements
8  */
9 public class SearchEverywhereFoundElementInfo {
10   public final int priority;
11   public final Object element;
12   public final SearchEverywhereContributor<?> contributor;
13
14   public SearchEverywhereFoundElementInfo(Object element, int priority, SearchEverywhereContributor<?> contributor) {
15     this.priority = priority;
16     this.element = element;
17     this.contributor = contributor;
18   }
19
20   public int getPriority() {
21     return priority;
22   }
23
24   public Object getElement() {
25     return element;
26   }
27
28   public SearchEverywhereContributor<?> getContributor() {
29     return contributor;
30   }
31
32   public static final Comparator<SearchEverywhereFoundElementInfo> COMPARATOR = (o1, o2) -> {
33     int res = Integer.compare(o1.priority, o2.priority);
34     if (res != 0) return res;
35
36     return -Integer.compare(o1.contributor.getSortWeight(), o2.contributor.getSortWeight());
37   };
38 }