本文整理匯總了Java中java.lang.reflect.AccessibleObject.isAnnotationPresent方法的典型用法代碼示例。如果您正苦於以下問題:Java AccessibleObject.isAnnotationPresent方法的具體用法?Java AccessibleObject.isAnnotationPresent怎麽用?Java AccessibleObject.isAnnotationPresent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.reflect.AccessibleObject
的用法示例。
在下文中一共展示了AccessibleObject.isAnnotationPresent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createDynamicMethod
import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
/**
* Given a reflective method or a constructor, creates a dynamic method that represents it. This method will
* distinguish between caller sensitive and ordinary methods/constructors, and create appropriate caller sensitive
* dynamic method when needed.
* @param m the reflective member
* @return the single dynamic method representing the reflective member
*/
private static SingleDynamicMethod createDynamicMethod(final AccessibleObject m) {
if (m.isAnnotationPresent(CallerSensitive.class)) {
// Method has @CallerSensitive annotation
return new CallerSensitiveDynamicMethod(m);
}
// Method has no @CallerSensitive annotation
final MethodHandle mh;
try {
mh = unreflectSafely(m);
} catch (final IllegalAccessError e) {
// java.lang.invoke can in some case conservatively treat as caller sensitive methods that aren't
// marked with the annotation. In this case, we'll fall back to treating it as caller sensitive.
return new CallerSensitiveDynamicMethod(m);
}
// Proceed with non-caller sensitive
final Member member = (Member)m;
return new SimpleDynamicMethod(mh, member.getDeclaringClass(), member.getName(), m instanceof Constructor);
}
示例2: annotatedName
import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
private static String annotatedName(AccessibleObject obj) {
if (obj.isAnnotationPresent(PropertyName.class)) {
PropertyName annotation = obj.getAnnotation(PropertyName.class);
return annotation.value();
}
return null;
}
示例3: findAnnotatedMember
import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
private static Member findAnnotatedMember(AccessibleObject[] members,
Class<? extends Annotation> annotation) {
for (AccessibleObject member : members) {
if (member.isAnnotationPresent(annotation)) {
return (Member) member;
}
}
return null;
}
示例4: getCascadeTypes
import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
private CascadeType[] getCascadeTypes(AccessibleObject accessibleObject) {
CascadeType[] cascadeTypes = null;
if(accessibleObject.isAnnotationPresent(OneToMany.class)) {
cascadeTypes = accessibleObject.getAnnotation(OneToMany.class).cascade();
}else if(accessibleObject.isAnnotationPresent(ManyToOne.class)) {
cascadeTypes = accessibleObject.getAnnotation(ManyToOne.class).cascade();
}else if(accessibleObject.isAnnotationPresent(ManyToMany.class)) {
cascadeTypes = accessibleObject.getAnnotation(ManyToMany.class).cascade();
}
return cascadeTypes;
}
示例5: isCallerSensitive
import java.lang.reflect.AccessibleObject; //導入方法依賴的package包/類
private static boolean isCallerSensitive(final AccessibleObject e) {
return e.isAnnotationPresent(CallerSensitive.class);
}