@Override
        public int compare(AnnotatedMethod m1, AnnotatedMethod m2) {

          int o1 = m1.getApplicablTestMethodsAndOrder().getOrder();
          int o2 = m2.getApplicablTestMethodsAndOrder().getOrder();

          if (o1 > 0) {
            if (o2 > 0) {
              return o1 - o2;
            } else {
              // explicitly ordered stuff always precedes the unordered
              return -1;
            }
          } else {
            // explicitly ordered stuff always precedes the unordered
            return o2 > 0 ? 1 : 0;
          }
        }
  private List<Method> filterAndOrderMethods(
      String targetTestMethodName, Method[] beforeDiscoveryMethods) {
    List<AnnotatedMethod> ordered =
        new ArrayList<AbstractAroundDiscoveryExecutor.AnnotatedMethod>(
            beforeDiscoveryMethods.length);

    for (int i = 0; i < beforeDiscoveryMethods.length; ++i) {
      T annotation = beforeDiscoveryMethods[i].getAnnotation(annotationClass);
      ApplicableTestMethodsAndOrder o = getApplicableTestMethodsAndOrder(annotation);

      AnnotatedMethod m = new AnnotatedMethod(beforeDiscoveryMethods[i], o);

      ordered.add(m);
    }

    Iterator<AnnotatedMethod> it = ordered.iterator();

    // filter
    while (it.hasNext()) {
      AnnotatedMethod m = it.next();

      String[] applicableTestMethodNames =
          m.getApplicablTestMethodsAndOrder().getApplicableTestMethodNames();

      if (applicableTestMethodNames.length > 0
          && !Arrays.asList(applicableTestMethodNames).contains(targetTestMethodName)) {

        it.remove();
      }
    }

    // order
    Collections.sort(ordered, ORDERING);

    // convert to List<Method>

    List<Method> ret = new ArrayList<Method>(ordered.size());

    for (AnnotatedMethod m : ordered) {
      ret.add(m.getTestMethod());
    }

    return ret;
  }