private static Optional<String> extractMethodJavadoc(Method method, MethodHolder<?> parsed) { final String methodName = method.getName(); List<? extends org.jboss.forge.roaster.model.Method<?, ?>> methods = parsed.getMethods(); for (org.jboss.forge.roaster.model.Method<?, ?> parsedMethod : methods) { if (parsedMethod.getName().equals(methodName)) { if (!(parsedMethod instanceof MethodSource)) { logger.warn("unexpected method type: {}", parsedMethod.getClass()); return Optional.absent(); } MethodSource methodSource = (MethodSource) parsedMethod; return javadocToContent(methodSource.getJavaDoc()); } } logger.warn("could not find method {} in parsed methods: {}", method, Joiners .squareBracketsSameLineJoiner().join(methods)); return Optional.absent(); }
private static Optional<String> extractMethodJavadoc(Method method, MethodHolder<?> parsed) { final String methodName = method.getName(); List<? extends org.jboss.forge.roaster.model.Method<?, ?>> methods = parsed.getMethods(); for (org.jboss.forge.roaster.model.Method<?, ?> parsedMethod : methods) { if (parsedMethod.getName().equals(methodName)) { if (!(parsedMethod instanceof MethodSource)) { logger.warn("unexpected method type: {}", parsedMethod.getClass()); return Optional.absent(); } MethodSource methodSource = (MethodSource) parsedMethod; return javadocToContent(methodSource.getJavaDoc()); } } logger.warn("could not find method {} in parsed methods: {}", method, Joiners .squareBracketsSameLineJoiner().join(methods)); return Optional.absent(); }
private static Optional<String> extractMethodJavadoc(Method method, MethodHolder<?> parsed) { final String methodName = method.getName(); List<? extends org.jboss.forge.roaster.model.Method<?, ?>> methods = parsed.getMethods(); for (org.jboss.forge.roaster.model.Method<?, ?> parsedMethod : methods) { if (parsedMethod.getName().equals(methodName)) { if (!(parsedMethod instanceof MethodSource)) { logger.warn("unexpected method type: {}", parsedMethod.getClass()); return Optional.absent(); } MethodSource methodSource = (MethodSource) parsedMethod; return javadocToContent(methodSource.getJavaDoc()); } } logger.warn("could not find method {} in parsed methods: {}", method, Joiners .squareBracketsSameLineJoiner().join(methods)); return Optional.absent(); }
.setBody(body.toString()) .setReturnTypeVoid(); method.getJavaDoc().setFullText("{@inheritDoc}"); method.addAnnotation(Override.class);
private void writeMapRemove(final JavaClassSource javaClass, final Property propDef) { final String name = "remove" + propDef.getPropertyName(); if (!javaClass.hasMethodSignature(name)) { final StringBuilder javadoc = new StringBuilder(); javadoc .append("@return the pSourcePath\n"); String body = ""; javaClass.addImport("javafx.collections.FXCollections"); body = Templates.use(TemplateName.PropertyRemoveMap, propDef); final MethodSource<?> method = javaClass.addMethod() .setName(name) .setPublic() .setBody(body.toString()) .setReturnType(javaClass.getTypeVariables().isEmpty() ? javaClass.getName() : javaClass.getTypeVariables().get(0).getName()); method.getJavaDoc().setFullText(javadoc.toString()); } else { // javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody() // + body.toString()); } }
private void writeMapPut(final JavaClassSource javaClass, final Property propDef) { final String name = "put" + propDef.getPropertyName(); if (!javaClass.hasMethodSignature(name)) { final StringBuilder javadoc = new StringBuilder(); javadoc .append("@return the pSourcePath\n"); String body = ""; javaClass.addImport("javafx.collections.FXCollections"); body = Templates.use(TemplateName.PropertyPutMap, propDef); final MethodSource<?> method = javaClass.addMethod() .setName(name) .setPublic() .setBody(body.toString()) .setReturnType(javaClass.getTypeVariables().isEmpty() ? javaClass.getName() : javaClass.getTypeVariables().get(0).getName()); method.getJavaDoc().setFullText(javadoc.toString()); } else { // javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody() // + body.toString()); } }
private void writeCreator(final JavaClassSource javaClass, final Class beanDef) { if (!beanDef.isAbstract() && !javaClass.hasMethodSignature("create")) { final StringBuilder javadoc = new StringBuilder(); javadoc .append("Build a new instance of {@link ").append(beanDef.name()).append("}."); final String body = Templates.use(TemplateName.Creator, beanDef); final MethodSource<?> method = javaClass.addMethod() .setName("of") .setPublic() .setStatic(true) .setBody(body) .setReturnType(beanDef.qualifiedName()); method.getJavaDoc().setFullText(javadoc.toString()) .addTagValue("@return", "a fresh instance"); } else { // javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody() // + body.toString()); } }
private void writeListRemove(final JavaClassSource javaClass, final Property propDef) { final String name = "remove" + propDef.getUpperName(); if (!javaClass.hasMethodSignature(name)) { final StringBuilder javadoc = new StringBuilder(); javadoc .append("@return the pSourcePath\n"); String body = ""; javaClass.addImport("javafx.collections.FXCollections"); javaClass.addImport("java.util.Arrays"); body = Templates.use(TemplateName.PropertyRemoveList, propDef); final MethodSource<?> method = javaClass.addMethod() .setName(name) .setPublic() .setBody(body.toString()) .setReturnType(javaClass.getTypeVariables().isEmpty() ? javaClass.getName() : javaClass.getTypeVariables().get(0).getName()); method.addParameter(propDef.subtype(), propDef.name()).setVarArgs(true); method.getJavaDoc().setFullText(javadoc.toString()); } else { // javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody() // + body.toString()); } }
private void writeListAdd(final JavaClassSource javaClass, final Property propDef) { final String name = "add" + propDef.getUpperName(); if (!javaClass.hasMethodSignature(name)) { final StringBuilder javadoc = new StringBuilder(); javadoc .append("@return the pSourcePath\n"); String body = ""; javaClass.addImport("javafx.collections.FXCollections"); javaClass.addImport("java.util.Arrays"); body = Templates.use(TemplateName.PropertyAddList, propDef); final MethodSource<?> method = javaClass.addMethod() .setName(name) .setPublic() .setBody(body.toString()) .setReturnType(javaClass.getTypeVariables().isEmpty() ? javaClass.getName() : javaClass.getTypeVariables().get(0).getName()); method.addParameter(propDef.subtype(), propDef.name()).setVarArgs(true); method.getJavaDoc().setFullText(javadoc.toString()); } else { // javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody() // + body.toString()); } }
protected void addGet(JavaInterfaceSource type, ClassPlan plan) { final MethodSource<JavaInterfaceSource> method = type.addMethod(); method.getJavaDoc() .setText("Constructed instance of " + plan.getClassName() + " resource") .addTagValue("@return", "The instance"); method.setPublic() .setName("get") .setReturnType(plan.getClassName()); }
protected void addGet(JavaInterfaceSource type, ClassPlan plan) { final MethodSource<JavaInterfaceSource> method = type.addMethod(); method.getJavaDoc() .setText("Constructed instance of " + plan.getClassName() + " resource") .addTagValue("@return", "The instance"); method.setPublic() .setName("get") .setReturnType(plan.getClassName()); }
protected void addAccept(JavaInterfaceSource type, ClassPlan plan) { final MethodSource<JavaInterfaceSource> method = type.addMethod(); method.getJavaDoc() .setText("Configure a pre-constructed instance of " + plan.getClassName() + " resource") .addTagValue("@parameter", "Instance of " + plan.getClassName() + " to configure") .addTagValue("@return", "nothing"); method.addParameter("T", "value"); method.setName("accept") .setReturnType("void"); }
protected void addAccept(JavaInterfaceSource type, ClassPlan plan) { final MethodSource<JavaInterfaceSource> method = type.addMethod(); method.getJavaDoc() .setText("Configure a pre-constructed instance of " + plan.getClassName() + " resource") .addTagValue("@parameter", "Instance of " + plan.getClassName() + " to configure") .addTagValue("@return", "nothing"); method.addParameter("T", "value"); method.setName("accept") .setReturnType("void"); }
.getJavaDoc() .setText("Returns the allowed value for the management model.") .addTagValue("@return", "the allowed model value");
.getJavaDoc() .setText("Returns the allowed value for the management model.") .addTagValue("@return", "the allowed model value");
protected void addPropertyChangeSupport(JavaClassSource type, ClassPlan plan) { // property change listeners type.addField() .setName("pcs") .setType(PropertyChangeSupport.class) .setPrivate(); final MethodSource<JavaClassSource> listenerAdd = type.addMethod(); listenerAdd.getJavaDoc().setText("Adds a property change listener"); listenerAdd.setPublic() .setName("addPropertyChangeListener") .addParameter(PropertyChangeListener.class, "listener"); listenerAdd.setBody("if(null==this.pcs) this.pcs = new PropertyChangeSupport(this);\n" + "this.pcs.addPropertyChangeListener(listener);"); final MethodSource<JavaClassSource> listenerRemove = type.addMethod(); listenerRemove.getJavaDoc().setText("Removes a property change listener"); listenerRemove.setPublic() .setName("removePropertyChangeListener") .addParameter(PropertyChangeListener.class, "listener"); listenerRemove.setBody("if(this.pcs!=null) this.pcs.removePropertyChangeListener(listener);"); }
protected void addPropertyChangeSupport(JavaClassSource type, ClassPlan plan) { // property change listeners type.addField() .setName("pcs") .setType(PropertyChangeSupport.class) .setPrivate(); final MethodSource<JavaClassSource> listenerAdd = type.addMethod(); listenerAdd.getJavaDoc().setText("Adds a property change listener"); listenerAdd.setPublic() .setName("addPropertyChangeListener") .addParameter(PropertyChangeListener.class, "listener"); listenerAdd.setBody("if(null==this.pcs) this.pcs = new PropertyChangeSupport(this);\n" + "this.pcs.addPropertyChangeListener(listener);"); final MethodSource<JavaClassSource> listenerRemove = type.addMethod(); listenerRemove.getJavaDoc().setText("Removes a property change listener"); listenerRemove.setPublic() .setName("removePropertyChangeListener") .addParameter(PropertyChangeListener.class, "listener"); listenerRemove.setBody("if(this.pcs!=null) this.pcs.removePropertyChangeListener(listener);"); }
.setBody(body.toString()) .setReturnType(propDef.getPropertyType()); method.getJavaDoc().setFullText(javadoc.toString());
.setBody(body) .setReturnType(propDef.type().qualifiedName()); method.getJavaDoc().setFullText(javadoc.toString());
accessor.getJavaDoc() .setText(javaDoc); accessor.setPublic() mutator.getJavaDoc() .setText(javaDoc); mutator.addParameter(childClass.getFullyQualifiedClassName(), "value"); consumer.getJavaDoc() .setText(javaDoc); consumer.addParameter(childClass.getClassName() + "Consumer", "consumer"); noConfig.getJavaDoc() .setText(javaDoc); noConfig.setPublic() supplier.getJavaDoc() .setText(javaDoc); supplier.addParameter(childClass.getClassName() + "Supplier", "supplier");