noargsConstructor.javadoc().add("No args constructor for use in serialization"); fieldsConstructor.javadoc().addParam(property); JVar param = fieldsConstructor.param(field.type(), field.name()); constructorBody.assign(JExpr._this().ref(field), param); fieldsConstructor.javadoc().addParam(property); superConstructorParams.add(param);
private void generateBuilderMethodJavadoc(final JMethod method, final String methodPrefix, final String propertyName) { final String endMethodClassName = method.type().erasure().fullName(); method.javadoc().append(MessageFormat.format(this.resources.getString("comment." + methodPrefix + "BuilderMethod"), propertyName, endMethodClassName)) .addReturn().append(MessageFormat.format(this.resources.getString("comment." + methodPrefix + "BuilderMethod.return"), propertyName, endMethodClassName)); }
private void generateAddMethodJavadoc(final JMethod method, final JVar param) { final String propertyName = param.name(); method.javadoc().append(MessageFormat.format(this.resources.getString("comment.addMethod"), propertyName)) .addParam(param).append(MessageFormat.format(this.resources.getString("comment.addMethod.param"), propertyName)); }
private void generateWithMethodJavadoc(final JMethod method, final JVar param) { final String propertyName = param.name(); method.javadoc().append(MessageFormat.format(this.resources.getString("comment.withMethod"), propertyName)) .addParam(param).append(MessageFormat.format(this.resources.getString("comment.withMethod.param"), propertyName)); }
/** * Extract documentation from a WADL resource and add it to a corresponding * accessor method. * * @param r the WADL resource. * @param c the corresponding class. */ public void generateAccessorDoc(ResourceNode r, JMethod 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 method and add it to the corresponding * generated Java method. * * @param m the WADL method. * @param jm the corresponding Java method. */ public void generateMethodDoc(MethodNode m, JMethod jm) { if (m.getDoc().size() < 1) return; Doc d = m.getDoc().get(0); JDocComment jdoc = jm.javadoc(); appendTextContent(d, jdoc); }
private JDocComment addBaseJavaDoc(final Action action, final JMethod method) { final JDocComment javadoc = method.javadoc(); if (isNotBlank(action.getDescription())) { javadoc.add(action.getDescription()); } return javadoc; }
/** * Extract documentation from a WADL representation and add it to the * corresponding Java method return. * @param r the WADL representation * @param jm the corresponding Java method */ public void generateReturnDoc(RepresentationNode r, JMethod jm) { if (r.getDoc().size() < 1) return; Doc d = r.getDoc().get(0); JDocComment jdoc = jm.javadoc(); JCommentPart jp = jdoc.addReturn(); appendTextContent(d, jp); }
@Override public JDocComment apply(ApiActionMetadata endpointMetadata, JMethod generatableType) { String comments = "No description"; if (endpointMetadata.getDescription() != null) { comments = endpointMetadata.getDescription(); } return generatableType.javadoc().append(comments); } }
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"); }
protected JVar paramHttpRequest(CodeModelHelper.JExtMethod generatableType) { JVar paramHttpRequest = generatableType.get().param(HttpServletRequest.class, "httpRequest"); if (addParameterJavadoc) { generatableType.get().javadoc().addParam("httpRequest The HTTP request"); } return paramHttpRequest; }
protected JVar paramHttpHeaders(CodeModelHelper.JExtMethod generatableType) { JVar paramHttpHeaders = generatableType.get().param(HttpHeaders.class, "httpHeaders"); if (addParameterJavadoc) { generatableType.get().javadoc().addParam("httpHeaders The HTTP headers for the request"); } return paramHttpHeaders; }
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 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 void genConstructor(Refs r, JDefinedClass clazz, Collection<Ref> refs, Map<Ref, JFieldVar> fieldVarMap) { // private MyLayoutViewModel(View view) { JMethod constructor = clazz.constructor(PUBLIC); JVar viewVar = constructor.param(r.viewClass, "view"); JBlock body = constructor.body(); // super(view); body.invoke("super").arg(viewVar); // myLinearLayout = (LinearLayout) view.findViewById(R.id.my_linear_layout); // myTextView = (TextView) myLinearLayout.findViewById(R.id.my_text_view); genInitFields(r, fieldVarMap, viewVar, refs, body); JDocComment doc = constructor.javadoc(); doc.append("Constructs a new {@link me.tatarka.socket.Socket} for {@link " + r.packageName + ".R.layout#" + r.layoutName + "}."); doc.addParam(viewVar).append("The root view to search for the socket's views."); }
void generateDefaultConstructor() { final JMethod defaultConstructor = this.classOutline.implClass.constructor( this.classOutline.implClass.isAbstract() ? JMod.PROTECTED : JMod.PUBLIC); defaultConstructor.body().directStatement("// " + getMessage("defaultConstructor.bodyComment")); defaultConstructor.javadoc().append(getMessage("defaultConstructor.javadoc.desc")); }
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; }
private JMethod generateStandardConstructor(final JDefinedClass clazz, FieldOutline[] declaredFields, FieldOutline[] superclassFields) { final JMethod ctor = createConstructor(clazz, JMod.PROTECTED); ctor.javadoc().add("Used by JAX-B"); if (superclassFields.length > 0) { JInvocation superInvocation = ctor.body().invoke("super"); for (FieldOutline fieldOutline : superclassFields) { superInvocation.arg(defaultValue(getJavaType(fieldOutline), fieldOutline)); } } for (FieldOutline fieldOutline : declaredFields) { generateDefaultPropertyAssignment(ctor, fieldOutline); } return ctor; }
private void addToStringMethod(ClassOutline co, JClass delegateImpl, JFieldRef toStringDelegateStyleParam) { final JDefinedClass implementation = co.implClass; final JMethod toStringMethod = implementation.method(JMod.PUBLIC, String.class, "toString"); final JInvocation invoke = delegateImpl.staticInvoke("reflectionToString"); invoke.arg(JExpr._this()); invoke.arg(toStringDelegateStyleParam); toStringMethod.body()._return(invoke); JDocComment doc = toStringMethod.javadoc(); doc.add("Generates a String representation of the contents of this type."); doc.add("\nThis is an extension method, produced by the 'ts' xjc plugin"); toStringMethod.annotate(Override.class); }