private void processNestedType(
     String prefix,
     TypeElement element,
     ExecutableElement source,
     String name,
     ExecutableElement getter,
     VariableElement field,
     TypeMirror returnType) {
   Element returnElement = this.processingEnv.getTypeUtils().asElement(returnType);
   boolean isNested = isNested(returnElement, field, element);
   AnnotationMirror annotation = getAnnotation(getter, configurationPropertiesAnnotation());
   if (returnElement != null
       && returnElement instanceof TypeElement
       && annotation == null
       && isNested) {
     String nestedPrefix = ConfigurationMetadata.nestedPrefix(prefix, name);
     this.metadataCollector.add(
         ItemMetadata.newGroup(
             nestedPrefix,
             this.typeUtils.getType(returnElement),
             this.typeUtils.getType(element),
             (getter == null ? null : getter.toString())));
     processTypeElement(nestedPrefix, (TypeElement) returnElement, source);
   }
 }
Example #2
0
 @Override
 public void printErrorCheckMethod(
     final PrintWriter writer, final ExecutableElement method, final String tabs) {
   final Check check = method.getAnnotation(Check.class);
   if (check != null) // Get the error code from an IntBuffer output parameter
   writer.println(
         tabs + "Util.checkCLError(" + check.value() + ".get(" + check.value() + ".position()));");
   else {
     final Class return_type = Utils.getJavaType(method.getReturnType());
     if (return_type == int.class) writer.println(tabs + "Util.checkCLError(__result);");
     else {
       boolean hasErrCodeParam = false;
       for (final VariableElement param : method.getParameters()) {
         if ("errcode_ret".equals(param.getSimpleName().toString())
             && Utils.getJavaType(param.asType()) == IntBuffer.class) {
           hasErrCodeParam = true;
           break;
         }
       }
       if (hasErrCodeParam)
         throw new RuntimeException(
             "A method is missing the @Check annotation: " + method.toString());
     }
   }
 }
 private void processExecutableElement(String prefix, ExecutableElement element) {
   if (element.getModifiers().contains(Modifier.PUBLIC)
       && (TypeKind.VOID != element.getReturnType().getKind())) {
     Element returns = this.processingEnv.getTypeUtils().asElement(element.getReturnType());
     if (returns instanceof TypeElement) {
       ItemMetadata group =
           ItemMetadata.newGroup(
               prefix,
               this.typeUtils.getType(returns),
               this.typeUtils.getType(element.getEnclosingElement()),
               element.toString());
       if (this.metadataCollector.hasSimilarGroup(group)) {
         this.processingEnv
             .getMessager()
             .printMessage(
                 Kind.ERROR,
                 "Duplicate `@ConfigurationProperties` definition for prefix '" + prefix + "'",
                 element);
       } else {
         this.metadataCollector.add(group);
         processTypeElement(prefix, (TypeElement) returns, element);
       }
     }
   }
 }