title: How to inove methods with annotation parameter prioritet
body: <p>How to invoke methods with annotation parameter prioritet?</p>
  
  <p>Got testmethods, which i should invoke with java reflection:</p>
  
  <pre><code>public class Testmethods {
  
  //There are eight method, should be invocen with value prioritet.
  //First method(1), last method(8)
  
  //first method
  @Test(8)
  public void method1(){
      System.out.println("test");
  }
  .
  .
  .
  .
  //last method
  @Test(1)
  public void method8(){
      System.out.println("test7");
  }
  </code></pre>
  
  <p>Annottation class with int parametr prioritet:</p>
  
  <pre><code>@Retention(RetentionPolicy.RUNTIME)
  @Target(ElementType.METHOD)
  public @interface Test {
      int value();
  }
  </code></pre>
  
  <p>Try to invoke it with loop:</p>
  
  <pre><code>   private static void start(Class c) throws Exception {
          c = Testmethods.class;
          Method[] methods = c.getDeclaredMethods();
  
          int before = 0;
          int after = 0;
          int annoValue = 0;
  
          for (Method m : methods) {
              if (m.isAnnotationPresent(BeforeSuite.class)) {
                  before++;
              }
              if (m.isAnnotationPresent(AfterSuite.class)) {
                  after++;
              }
  
              if (m.isAnnotationPresent(BeforeSuite.class) &amp;&amp; 
                  before &gt; COUNT || m.isAnnotationPresent(AfterSuite.class) &amp;&amp; 
                  after &gt; COUNT) {
                  throw new RuntimeException("more then one");
              }
  
              if (m.isAnnotationPresent(BeforeSuite.class) &amp;&amp; 
                  m.getAnnotation(BeforeSuite.class).value() == 10) {
                  m.invoke(c.newInstance());
              }
           }
  
  
  //loop to invoke.  
  //Loop invoce it in random order.       
              for (int i = 1; i &lt; 9; i++) {
              if (methods[i].isAnnotationPresent(Test.class) &amp;&amp; 
                 (methods[i].getAnnotation(Test.class).value() &lt; i)) {
                  methods[i].invoke(c.newInstance());
              }
          }
      }
  </code></pre>
  
  <p>But it's not work propertly.</p>
  
  <p>How to inove methods with annotation parameter prioritet?</p>