当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationsAttribute.getAnnotation方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:icode,项目名称:ameba-dev,代码行数:22,代码来源:EbeanEnhancer.java

示例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;
}
 
开发者ID:rapidoid,项目名称:rapidoid,代码行数:18,代码来源:ClasspathScanner.java

示例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;
}
 
开发者ID:yegor256,项目名称:rexsl,代码行数:26,代码来源:JaxbGroup.java

示例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);
}
 
开发者ID:BuycraftPlugin,项目名称:BuycraftX,代码行数:9,代码来源:Transform.java

示例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);
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:15,代码来源:TransformationUtil.java


注:本文中的javassist.bytecode.AnnotationsAttribute.getAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。