当前位置: 首页>>代码示例>>Java>>正文


Java AnnotatedElement.getAnnotations方法代码示例

本文整理汇总了Java中java.lang.reflect.AnnotatedElement.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedElement.getAnnotations方法的具体用法?Java AnnotatedElement.getAnnotations怎么用?Java AnnotatedElement.getAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.AnnotatedElement的用法示例。


在下文中一共展示了AnnotatedElement.getAnnotations方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMethodAnnotations

import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
private <T extends Annotation> List<T> getMethodAnnotations(AnnotatedElement ae,
           Class<T> annotationType) {
	List<T> anns = new ArrayList<T>(2);
	// look for raw annotation
	T ann = ae.getAnnotation(annotationType);
	if (ann != null) {
		anns.add(ann);
	}
	// look for meta-annotations
	for (Annotation metaAnn : ae.getAnnotations()) {
		ann = metaAnn.annotationType().getAnnotation(annotationType);
		if (ann != null) {
			anns.add(ann);
		}
	}
	return (anns.isEmpty() ? null : anns);
}
 
开发者ID:ziwenxie,项目名称:leafer,代码行数:18,代码来源:CachingAnnotationsAspect.java

示例2: getAnnotations

import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
private <T extends Annotation> Collection<T> getAnnotations(AnnotatedElement ae, Class<T> annotationType) {
	Collection<T> anns = new ArrayList<T>(2);

	// look at raw annotation
	T ann = ae.getAnnotation(annotationType);
	if (ann != null) {
		anns.add(ann);
	}

	// scan meta-annotations
	for (Annotation metaAnn : ae.getAnnotations()) {
		ann = metaAnn.annotationType().getAnnotation(annotationType);
		if (ann != null) {
			anns.add(ann);
		}
	}

	return (anns.isEmpty() ? null : anns);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:SpringCacheAnnotationParser.java

示例3: findAnnotations

import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
/**
 * Find the annotations of given <code>annotationType</code> on given element and stores them in given
 * <code>accumulator</code>.
 * @param accumulator Accumulator
 * @param element Annotated element
 * @param annotationType Annotation type to lookup
 * @param repeatableContainerType Optional repeteable annotation type
 */
private static <A extends Annotation> void findAnnotations(List<A> accumulator, AnnotatedElement element,
		Class<A> annotationType, Class<? extends Annotation> repeatableContainerType) {

	// direct lookup
	A[] as = element.getAnnotationsByType(annotationType);
	if (as.length > 0) {
		for (A a : as) {
			accumulator.add(a);
		}
	}

	// check meta-annotations
	Annotation[] all = element.getAnnotations();
	if (all.length > 0) {
		for (Annotation annotation : all) {
			if (!isInJavaLangAnnotationPackage(annotation) && !annotation.annotationType().equals(annotationType)
					&& (repeatableContainerType == null
							|| !annotation.annotationType().equals(repeatableContainerType))) {
				findAnnotations(accumulator, annotation.annotationType(), annotationType, repeatableContainerType);
			}
		}
	}

}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:33,代码来源:AnnotationUtils.java

示例4: Annotations

import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
public Annotations(AnnotatedElement... elements) {
    for (AnnotatedElement element : elements) {
        for (Annotation annotation : element.getAnnotations()) {
            annotations.put(annotation.annotationType(), annotation);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Annotations.java

示例5: AnnotatedElementAdapter

import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
public AnnotatedElementAdapter(AnnotatedElement... elements) {
    for (AnnotatedElement element : elements) {
        for (Annotation annotation : element.getAnnotations()) {
            annotations.put(annotation.annotationType(), annotation);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:AnnotatedElementAdapter.java

示例6: checkAnnotations

import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
private static void checkAnnotations(AnnotatedElement el, AnnotatableWrapper aw) throws Exception {
    for (Annotation ann : el.getAnnotations()) {
        Annotation wrapper = aw.getAnnotation(ann.annotationType());

        assertNotNull(ann.annotationType().getName(), wrapper);

        checkAnnotation(ann, wrapper);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:FSWrapperTest.java

示例7: isAction

import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
public static boolean isAction(AnnotatedElement element) {
    if (element.getAnnotation(Action.class) != null) {
        return true;
    }
    for (Annotation anno : element.getAnnotations()) {
        if (AnnotationUtil.isActionAnnotation(anno)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:febit,项目名称:febit,代码行数:12,代码来源:AnnotationUtil.java

示例8: getBindingAnnotations

import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
private static List<Annotation> getBindingAnnotations(AnnotatedElement element) {
  List<Annotation> annotations = new ArrayList<>();
  for (Annotation annotation : element.getAnnotations()) {
    if (isBindingAnnotation(annotation)) {
      annotations.add(annotation);
    }
  }

  return annotations;
}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:11,代码来源:GuiceExtension.java

示例9: descriptorForElement

import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
public static Descriptor descriptorForElement(final AnnotatedElement elmt) {
    if (elmt == null)
        return ImmutableDescriptor.EMPTY_DESCRIPTOR;
    final Annotation[] annots = elmt.getAnnotations();
    return descriptorForAnnotations(annots);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:Introspector.java


注:本文中的java.lang.reflect.AnnotatedElement.getAnnotations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。