本文整理汇总了Java中javassist.bytecode.AnnotationsAttribute.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationsAttribute.getAnnotation方法的具体用法?Java AnnotationsAttribute.getAnnotation怎么用?Java AnnotationsAttribute.getAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javassist.bytecode.AnnotationsAttribute
的用法示例。
在下文中一共展示了AnnotationsAttribute.getAnnotation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDbCommentAnnotation
import javassist.bytecode.AnnotationsAttribute; //导入方法依赖的package包/类
private void addDbCommentAnnotation(AnnotationsAttribute attribute) {
if (attribute.getAnnotation(DbComment.class.getName()) != null) return;
StringBuilder builder = new StringBuilder();
String display = appendDbCommentValue(attribute, Display.class);
if (StringUtils.isNotBlank(display))
builder.append(display);
String desc = appendDbCommentValue(attribute, Description.class);
if (StringUtils.isNotBlank(desc))
builder.append(" ").append(desc);
if (builder.length() > 0) {
Map<String, MemberValue> valueMap = Maps.newHashMap();
ConstPool cp = attribute.getConstPool();
valueMap.put("value", new StringMemberValue(builder.toString()
.replace("'", "''")
.replace("\r", " ")
.replace("\n", " "), cp));
addAnnotation(attribute, DbComment.class, valueMap);
}
}
示例2: isAnnotated
import javassist.bytecode.AnnotationsAttribute; //导入方法依赖的package包/类
private static boolean isAnnotated(ClassFile cfile, Class<? extends Annotation>[] annotated) throws IOException {
List attributes = U.safe(cfile.getAttributes());
for (Object attribute : attributes) {
if (attribute instanceof AnnotationsAttribute) {
AnnotationsAttribute annotations = (AnnotationsAttribute) attribute;
for (Class<? extends Annotation> ann : annotated) {
if (annotations.getAnnotation(ann.getName()) != null) {
return true;
}
}
}
}
return false;
}
示例3: xmlRootElement
import javassist.bytecode.AnnotationsAttribute; //导入方法依赖的package包/类
/**
* Create new <tt>XmlRootElement</tt> annotation.
* @param file Javassist file to work with
* @param name Name of root element
* @return The annotation
*/
private static Annotation xmlRootElement(final ClassFile file,
final String name) {
final AnnotationsAttribute attribute = AnnotationsAttribute.class.cast(
file.getAttribute(AnnotationsAttribute.visibleTag)
);
final Annotation annotation = attribute.getAnnotation(
XmlRootElement.class.getName()
);
annotation.addMemberValue(
"name",
new StringMemberValue(name, file.getConstPool())
);
Logger.debug(
JaxbGroup.class,
"#xmlRootElement(.., '%s'): annotation created",
name
);
return annotation;
}
示例4: applyTransformations
import javassist.bytecode.AnnotationsAttribute; //导入方法依赖的package包/类
@Override
protected void applyTransformations(CtClass clazz) throws Exception {
AnnotationsAttribute attribute = (AnnotationsAttribute) clazz.getClassFile().getAttribute(AnnotationsAttribute.visibleTag);
Annotation annotation = attribute.getAnnotation("org.spongepowered.api.plugin.Plugin");
StringMemberValue version = (StringMemberValue) annotation.getMemberValue("version");
version.setValue(this.version);
attribute.setAnnotation(annotation);
}
示例5: updatePropOrder
import javassist.bytecode.AnnotationsAttribute; //导入方法依赖的package包/类
static
private void updatePropOrder(CtClass ctClass, String name){
ClassFile classFile = ctClass.getClassFile();
AnnotationsAttribute annotations = (AnnotationsAttribute)classFile.getAttribute(AnnotationsAttribute.visibleTag);
Annotation xmlTypeAnnotation = annotations.getAnnotation("javax.xml.bind.annotation.XmlType");
ArrayMemberValue propOrderValue = (ArrayMemberValue)xmlTypeAnnotation.getMemberValue("propOrder");
removeValue(propOrderValue, name);
annotations.addAnnotation(xmlTypeAnnotation);
}