java.lang.reflect.Executable.getAnnotation()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中java.lang.reflect.Executable.getAnnotation()方法的一些代码示例,展示了Executable.getAnnotation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Executable.getAnnotation()方法的具体详情如下:
包路径:java.lang.reflect.Executable
类名称:Executable
方法名:getAnnotation

Executable.getAnnotation介绍

暂无

代码示例

代码示例来源:origin: jdbi/jdbi

@Nullable
<A extends Annotation> A getAnnotation(Class<A> annotationClass) {
  return executable.getAnnotation(annotationClass);
}

代码示例来源:origin: jooby-project/jooby

return RouteParameter.Kind.PATH;
boolean formLike = !hasBody && p.getDeclaringExecutable().getAnnotation(POST.class) != null;
if (formLike) {
 return RouteParameter.Kind.FORM;

代码示例来源:origin: oblac/jodd

PetiteInject petiteInject = methodOrCtor.getAnnotation(PetiteInject.class);

代码示例来源:origin: org.jboss.weld.se/weld-se-shaded

public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
  return executable.getAnnotation(annotationType);
}

代码示例来源:origin: weld/core

public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
  return executable.getAnnotation(annotationType);
}

代码示例来源:origin: weld/core

public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
  return executable.getAnnotation(annotationType);
}

代码示例来源:origin: weld/core

public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
  return executable.getAnnotation(annotationType);
}

代码示例来源:origin: org.jboss.weld.servlet/weld-servlet-shaded

public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
  return executable.getAnnotation(annotationType);
}

代码示例来源:origin: com.github.XDean/Java-EX

@SuppressWarnings("unchecked")
public static <T extends Annotation> T removeAnnotation(Executable ex, Class<T> annotationType) {
 if (ex.getAnnotation(annotationType) == null) {
  return null;
 }
 ex.getAnnotation(Annotation.class);// prevent declaredAnnotations haven't initialized
 Map<Class<? extends Annotation>, Annotation> annos;
 try {
  annos = (Map<Class<? extends Annotation>, Annotation>) Field_Excutable_DeclaredAnnotations.get(ex);
 } catch (IllegalAccessException e) {
  throw new IllegalStateException(e);
 }
 return (T) annos.remove(annotationType);
}

代码示例来源:origin: com.github.XDean/Java-EX

/**
 * Add annotation to Executable(Method or Constructor)<br>
 * Note that you may need to give the root method.
 *
 * @param ex
 * @param annotation
 * @author XDean
 * @see Executable
 * @see #createAnnotationFromMap(Class, Map)
 * @see ReflectUtil#getRootMethods(Class)
 */
@SuppressWarnings("unchecked")
public static void addAnnotation(Executable ex, Annotation annotation) {
 ex.getAnnotation(Annotation.class);// prevent declaredAnnotations haven't initialized
 Map<Class<? extends Annotation>, Annotation> annos;
 try {
  annos = (Map<Class<? extends Annotation>, Annotation>) Field_Excutable_DeclaredAnnotations.get(ex);
 } catch (IllegalAccessException e) {
  throw new IllegalStateException(e);
 }
 if (annos.getClass() == Collections.EMPTY_MAP.getClass()) {
  annos = new HashMap<>();
  try {
   Field_Excutable_DeclaredAnnotations.set(ex, annos);
  } catch (IllegalAccessException e) {
   throw new IllegalStateException(e);
  }
 }
 annos.put(annotation.annotationType(), annotation);
}

代码示例来源:origin: btrplace/scheduler

public List<TestCampaign> testGroups(String... groups) throws IllegalAccessException, InvocationTargetException, InstantiationException {
    List<Executable> ms = new ArrayList<>();
    Set<String> ok = Stream.of(groups).collect(Collectors.toSet());

    FastClasspathScanner scanner = new FastClasspathScanner();
    scanner.matchClassesWithMethodAnnotation(CstrTest.class, (cl, m) -> {
      CstrTest a = m.getAnnotation(CstrTest.class);
      for (String g : a.groups()) {
        if (ok.contains(g)) {
          ms.add(m);
        }
      }
    }).scan(Runtime.getRuntime().availableProcessors() - 1);
    return test(ms.toArray(new Method[ms.size()]));
  }
}

代码示例来源:origin: io.astefanutti.metrics.cdi/metrics-cdi

private <T extends Annotation> Of<T> elementResolverOf(Executable executable, Class<T> metric) {
  T annotation = executable.getAnnotation(metric);
  String name = metricName(executable, metric, metricName(annotation), isMetricAbsolute(annotation));
  return new DoesHaveMetric<>(annotation, name);
}

代码示例来源:origin: astefanutti/metrics-cdi

private <T extends Annotation> Of<T> elementResolverOf(Executable executable, Class<T> metric) {
  T annotation = executable.getAnnotation(metric);
  String name = metricName(executable, metric, metricName(annotation), isMetricAbsolute(annotation));
  return new DoesHaveMetric<>(annotation, name);
}

代码示例来源:origin: org.jooby/jooby-apitool

return RouteParameter.Kind.PATH;
boolean formLike = !hasBody && p.getDeclaringExecutable().getAnnotation(POST.class) != null;
if (formLike) {
 return RouteParameter.Kind.FORM;

代码示例来源:origin: org.jodd/jodd-petite

PetiteInject petiteInject = methodOrCtor.getAnnotation(PetiteInject.class);

相关文章