package org.infinispan.protostream.annotations.impl;

import java.lang.reflect.AnnotatedElement;

import org.infinispan.protostream.annotations.ProtoDoc;

/**
 * @author anistor@redhat.com
 * @since 3.0
 */
final class DocumentationExtractor {

   /**
    * Collect and concatenate the description text from the ProtoDoc.value of the given elements.
    */
   public static String getDocumentation(AnnotatedElement... elements) {
      StringBuilder sb = null;

      for (AnnotatedElement element : elements) {
         for (ProtoDoc docAnnotation : element.getAnnotationsByType(ProtoDoc.class)) {
            if (docAnnotation != null && !docAnnotation.value().isEmpty()) {
               if (sb == null) {
                  sb = new StringBuilder();
               } else {
                  sb.append('\n');
               }
               sb.append(docAnnotation.value());
            }
         }
      }

      return sb == null ? null : sb.toString();
   }
}

@@ -305,16 +305,24 @@
 rom the 
+%7B@code @
 ProtoDoc
@@ -327,16 +327,17 @@
 oc.value
+%7D
  of the 
@@ -420,101 +420,481 @@
 ment
-... elements) %7B%0A      StringBuilder sb = null;%0A%0A      for (AnnotatedElement e
+ element1, AnnotatedElement element2) %7B%0A      String doc1 = getDocumentation(element1);%0A      String doc2 = getDocumentation(element2);%0A%0A      if (doc1 == null) %7B%0A         return doc2;%0A      %7D%0A      if (doc2 == null) %7B%0A         return doc1;%0A      %7D%0A      return doc1 + '%5Cn' + doc2;%0A   %7D%0A%0A   /**%0A    * Collect and concatenate the description text from the %7B@code @ProtoDoc.value%7D of the given element.%0A    */%0A   public static String getDocumentation(AnnotatedE
 lement
- :
  element
 s) %7B
@@ -893,16 +893,44 @@
 ment
-s
 ) %7B%0A   
+   StringBuilder sb = null;%0A%0A
     
@@ -1022,40 +1022,12 @@
     
-   
 if (
-docAnnotation != null && 
 !doc
@@ -1066,27 +1066,24 @@
             
- 
-  
 if (sb == nu
@@ -1084,27 +1084,24 @@
  == null) %7B%0A
-   
             
@@ -1129,19 +1129,16 @@
 lder();%0A
-   
         
@@ -1157,35 +1157,32 @@
 %0A               
-   
 sb.append('%5Cn');
@@ -1190,31 +1190,26 @@
             
-   %7D%0A  
+%7D%0A
             
@@ -1200,33 +1200,32 @@
   %7D%0A            
- 
 sb.append(docAnn
@@ -1242,30 +1242,16 @@
 lue());%0A
-            %7D%0A
         

Refactor DocumentationExtractor to avoid creation of vararg arrays at invocation