private void annotationTypes(RamlDocumentBuilder builder, RamlApi modelApi) throws IOException { for (RamlSupportedAnnotation ramlSupportedAnnotation : modelApi.getSupportedAnnotation()) { AnnotationTypeBuilder annotationTypeBuilder = AnnotationTypeBuilder.annotationType(ramlSupportedAnnotation.getAnnotation().getSimpleName()); Class<? extends Annotation> javaAnnotation = ramlSupportedAnnotation.getAnnotation(); if (javaAnnotation.getDeclaredMethods().length > 0) { for (Method method : javaAnnotation.getDeclaredMethods()) { if (method.getReturnType().isArray()) { annotationTypeBuilder.withProperty(property(method.getName(), calculateRamlType(method.getReturnType() .getComponentType()) + "[]")); } else { annotationTypeBuilder.withProperty(property(method.getName(), calculateRamlType(method.getReturnType()) )); } } builder.withAnnotationTypes(annotationTypeBuilder); } } }
public void emitAnnotations() throws IOException { writer.appendLine("annotationTypes:"); writer.indent(); for (RamlSupportedAnnotation ramlSupportedAnnotation : suportedAnnotations) { Class<? extends Annotation> javaAnnotation = ramlSupportedAnnotation.getAnnotation(); if (javaAnnotation.getDeclaredMethods().length > 0) { writer.appendLine(javaAnnotation.getSimpleName() + ":"); writer.indent(); writer.appendLine("properties:"); writer.indent(); for (Method method : javaAnnotation.getDeclaredMethods()) { if (method.getReturnType().isArray()) { writer.appendLine(method.getName() + ": " + calculateRamlType(method.getReturnType().getComponentType()) + "[]"); } else { writer.appendLine(method.getName() + ": " + calculateRamlType(method.getReturnType())); } } writer.outdent(); writer.outdent(); } else { writer.appendLine(javaAnnotation.getSimpleName() + ": nil"); } } writer.outdent(); }