/** * Applies this schema rule to take the required code generation steps. * <p> * When a title node is found and applied with this rule, the value of the * title is added as a JavaDoc comment. This rule is typically applied to * the generated field, generated getter and generated setter for the * property. * <p> * Note that the title is always inserted at the top of the JavaDoc comment. * * @param nodeName * the name of the property to which this title applies * @param node * the "title" schema node * @param parent * the parent node * @param generatableType * comment-able code generation construct, usually a field or * method, which should have this title applied * @return the JavaDoc comment created to contain the title */ @Override public JDocComment apply(String nodeName, JsonNode node, JsonNode parent, JDocCommentable generatableType, Schema schema) { JDocComment javadoc = generatableType.javadoc(); javadoc.add(0, node.asText() + "\n<p>\n"); return javadoc; }
noargsConstructor.javadoc().add("No args constructor for use in serialization");
private JMethod generateGetterMethod(JFieldVar field, String fieldName, JExpression defaultValue) { String javaName = NamingHelper.convertToClassName(fieldName); // Add get method JMethod getter = this.pojo.method(JMod.PUBLIC, field.type(), "get" + javaName); if (defaultValue != null) { JBlock body = getter.body(); body._if(field.eq(JExpr._null()))._then()._return(defaultValue); } getter.body()._return(field); getter.javadoc().add("Returns the " + fieldName + "."); getter.javadoc().addReturn().add(field.name()); return getter; }
public JDocComment append(Object o) { add(o); return this; }
public JDocComment append(Object o) { add(o); return this; }
public JDocComment append(Object o) { add(o); return this; }
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"); }
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; }
private JDocComment addBaseJavaDoc(final Action action, final JMethod method) { final JDocComment javadoc = method.javadoc(); if (isNotBlank(action.getDescription())) { javadoc.add(action.getDescription()); } return javadoc; }
private void withDefaultConstructor(String className) { // Create default constructor JMethod constructor = this.pojo.constructor(JMod.PUBLIC); constructor.javadoc().add("Creates a new " + className + "."); JBlock defaultConstructorBody = constructor.body(); defaultConstructorBody.invoke("super"); }
@Override public void visit(Service service) throws Exception { String jd = model.getJavaDoc(); if(jd != null){ JPackage pkg = cm._package(options.defaultPackage); pkg.javadoc().add(jd); } for(Port p:service.getPorts()){ visitPort(service, p); } }
@Override public void visit(Service service) throws Exception { String jd = model.getJavaDoc(); if(jd != null){ JPackage pkg = cm._package(options.defaultPackage); pkg.javadoc().add(jd); } for(Port p:service.getPorts()){ visitPort(service, p); } }
@Override public void visit(Service service) throws Exception { String jd = model.getJavaDoc(); if(jd != null){ JPackage pkg = cm._package(options.defaultPackage); pkg.javadoc().add(jd); } for(Port p:service.getPorts()){ visitPort(service, p); } }
@Override public void visit(Service service) throws Exception { String jd = model.getJavaDoc(); if(jd != null){ JPackage pkg = cm._package(options.defaultPackage); pkg.javadoc().add(jd); } for(Port p:service.getPorts()){ visitPort(service, p); } }
private void renderPrivateJaxbConstructor(JDefinedClass classModel, List<FieldModel> fields) { JMethod method = classModel.constructor(JMod.PRIVATE); JBlock body = method.body(); for (FieldModel fieldModel : fields) { body.directStatement("this." + fieldModel.fieldName + " = " + getInitString(fieldModel.fieldType) + ";"); } method.javadoc().add("Private constructor used only by JAXB."); }
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 JMethod generateStandardConstructor( final ClassOutline clazz ) { final JMethod ctor = clazz.implClass.constructor( JMod.PUBLIC ); ctor.body().directStatement( "// " + getMessage( "title" ) ); ctor.body().invoke( "super" ); ctor.javadoc().add( "Creates a new {@code " + clazz.implClass.name() + "} instance." ); this.constructorCount = this.constructorCount.add( BigInteger.ONE ); return ctor; }
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; }
protected void addEnumConstants() { // TODO optionally add an ILLEGAL_VALUE constant, which could be returned from the findValue() method for (SmiNamedNumber namedNumber : type.getNamedNumbers()) { JEnumConstant ec = definedClass.enumConstant(namedNumber.getCodeId()); ec.arg(JExpr.lit(namedNumber.getId())); ec.arg(JExpr.lit(namedNumber.getValue().intValue())); ec.javadoc().add("<pre>" + namedNumber.toString() + "</pre>"); } }
private void generateDefinitions() throws Exception { JDefinedClass defs = cm._class(codecPackagePrefix + ".Definitions", ClassType.INTERFACE); Log.info("Creating %s", defs.binaryName()); for ( Definition def : definitions ) { Log.info("Adding field %s with value %s", def.getName(), def.getValue()); JFieldVar field = defs.field(JMod.PUBLIC | JMod.STATIC, java.lang.String.class, toStaticName(def.getName()), JExpr.lit(def.getValue())); field.javadoc().add(def.getLabel()); } }