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