本文整理匯總了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);
}