private static String nameOf(Method method) {
   Name name = method.getAnnotation(Name.class);
   if (name != null) {
     return name.value();
   }
   return method.getName();
 }
Exemple #2
0
 static String getSuiteName(Class<?> klass) throws InitializationError {
   Name nameAnnotation = klass.getAnnotation(Name.class);
   if (nameAnnotation == null) {
     throw new InitializationError("There must be a @Name annotation");
   }
   return nameAnnotation.value();
 }
Exemple #3
0
 public static Set get() {
   if (set == null) {
     Set ret = new Set();
     for (Class<? extends Card> card : org.rnd.jmagic.CardLoader.getAllCards()) {
       Name name = card.getAnnotation(Name.class);
       if (name != null)
         // when naming cards for meddling mage, you name one
         // side of a split card, not both sides.
         java.util.Arrays.stream(name.value().split(" // ")).forEach(n -> ret.add(n));
     }
     set = new Set.Unmodifiable(ret);
   }
   return set;
 }
  public static void parse() {
    Class classt = ITCAST.class;
    /** 类上的注解 */
    if (classt.isAnnotationPresent(Name.class)) {
      Name name = (Name) classt.getAnnotation(Name.class);
      System.out.println(name.value());
    }

    Method[] methods = classt.getMethods();
    for (Method method : methods) {
      if (method.isAnnotationPresent(Description.class)) {
        Description description = (Description) method.getAnnotation(Description.class);
        System.out.println(description.value());
      }
    }
  }
Exemple #5
0
 public static String getClassName(Class<?> clazz) {
   Name name = clazz.getAnnotation(Name.class);
   return name == null ? clazz.getSimpleName() : name.value();
 }