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