當前位置: 首頁>>代碼示例>>Java>>正文


Java AnnotatedElement.isAnnotationPresent方法代碼示例

本文整理匯總了Java中java.lang.reflect.AnnotatedElement.isAnnotationPresent方法的典型用法代碼示例。如果您正苦於以下問題:Java AnnotatedElement.isAnnotationPresent方法的具體用法?Java AnnotatedElement.isAnnotationPresent怎麽用?Java AnnotatedElement.isAnnotationPresent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.reflect.AnnotatedElement的用法示例。


在下文中一共展示了AnnotatedElement.isAnnotationPresent方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNameFromMemberAnnotation

import java.lang.reflect.AnnotatedElement; //導入方法依賴的package包/類
private static String getNameFromMemberAnnotation(final AnnotatedElement field) {
    final String result;
    if (field.isAnnotationPresent(Attribute.class)) {
        result = Utils.name(field.getAnnotation(Attribute.class).name(), field);
    } else if (field.isAnnotationPresent(Element.class)) {
        result = Utils.name(field.getAnnotation(Element.class).name(), field);
    } else if (field.isAnnotationPresent(ElementList.class)) {
        result = Utils.name(field.getAnnotation(ElementList.class).name(), field);
    } else if (field.isAnnotationPresent(ElementMap.class)) {
        result = Utils.name(field.getAnnotation(ElementMap.class).name(), field);
    } else if (field.isAnnotationPresent(Text.class)) {
        result = "**text**";
    } else {
        result = null;
    }
    return result;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:18,代碼來源:Configuration.java

示例2: getDependencies

import java.lang.reflect.AnnotatedElement; //導入方法依賴的package包/類
private List<Use> getDependencies(AnnotatedElement element) {
    Use[] requirements = element.isAnnotationPresent(Usages.class)
                ? element.getAnnotation(Usages.class)
                    .value()
                : new Use[] {};
    if(requirements.length == 0 && element.isAnnotationPresent(Use.class)) {
    	requirements = new Use[] {element.getAnnotation(Use.class)};
    }                
    return Arrays.asList(requirements);
}
 
開發者ID:qzagarese,項目名稱:dockerunit,代碼行數:11,代碼來源:DefaultDependencyDescriptorBuilder.java

示例3: getLabels

import java.lang.reflect.AnnotatedElement; //導入方法依賴的package包/類
private static <T extends Annotation> List<Label> getLabels(final AnnotatedElement element,
                                                            final Class<T> annotation,
                                                            final Function<T, List<Label>> extractor) {
    return element.isAnnotationPresent(annotation)
            ? extractor.apply(element.getAnnotation(annotation))
            : Collections.emptyList();
}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:8,代碼來源:Allure1Utils.java

示例4: getLinks

import java.lang.reflect.AnnotatedElement; //導入方法依賴的package包/類
private static <T extends Annotation> List<Link> getLinks(final AnnotatedElement element,
                                                            final Class<T> annotation,
                                                            final Function<T, List<Link>> extractor) {
    return element.isAnnotationPresent(annotation)
            ? extractor.apply(element.getAnnotation(annotation))
            : Collections.emptyList();
}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:8,代碼來源:Allure1Utils.java

示例5: registerAuthenticationFilters

import java.lang.reflect.AnnotatedElement; //導入方法依賴的package包/類
/**
 * Checks if given <code>element</code> has the {@link Authenticate} annotation and if so registers the required
 * authentication filters.
 * @param context Feature context
 * @param element Annotated element
 * @return <code>true</code> if the {@link Authenticate} annotation was found and the authentication filters were
 *         registered, <code>false</code> otherwise
 */
private static boolean registerAuthenticationFilters(FeatureContext context, AnnotatedElement element) {
	if (element.isAnnotationPresent(Authenticate.class)) {
		// AuthContext setup for SecurityContext
		context.register(AuthContextFilter.class, Priorities.AUTHENTICATION - 10);
		// Authenticator
		context.register(new AuthenticationFilter(element.getAnnotation(Authenticate.class).schemes()),
				Priorities.AUTHENTICATION);
		return true;
	}
	return false;
}
 
開發者ID:holon-platform,項目名稱:holon-jaxrs,代碼行數:20,代碼來源:AuthenticationDynamicFeature.java

示例6: readAnnotations

import java.lang.reflect.AnnotatedElement; //導入方法依賴的package包/類
private void readAnnotations(AnnotatedElement element) {
    if (element.isAnnotationPresent(BindItem.class)) {
        BindItem bindItem = element.getAnnotation(BindItem.class);
        putViewType(bindItem.layout(), bindItem.holder());
    } else {
        throw new IllegalStateException("items should be annotated with BindItem");
    }
}
 
開發者ID:sajadshokri,項目名稱:GhostAdapter,代碼行數:9,代碼來源:GhostAdapter.java

示例7: readLayout

import java.lang.reflect.AnnotatedElement; //導入方法依賴的package包/類
private int readLayout(AnnotatedElement element) {
    if (element.isAnnotationPresent(BindItem.class)) {
        BindItem bindItem = element.getAnnotation(BindItem.class);
        return bindItem.layout();
    } else {
        throw new IllegalStateException("items should be annotated with BindItem");
    }
}
 
開發者ID:sajadshokri,項目名稱:GhostAdapter,代碼行數:9,代碼來源:GhostAdapter.java

示例8: matches

import java.lang.reflect.AnnotatedElement; //導入方法依賴的package包/類
public boolean matches(AnnotatedElement element) {
  return element.isAnnotationPresent(annotationType);
}
 
開發者ID:maetrive,項目名稱:businessworks,代碼行數:4,代碼來源:Matchers.java


注:本文中的java.lang.reflect.AnnotatedElement.isAnnotationPresent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。