當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。