protected Javadoc getJavaDoc() { final String owner; final String message; if (isInGeneratedPackage()) { owner = infoComponent.getTitle(); message = getGeneratedJavadocMessage(); } else { owner = project().orElseThrow(NoSuchElementException::new).getCompanyName(); message = JAVADOC_MESSAGE; } return Javadoc.of(getJavadocRepresentText() + message) .add(AUTHOR.setValue(owner)); }
/** * Copy constructor. * * @param prototype the prototype */ protected JavadocImpl(final Javadoc prototype) { text = requireNonNull(prototype).getText(); tags = Copier.copy(prototype.getTags()); imports = Copier.copy(prototype.getImports()); }
.set(Javadoc.of() .setText("Adds the specified " + lcfirst(shortName(param.getType().getTypeName())) + " to this " + shortName(model.getName()) + ".") .add(JavadocTag.of("param", param.getName(), "the new value")) .add(JavadocTag.of("return", "a reference to this object")) ).public_() .add(param) .set(Javadoc.of() .setText("Sets the " + f.getName() + " of this " + shortName(model.getName()) + ".") .add(JavadocTag.of("param", f.getName(), "the new value")) .add(JavadocTag.of("return", "a reference to this object")) ).public_(); .set(Javadoc.of() .setText("Gets the " + f.getName() + " of this " + shortName(model.getName()) + ".") .add(JavadocTag.of("return", "the " + f.getName())) ).public_() .add("return this." + f.getName() + ";");
/** * Add a javadoc tag to the specified documentation block. If the tag is * already defined, this will have no effect. * * @param doc the documentation block * @param tag the tag to add */ private static void addTag(Javadoc doc, JavadocTag tag) { if (!hasTagAlready( requireNonNull(doc), requireNonNull(tag) )) { doc.add(tag); } }
@Override public File set(Javadoc doc) { this.doc = doc.setParent(this); return this; }
/** * Checks if the specified tag is already defined in the supplied * documentation block. * * @param doc the documentation block * @param tag the tag to check * @return {@code true} if it exists, else {@code false} */ private static boolean hasTagAlready(Javadoc doc, JavadocTag tag) { requireNonNull(doc); requireNonNull(tag); return doc.getTags().stream().anyMatch(t -> tag.getName().equals(t.getName()) && tag.getValue().equals(t.getValue()) ); } }
.set(Javadoc.of() .setText("Adds the specified " + lcfirst(shortName(param.getType().getTypeName())) + " to this " + shortName(model.getName()) + ".") .add(JavadocTag.of("param", param.getName(), "the new value")) .add(JavadocTag.of("return", "a reference to this object")) ).public_() .add(param) .set(Javadoc.of() .setText("Sets the " + f.getName() + " of this " + shortName(model.getName()) + ".") .add(JavadocTag.of("param", f.getName(), "the new value")) .add(JavadocTag.of("return", "a reference to this object")) ).public_(); .set(Javadoc.of() .setText("Gets the " + f.getName() + " of this " + shortName(model.getName()) + ".") .add(JavadocTag.of("return", "the " + f.getName())) ).public_() .add("return this." + f.getName() + ";");
/** * Add a javadoc tag to the specified documentation block. If the tag is * already defined, this will have no effect. * * @param doc the documentation block * @param tag the tag to add */ private static void addTag(Javadoc doc, JavadocTag tag) { if (!hasTagAlready( requireNonNull(doc), requireNonNull(tag) )) { doc.add(tag); } }
@Override public Field set(Javadoc doc) { javadoc = doc.setParent(this); return this; }
/** * Checks if the specified tag is already defined in the supplied * documentation block. * * @param doc the documentation block * @param tag the tag to check * @return {@code true} if it exists, else {@code false} */ private static boolean hasTagAlready(Javadoc doc, JavadocTag tag) { requireNonNull(doc); requireNonNull(tag); return doc.getTags().stream().anyMatch(t -> tag.getName().equals(t.getName()) && tag.getValue().equals(t.getValue()) ); } }
/** * The <code>hashCode()</code>-part of the <code>accept</code> method. * * @param model the model */ protected void acceptHashcode(T model) { requireNonNull(model); model.add(Method.of(HASHCODE, int.class) .set( Javadoc.of( "Generates a hashCode for this object. If any field is " + "changed to another value, the hashCode may be different. " + "Two objects with the same values are guaranteed to have " + "the same hashCode. Two objects with the same hashCode are " + "not guaranteed to have the same hashCode." ) .add(RETURN.setText("The hash code.")) ).public_() .add(OVERRIDE) .add("int hash = 7;") .add(model.getFields().stream() .map(this::hash) .collect(Collectors.joining(nl())) ) .add("return hash;") ); }
.set(Javadoc.of() .setText("Adds the specified " + lcfirst(shortName(param.getType().getTypeName())) + " to this " + shortName(model.getName()) + ".") .add(JavadocTag.of("param", param.getName(), "the new value")) .add(JavadocTag.of("return", "a reference to this object")) ).public_() .add(param) .set(Javadoc.of() .setText("Sets the " + f.getName() + " of this " + shortName(model.getName()) + ".") .add(JavadocTag.of("param", f.getName(), "the new value")) .add(JavadocTag.of("return", "a reference to this object")) ).public_(); .set(Javadoc.of() .setText("Gets the " + f.getName() + " of this " + shortName(model.getName()) + ".") .add(JavadocTag.of("return", "the " + f.getName())) ).public_() .add("return this." + f.getName() + ";");
/** * Copy constructor. * * @param prototype the prototype */ protected JavadocImpl(final Javadoc prototype) { text = requireNonNull(prototype).getText(); tags = Copier.copy(prototype.getTags()); imports = Copier.copy(prototype.getImports()); }