Beispiel #1
0
 public static void addAnnotationIfNecessary(
     ClassNode classNode, @SuppressWarnings("unused") Class<Entity> entityClass) {
   List<AnnotationNode> annotations = classNode.getAnnotations();
   ClassNode annotationClassNode = new ClassNode(Entity.class);
   AnnotationNode annotationToAdd = new AnnotationNode(annotationClassNode);
   if (annotations.isEmpty()) {
     classNode.addAnnotation(annotationToAdd);
   } else {
     boolean foundAnn = findAnnotation(annotationClassNode, annotations) != null;
     if (!foundAnn) classNode.addAnnotation(annotationToAdd);
   }
 }
  @Test
  public void transformationOfAnnotationOnClass() {
    ClassNode classNode = new ClassNode("Test", 0, new ClassNode(Object.class));
    classNode.addAnnotation(this.grabAnnotation);
    this.moduleNode.addClass(classNode);

    assertGrabAnnotationHasBeenTransformed();
  }