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


Java JavaType.getAnnotation方法代码示例

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


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

示例1: getCDIBeanName

import org.jboss.forge.roaster.model.JavaType; //导入方法依赖的package包/类
private String getCDIBeanName(UIContextProvider context, String fqcn) throws FileNotFoundException {
	JavaResource javaResource = getJavaResourceFromProject(context, fqcn);
	JavaType<?> javaType = javaResource.getJavaType();
	Annotation<?> named = javaType.getAnnotation(Named.class);
	if (named.getStringValue() != null) {
		return named.getStringValue();
	}
	return Strings.uncapitalize(javaType.getName());
}
 
开发者ID:javaee-samples,项目名称:forge-addons,代码行数:10,代码来源:BatchNewJobXmlCommand.java

示例2: process

import org.jboss.forge.roaster.model.JavaType; //导入方法依赖的package包/类
@Override
public void process(DefaultIndexBuilder builder,
                    JavaType javaType) {
    try {
        final List<Annotation> comparatorDefinitions;

        Annotation planningEntityAnnotation = javaType.getAnnotation(PlanningEntity.class.getName());

        if (planningEntityAnnotation == null) {
            return;
        }

        String difficultyComparatorClass = planningEntityAnnotation.getStringValue("difficultyComparatorClass");

        if (difficultyComparatorClass != null && javaType instanceof JavaClassSource && difficultyComparatorClass.matches("\\w[\\.\\w]+\\.class")) {
            String[] difficultyComparatorTokens = difficultyComparatorClass.split("\\.");
            comparatorDefinitions = ((JavaClassSource) javaType).getNestedTypes().stream()
                    .filter(t -> t instanceof JavaClassSource
                            && t.getName().equals(difficultyComparatorTokens[difficultyComparatorTokens.length - 2])
                            && t.getAnnotation(ComparatorDefinition.class.getName()) != null
                            && t.getAnnotation(Generated.class.getName()) != null
                            && ((JavaClassSource) t).getInterfaces().stream().anyMatch(i -> i.startsWith(Comparator.class.getName())))
                    .map(t -> t.getAnnotation(ComparatorDefinition.class.getName()))
                    .collect(Collectors.toList());
        } else {
            return;
        }

        if (javaType.getSyntaxErrors() == null || javaType.getSyntaxErrors().isEmpty()) {
            for (Annotation comparatorDefinition : comparatorDefinitions) {
                Annotation[] fieldPathDefinitions = comparatorDefinition.getAnnotationArrayValue("objectPropertyPaths");

                String previousFullyQualifiedClassname = null;

                if (fieldPathDefinitions != null) {
                    for (Annotation fieldPathDefinition : fieldPathDefinitions) {
                        Annotation[] fieldDefinitions = fieldPathDefinition.getAnnotationArrayValue("objectProperties");

                        if (fieldDefinitions != null && fieldDefinitions.length > 0) {

                            previousFullyQualifiedClassname = fieldDefinitions[0].getStringValue("type");

                            if (previousFullyQualifiedClassname != null && previousFullyQualifiedClassname.matches("\\w[\\.\\w]+\\.class")) {
                                for (int i = 1; i < fieldDefinitions.length; i++) {
                                    ResourceReference resourceReference = new ResourceReference(previousFullyQualifiedClassname.substring(0,
                                                                                                                                          previousFullyQualifiedClassname.indexOf(".class")),
                                                                                                ResourceType.JAVA);
                                    resourceReference.addPartReference(fieldDefinitions[i].getStringValue("name"),
                                                                       PartType.FIELD);

                                    previousFullyQualifiedClassname = fieldDefinitions[i].getStringValue("type");

                                    builder.addGenerator(resourceReference);
                                }
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        logger.error("Unable to index comparator definition for " + javaType.getQualifiedName());
    }
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:65,代码来源:ComparatorDefinitionIndexerExtension.java

示例3: accept

import org.jboss.forge.roaster.model.JavaType; //导入方法依赖的package包/类
@Override
public boolean accept(JavaType<?> javaType) {
    return javaType.isClass() && (javaType.getAnnotation(Generated.class.getName()) != null)
            && (javaType.getAnnotation(ComparatorDefinition.class.getName()) != null)
            && ((JavaClass) javaType).getInterfaces().stream().anyMatch(s -> s.startsWith(Comparator.class.getName()));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:7,代码来源:PlannerNestedClassFilter.java


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