aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/testng/internal/MethodSelectorDescriptor.java
blob: 1ad2d08558c6b575ed2f2f8e077f007199f377b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package org.testng.internal;

import org.testng.IMethodSelector;
import org.testng.ITestNGMethod;

import java.util.List;

/**
 * This class describes a method selector:
 * - The class that implements it
 * - Its priority
 *
 * Created on Sep 26, 2005
 * @author cbeust
 */
public class MethodSelectorDescriptor implements Comparable<MethodSelectorDescriptor> {
  private IMethodSelector m_methodSelector;
  private int m_priority;

  public int getPriority() {
    return m_priority;
  }

  public IMethodSelector getMethodSelector() {
    return m_methodSelector;
  }

  public MethodSelectorDescriptor(IMethodSelector selector, int priority) {
    m_methodSelector = selector;
    m_priority = priority;
  }

  @Override
  public int compareTo(MethodSelectorDescriptor other) {
    int result = 0;

    try {
      int p1 = getPriority();
      int p2 = other.getPriority();
      result = p1 - p2;
    }
    catch(Exception ex) {
      // ignore
    }

    return result;
  }

  public void setTestMethods(List<ITestNGMethod> testMethods) {
    m_methodSelector.setTestMethods(testMethods);

  }
}