@Override public JDocComment apply(ApiResourceMetadata controllerMetadata, JDefinedClass generatableType) { String comments = "No description"; if (controllerMetadata.getDescription() != null) { comments = controllerMetadata.getDescription(); } generatableType.javadoc().append(comments); generatableType.javadoc().append("\n(Generated with springmvc-raml-parser v." + CodeModelHelper.getVersion() + ")"); return generatableType.javadoc(); } }
public AbstractBuilder withClassComment(String classComment) { pojoCreationCheck(); JDocComment javadoc = this.pojo.javadoc(); // javadoc.add javadoc.add(toJavaComment(classComment)); javadoc.add("\n\nGenerated using springmvc-raml-plugin on " + new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(new Date())); return this; }
/** * Extract documentation from a WADL resource and add it to a corresponding * generated class. * * @param r the WADL resource. * @param c the corresponding class. */ public void generateClassDoc(ResourceNode r, JDefinedClass c) { if (r.getDoc().size() < 1) return; Doc d = r.getDoc().get(0); JDocComment jdoc = c.javadoc(); appendTextContent(d, jdoc); }
/** * Extract documentation from a WADL resource type and add it to a corresponding * generated interface. * * @param n the WADL resource type. * @param iface the corresponding interface. */ void generateClassDoc(ResourceTypeNode n, JDefinedClass iface) { if (n.getDoc().size() < 1) return; Doc d = n.getDoc().get(0); JDocComment jdoc = iface.javadoc(); appendTextContent(d, jdoc); }
/** * Extract documentation from a WADL param with enumerated values and add it to the corresponding * Java enum. * * @param p the WADL param. * @param e the corresponding enum. */ public void generateEnumDoc(Param p, JDefinedClass e) { if (p.getDoc().size() < 1) return; Doc d = p.getDoc().get(0); JDocComment jdoc = e.javadoc(); appendTextContent(d, jdoc); }
private static void generateClassJavadoc(JDefinedClass clazz, RecordTemplate schema) { final String doc = schema.data().getString("doc"); if (doc != null) { clazz.javadoc().append(doc); } }
protected void addJavadocs() { JDocComment c = definedClass.javadoc(); c.add("<pre>\n"); for (Iterator<SmiNamedNumber> iterator = type.getNamedNumbers().iterator(); iterator.hasNext(); ) { SmiNamedNumber namedNumber = iterator.next(); c.add(namedNumber.toString()); if (iterator.hasNext()) { c.add(","); } c.add("\n"); } c.add("</pre>\n"); }
@NotNull private JDefinedClass createAnonListClass(JFieldVar field, ClassOutline classOutline) { JDefinedClass anonymous; try { CPropertyInfo propertyInfo = classOutline.target.getProperty(field.name()); anonymous = classOutline.implClass._class(JMod.PRIVATE | JMod.STATIC, "Anon" + propertyInfo.getName(true)); JDocComment comment = anonymous.javadoc(); comment.append("TODO Can't be anonymous because of NPE bug in CodeModel generator, will be fixed later."); } catch (JClassAlreadyExistsException ex) { throw new RuntimeException(ex.getMessage(), ex); } return anonymous; }
private JDefinedClass createCustomHttpMethodAnnotation(final String httpMethod) throws JClassAlreadyExistsException { final JPackage pkg = codeModel._package(getSupportPackage()); final JDefinedClass annotationClazz = pkg._annotationTypeDeclaration(httpMethod); annotationClazz.annotate(Target.class).param("value", ElementType.METHOD); annotationClazz.annotate(Retention.class).param("value", RetentionPolicy.RUNTIME); annotationClazz.annotate(HttpMethod.class).param("value", httpMethod); annotationClazz.javadoc().add("Custom JAX-RS support for HTTP " + httpMethod + "."); httpMethodAnnotations.put(httpMethod.toUpperCase(), annotationClazz); return annotationClazz; }
private JDefinedClass createCustomHttpMethodAnnotation(final String httpMethod) throws JClassAlreadyExistsException { final JPackage pkg = codeModel._package(getSupportPackage()); final JDefinedClass annotationClazz = pkg._annotationTypeDeclaration(httpMethod); annotationClazz.annotate(Target.class).param("value", ElementType.METHOD); annotationClazz.annotate(Retention.class).param("value", RetentionPolicy.RUNTIME); annotationClazz.annotate(HttpMethod.class).param("value", httpMethod); annotationClazz.javadoc().add("Custom JAX-RS support for HTTP " + httpMethod + "."); httpMethodAnnotations.put(httpMethod.toUpperCase(), annotationClazz); return annotationClazz; }
/** * Generates the minimum {@link JDefinedClass} skeleton * without filling in its body. */ private EnumOutline generateEnumDef(CEnumLeafInfo e) { JDefinedClass type; type = getClassFactory().createClass( getContainer(e.parent, EXPOSED),e.shortName,e.getLocator(), ClassType.ENUM); type.javadoc().append(e.javadoc); return new EnumOutline(e, type) { @Override public @NotNull Outline parent() { return BeanGenerator.this; } }; }
/** * Generates the minimum {@link JDefinedClass} skeleton * without filling in its body. */ private EnumOutline generateEnumDef(CEnumLeafInfo e) { JDefinedClass type; type = getClassFactory().createClass( getContainer(e.parent, EXPOSED),e.shortName,e.getLocator(), ClassType.ENUM); type.javadoc().append(e.javadoc); return new EnumOutline(e, type) { @Override public @NotNull Outline parent() { return BeanGenerator.this; } }; }
/** * Generates the minimum {@link JDefinedClass} skeleton * without filling in its body. */ private EnumOutline generateEnumDef(CEnumLeafInfo e) { JDefinedClass type; type = getClassFactory().createClass( getContainer(e.parent, EXPOSED), e.shortName, e.getLocator(), ClassType.ENUM); type.javadoc().append(e.javadoc); return new EnumOutline(e, type) { @Override public @NotNull Outline parent() { return BeanGenerator.this; } }; }
/** * Generates the minimum {@link JDefinedClass} skeleton * without filling in its body. */ private EnumOutline generateEnumDef(CEnumLeafInfo e) { JDefinedClass type; type = getClassFactory().createClass( getContainer(e.parent, EXPOSED), e.shortName, e.getLocator(), ClassType.ENUM); type.javadoc().append(e.javadoc); return new EnumOutline(e, type) { @Override public @NotNull Outline parent() { return BeanGenerator.this; } }; }
/** * Javadoc setup. */ @RequiredArgsConstructor private enum JavaDocs { DOCS_TOP_CLASS("top_class"), DOCS_CONSTRUCTOR("constructor"); private static final String JAVADOC_DIR = "arbitrary-action-builder-procreator"; private final String name; String fillTemplate(final Object... params) { return String.format(JavadocUtils.getTemplateString(JAVADOC_DIR, name), params); } }
private void renderElementsClass(JDefinedClass classModel, List<FieldModel> fields) throws Exception { // define constants class JDefinedClass elementsClass = classModel._class(JMod.STATIC, Util.ELEMENTS_CLASS_NAME); // generate the javadoc on the top of the Elements class JDocComment javadoc = elementsClass.javadoc(); javadoc.append(Util.ELEMENTS_CLASS_JAVADOC); // go through each field and create a corresponding constant for (FieldModel fieldModel : fields) { if (Util.isCommonElement(fieldModel.fieldName)) { continue; } JFieldVar elementFieldVar = elementsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.toConstantsVariable(fieldModel.fieldName)); elementFieldVar.init(JExpr.lit(fieldModel.fieldName)); } }
protected void createResourceInterface(final Resource resource) throws Exception { final String resourceInterfaceName = Names.buildResourceInterfaceName(resource); final JDefinedClass resourceInterface = context.createResourceInterface(resourceInterfaceName); context.setCurrentResourceInterface(resourceInterface); final String path = strip(resource.getRelativeUri(), "/"); resourceInterface.annotate(Path.class).param(DEFAULT_ANNOTATION_PARAMETER, StringUtils.defaultIfBlank(path, "/")); if (isNotBlank(resource.getDescription())) { resourceInterface.javadoc().add(resource.getDescription()); } addResourceMethods(resource, resourceInterface, path); }
public JDefinedClass addEntity(final BusinessObject bo) throws JClassAlreadyExistsException { final String qualifiedName = bo.getQualifiedName(); validateClassNotExistsInRuntime(qualifiedName); JDefinedClass entityClass = codeGenerator.addClass(qualifiedName); entityClass = codeGenerator.addInterface(entityClass, org.bonitasoft.engine.bdm.Entity.class.getName()); entityClass.javadoc().add(bo.getDescription()); final JAnnotationUse entityAnnotation = codeGenerator.addAnnotation(entityClass, Entity.class); entityAnnotation.param("name", entityClass.name()); addIndexAnnotations(bo, entityClass); addUniqueConstraintAnnotations(bo, entityClass); addQueriesAnnotation(bo, entityClass); addFieldsAndMethods(bo, entityClass); codeGenerator.addDefaultConstructor(entityClass); return entityClass; }
public JDefinedClass addEntity(final BusinessObject bo) throws JClassAlreadyExistsException { final String qualifiedName = bo.getQualifiedName(); validateClassNotExistsInRuntime(qualifiedName); JDefinedClass entityClass = codeGenerator.addClass(qualifiedName); entityClass = codeGenerator.addInterface(entityClass, org.bonitasoft.engine.bdm.Entity.class.getName()); entityClass.javadoc().add(bo.getDescription()); final JAnnotationUse entityAnnotation = codeGenerator.addAnnotation(entityClass, Entity.class); entityAnnotation.param("name", entityClass.name()); addIndexAnnotations(bo, entityClass); addUniqueConstraintAnnotations(bo, entityClass); addQueriesAnnotation(bo, entityClass); addFieldsAndMethods(bo, entityClass); codeGenerator.addDefaultConstructor(entityClass); return entityClass; }
private void renderConstantsClass(JDefinedClass classModel) throws Exception { // define constants class JDefinedClass constantsClass = classModel._class(JMod.STATIC, Util.CONSTANTS_CLASS_NAME); // generate the javadoc on the top of the Constants class JDocComment javadoc = constantsClass.javadoc(); javadoc.append(Util.CONSTANTS_CLASS_JAVADOC); // render root element name JFieldVar rootElementField = constantsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.ROOT_ELEMENT_NAME_FIELD); rootElementField.init(JExpr.lit(Util.toLowerCaseFirstLetter(classModel.name()))); // render type name JFieldVar typeNameField = constantsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.TYPE_NAME_FIELD); typeNameField.init(JExpr.lit(classModel.name() + Util.TYPE_NAME_SUFFIX)); }