Search in sources :

Example 31 with JavaMethod

use of com.thoughtworks.qdox.model.JavaMethod in project jsonschema2pojo by joelittlejohn.

the class RequiredIT method requiredAppearsInSetterJavadoc.

@Test
public void requiredAppearsInSetterJavadoc() {
    JavaMethod javaMethod = classWithRequired.getMethodBySignature("setRequiredProperty", new Type[] { new Type("java.lang.String") });
    String javaDocComment = javaMethod.getComment();
    assertThat(javaDocComment, containsString("(Required)"));
}
Also used : Type(com.thoughtworks.qdox.model.Type) JavaMethod(com.thoughtworks.qdox.model.JavaMethod) Test(org.junit.Test)

Example 32 with JavaMethod

use of com.thoughtworks.qdox.model.JavaMethod in project jsonschema2pojo by joelittlejohn.

the class RequiredIT method requiredAppearsInGetterJavadoc.

@Test
public void requiredAppearsInGetterJavadoc() {
    JavaMethod javaMethod = classWithRequired.getMethodBySignature("getRequiredProperty", new Type[] {});
    String javaDocComment = javaMethod.getComment();
    assertThat(javaDocComment, containsString("(Required)"));
}
Also used : JavaMethod(com.thoughtworks.qdox.model.JavaMethod) Test(org.junit.Test)

Example 33 with JavaMethod

use of com.thoughtworks.qdox.model.JavaMethod in project jsonschema2pojo by joelittlejohn.

the class DescriptionIT method descriptionAppearsInSetterJavadoc.

@Test
public void descriptionAppearsInSetterJavadoc() {
    JavaMethod javaMethod = classWithDescription.getMethodBySignature("setDescription", new Type[] { new Type("java.lang.String") });
    String javaDocComment = javaMethod.getComment();
    assertThat(javaDocComment, containsString("A description for this property"));
}
Also used : Type(com.thoughtworks.qdox.model.Type) JavaMethod(com.thoughtworks.qdox.model.JavaMethod) Test(org.junit.Test)

Example 34 with JavaMethod

use of com.thoughtworks.qdox.model.JavaMethod in project jsonschema2pojo by joelittlejohn.

the class DescriptionIT method descriptionAppearsInGetterJavadoc.

@Test
public void descriptionAppearsInGetterJavadoc() {
    JavaMethod javaMethod = classWithDescription.getMethodBySignature("getDescription", new Type[] {});
    String javaDocComment = javaMethod.getComment();
    assertThat(javaDocComment, containsString("A description for this property"));
}
Also used : JavaMethod(com.thoughtworks.qdox.model.JavaMethod) Test(org.junit.Test)

Example 35 with JavaMethod

use of com.thoughtworks.qdox.model.JavaMethod in project maven-plugins by apache.

the class AbstractFixJavadocMojo method updateJavadocTags.

/**
 * Write tags according javaEntityTags.
 *
 * @param sb             not null
 * @param entity         not null
 * @param isJavaExecutable
 * @param javaEntityTags not null
 */
private void updateJavadocTags(final StringBuilder sb, final JavaAnnotatedElement entity, final boolean isJavaExecutable, final JavaEntityTags javaEntityTags) {
    for (DocletTag docletTag : entity.getTags()) {
        if (isJavaExecutable) {
            JavaExecutable javaExecutable = (JavaExecutable) entity;
            List<String> params = docletTag.getParameters();
            if (params.size() < 1) {
                continue;
            }
            if (docletTag.getName().equals(PARAM_TAG)) {
                writeParamTag(sb, javaExecutable, javaEntityTags, params);
            } else if (docletTag.getName().equals(RETURN_TAG) && javaExecutable instanceof JavaMethod) {
                writeReturnTag(sb, (JavaMethod) javaExecutable, javaEntityTags);
            } else if (docletTag.getName().equals(THROWS_TAG)) {
                writeThrowsTag(sb, javaExecutable, javaEntityTags, params);
            } else {
                // write unknown tags
                for (Iterator<String> it = javaEntityTags.getUnknownTags().iterator(); it.hasNext(); ) {
                    String originalJavadocTag = it.next();
                    String simplified = StringUtils.removeDuplicateWhitespace(originalJavadocTag).trim();
                    if (simplified.contains("@" + docletTag.getName())) {
                        it.remove();
                        sb.append(originalJavadocTag);
                        sb.append(EOL);
                    }
                }
            }
        } else {
            for (Iterator<String> it = javaEntityTags.getUnknownTags().iterator(); it.hasNext(); ) {
                String originalJavadocTag = it.next();
                String simplified = StringUtils.removeDuplicateWhitespace(originalJavadocTag).trim();
                if (simplified.contains("@" + docletTag.getName())) {
                    it.remove();
                    sb.append(originalJavadocTag);
                    sb.append(EOL);
                }
            }
        }
        if (sb.toString().endsWith(EOL)) {
            sb.delete(sb.toString().lastIndexOf(EOL), sb.toString().length());
        }
        sb.append(EOL);
    }
}
Also used : JavaMethod(com.thoughtworks.qdox.model.JavaMethod) DocletTag(com.thoughtworks.qdox.model.DocletTag) JavaExecutable(com.thoughtworks.qdox.model.JavaExecutable)

Aggregations

JavaMethod (com.thoughtworks.qdox.model.JavaMethod)38 DocletTag (com.thoughtworks.qdox.model.DocletTag)13 JavaClass (com.thoughtworks.qdox.model.JavaClass)12 Test (org.junit.Test)10 JavaParameter (com.thoughtworks.qdox.model.JavaParameter)8 StringReader (java.io.StringReader)8 Type (com.thoughtworks.qdox.model.Type)7 JavaDocBuilder (com.thoughtworks.qdox.JavaDocBuilder)3 JavaProjectBuilder (com.thoughtworks.qdox.JavaProjectBuilder)3 JavaExecutable (com.thoughtworks.qdox.model.JavaExecutable)3 JavaType (com.thoughtworks.qdox.model.JavaType)3 AbstractInheritableJavaEntity (com.thoughtworks.qdox.model.AbstractInheritableJavaEntity)2 AbstractJavaEntity (com.thoughtworks.qdox.model.AbstractJavaEntity)2 BeanProperty (com.thoughtworks.qdox.model.BeanProperty)2 JavaField (com.thoughtworks.qdox.model.JavaField)2 JavaGenericDeclaration (com.thoughtworks.qdox.model.JavaGenericDeclaration)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 StringWriter (java.io.StringWriter)2 Method (java.lang.reflect.Method)2