title: get annotation value?
body: <p>How do you get values set inside a annotation?</p>
  
  <p>I have the following annotation defined:</p>
  
  <pre><code>@Target(ElementType.METHOD)
  @Retention(RetentionPolicy.RUNTIME)
  public @interface JsonElement {
      int type();
  }
  </code></pre>
  
  <p>And here is the method that uses it in a POJO class</p>
  
  <pre><code>@JsonElement(type=GETTER_METHOD)
  public String getUsername{
  ........................
  }
  </code></pre>
  
  <p>And the util class that uses reflection to check if this method has the JSonElement annotation present and to check what the type value is.</p>
  
  <pre><code>Method methods[] = classObject.getClass().getDeclaredMethods();
  
          JSONObject jsonObject = new JSONObject();
          try {
              for (int i = 0; i &lt; methods.length; i++) {
                  String key = methods[i].getName();
                  System.out.println(key);
                  if (methods[i].isAnnotationPresent(JsonElement.class) &amp;&amp; key.startsWith(GET_CHAR_SEQUENCE)) {
                      methods[i].getDeclaredAnnotations();
                      key = key.replaceFirst(GET_CHAR_SEQUENCE, "");
                      jsonObject.put(key, methods[i].invoke(classObject));
                  }
  
              }
              return jsonObject;
          } catch (Exception e) {
              e.printStackTrace();
              return null;
          }
  </code></pre>
  
  <p>How do I find out what <code>type()</code> value is? I can find whether the annotation is present, but I can't find a method that finds out what value - if any - was set for <code>type()</code>.</p>