当前位置: 首页>>代码示例>>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;未经允许,请勿转载。