本文整理汇总了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;
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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");
}
}
示例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");
}
}
示例8: matches
import java.lang.reflect.AnnotatedElement; //导入方法依赖的package包/类
public boolean matches(AnnotatedElement element) {
return element.isAnnotationPresent(annotationType);
}