本文整理汇总了Java中org.codehaus.groovy.ast.AnnotatedNode.addAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedNode.addAnnotation方法的具体用法?Java AnnotatedNode.addAnnotation怎么用?Java AnnotatedNode.addAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.AnnotatedNode
的用法示例。
在下文中一共展示了AnnotatedNode.addAnnotation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAnnotation
import org.codehaus.groovy.ast.AnnotatedNode; //导入方法依赖的package包/类
private AnnotationNode getAnnotation(AnnotatedNode annotated) {
List<AnnotationNode> annotations = annotated.getAnnotations(BOM);
if (!annotations.isEmpty()) {
return annotations.get(0);
}
AnnotationNode annotation = new AnnotationNode(BOM);
annotated.addAnnotation(annotation);
return annotation;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:GenericBomAstTransformation.java
示例2: attachGroovydocAnnotation
import org.codehaus.groovy.ast.AnnotatedNode; //导入方法依赖的package包/类
private void attachGroovydocAnnotation(ASTNode node, String docCommentNodeText) {
if (!(node instanceof AnnotatedNode)) {
return;
}
if (!(ATTACHING_RUNTIME_GROOVYDOC_ENABLED || docCommentNodeText.matches(RUNTIME_GROOVYDOC_PATTERN))) {
return;
}
AnnotatedNode annotatedNode = (AnnotatedNode) node;
AnnotationNode annotationNode = new AnnotationNode(ClassHelper.make(Groovydoc.class));
annotationNode.addMember(VALUE, new ConstantExpression(docCommentNodeText));
annotatedNode.addAnnotation(annotationNode);
}
示例3: checkForDuplicateAnnotations
import org.codehaus.groovy.ast.AnnotatedNode; //导入方法依赖的package包/类
private void checkForDuplicateAnnotations(AnnotatedNode node, Map<String, List<AnnotationNode>> runtimeAnnotations) {
for (Map.Entry<String, List<AnnotationNode>> next : runtimeAnnotations.entrySet()) {
if (next.getValue().size() > 1) {
ClassNode repeatable = null;
AnnotationNode repeatee = next.getValue().get(0);
List<AnnotationNode> repeateeAnnotations = repeatee.getClassNode().getAnnotations();
for (AnnotationNode anno : repeateeAnnotations) {
ClassNode annoClassNode = anno.getClassNode();
if (annoClassNode.getName().equals("java.lang.annotation.Repeatable")) {
Expression value = anno.getMember("value");
if (value instanceof ClassExpression) {
ClassExpression ce = (ClassExpression) value;
if (ce.getType() != null && ce.getType().isAnnotationDefinition()) {
repeatable = ce.getType();
break;
}
}
}
}
if (repeatable != null) {
AnnotationNode collector = new AnnotationNode(repeatable);
collector.setRuntimeRetention(true); // checked earlier
List<Expression> annos = new ArrayList<Expression>();
for (AnnotationNode an : next.getValue()) {
annos.add(new AnnotationConstantExpression(an));
}
collector.addMember("value", new ListExpression(annos));
node.addAnnotation(collector);
node.getAnnotations().removeAll(next.getValue());
}
}
}
}
示例4: setAnnotationMetaData
import org.codehaus.groovy.ast.AnnotatedNode; //导入方法依赖的package包/类
private void setAnnotationMetaData(Annotation[] annotations, AnnotatedNode an) {
for (Annotation annotation : annotations) {
AnnotationNode node = new AnnotationNode(ClassHelper.make(annotation.annotationType()));
configureAnnotation(node, annotation);
an.addAnnotation(node);
}
}
示例5: visitAnnotations
import org.codehaus.groovy.ast.AnnotatedNode; //导入方法依赖的package包/类
@Override
public void visitAnnotations(AnnotatedNode node) {
super.visitAnnotations(node);
List<AnnotationNode> annotations = node.getAnnotations(DELEGATES_TO_RW_TYPE);
if (annotations.isEmpty()) return;
ClassExpression targetValue = (ClassExpression) annotations.get(0).getMember("value");
ClassNode target = targetValue != null ? targetValue.getType() : model;
if (!isDSLObject(target)) {
addError(target + " is no DSL object.", targetValue);
return;
}
AnnotationNode delegatesTo = createDelegatesToAnnotation(target);
node.addAnnotation(delegatesTo);
}