10 Replies Latest reply on Sep 27, 2017 2:53 PM by gariklolkin

    Is there a way to create annotation with array of annotations?

    ondrejz

      I created Annotation like:

      public @interface Caller {

       

        Class clazz();

         String method();
      }

       

      and then I want to make array of this Annotation:

       

      public @interface Callers {

       

         Caller[] value();
      }

       

      so is there a way how to apply it for some method using Roaster?

       

      I want to create this: @Callers({@Caller(clazz = ComprehensionTool.class, method = "method"), @Caller(clazz = AnalyseProcessor.class, method = "someOtherMethod")}).

       

      so I need something like:

      List<AnnotationSource> annotations = new ArrayList<>();

      annotations.add(new AnnotationSource("Caller").setClassValue("clazz", ComprehensionTool.class).setStringValue("method", "method"));

      annotations.add(new AnnotationSource("Caller").setClassValue("clazz", AnalyseProcessor.class,).setStringValue("method", "someOtherMethod"));

       

      //just add annotationArray

      method.addAnnotation("Callers").setAnnotationArray(annotations);

       

       

      I thank you for every help guys.