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


Java FieldSource.getAnnotations方法代码示例

本文整理汇总了Java中org.jboss.forge.roaster.model.source.FieldSource.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java FieldSource.getAnnotations方法的具体用法?Java FieldSource.getAnnotations怎么用?Java FieldSource.getAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.forge.roaster.model.source.FieldSource的用法示例。


在下文中一共展示了FieldSource.getAnnotations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.jboss.forge.roaster.model.source.FieldSource; //导入方法依赖的package包/类
public void visit(FieldSource<? extends JavaSource> fieldSource) {
    Type fieldType = fieldSource.getType();
    String fieldClassName;

    // the javadoc for Named.getName() is misleading:
    // the FieldSource.getName() (which is implemented by FieldImpl.getName())
    // returns the (fully-qualified!) name of the field
    String fieldName = fieldSource.getName();
    resParts.addPart(fieldName,
                     PartType.FIELD);

    if (fieldType.isPrimitive()) {
        fieldClassName = fieldType.getName();
    } else {
        fieldClassName = fieldType.getQualifiedName();
    }
    addJavaResourceReference(fieldClassName);

    // Field annotations
    for (AnnotationSource annoSource : fieldSource.getAnnotations()) {
        visit(annoSource);
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:24,代码来源:TestJavaSourceVisitor.java

示例2: visit

import org.jboss.forge.roaster.model.source.FieldSource; //导入方法依赖的package包/类
public void visit(FieldSource<? extends JavaSource> fieldSource) {
    Type fieldType = fieldSource.getType();
    String fieldClassName;

    // the javadoc for Named.getName() is misleading:
    // the FieldSource.getName() (which is implemented by FieldImpl.getName())
    // returns the (fully-qualified!) name of the field
    String fieldName = fieldSource.getName();
    resParts.addPart(fieldName, PartType.FIELD);

    try {
        if (DriverUtils.isManagedType(fieldType, classTypeResolver)) {
            if (fieldType.isPrimitive()) {
                fieldClassName = fieldType.getName();
            } else if (DriverUtils.isSimpleClass(fieldType)) {
                fieldClassName = classTypeResolver.getFullTypeName(fieldType.getName());
            } else {
                //if this point was reached, we know it's a Collection.
                // Managed type check was done previously.
                Type elementsType = ((List<Type>) fieldType.getTypeArguments()).get(0);
                fieldClassName = classTypeResolver.getFullTypeName(elementsType.getName());
            }
        } else {
            // mriet: not complete sure why we don't just do this instead of using DriverUtils?
            fieldClassName = fieldType.getQualifiedName();
        }
        addJavaResourceReference(fieldClassName);
    } catch (Exception e) {
        logger.error("Unable to index java class field for class: " + javaSource.getQualifiedName() + ", fieldName: " + fieldName + " fieldType: " + fieldType);
    }

    // Field annotations
    for (AnnotationSource annoSource : fieldSource.getAnnotations()) {
        visit(annoSource);
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:37,代码来源:JavaSourceVisitor.java


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