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);

  }
}

@@ -219,56 +219,8 @@
 ity%0A
- *%0A * Created on Sep 26, 2005%0A * @author cbeust%0A
  */%0A
@@ -307,16 +307,17 @@
 ptor%3E %7B%0A
+%0A
   privat
@@ -318,16 +318,22 @@
 private 
+final 
 IMethodS
@@ -368,16 +368,22 @@
 private 
+final 
 int m_pr
@@ -748,196 +748,91 @@
    i
-nt result = 0;%0A%0A    try %7B%0A      int p1 = getPriority()
+f (other == null) %7B%0A      return 1
 ;%0A    
- 
- int p2 = other.getPriority();%0A      result = p1 - p2;%0A    %7D%0A    catch(Exception ex) %7B%0A      // ignore%0A    %7D%0A%0A    return result
+%7D%0A%0A    return m_priority - other.m_priority
 ;%0A  
@@ -948,15 +948,14 @@
 thods);%0A
-%0A
   %7D%0A%7D%0A

Rework MethodSelectorDescriptor