Java 类com.sun.codemodel.JDocComment 实例源码

项目:aml    文件:AbstractGenerator.java   
private void addCatchAllFormParametersArgument(final MimeType bodyMimeType,
        final JMethod method, final JDocComment javadoc,
        final JType argumentType) {
    method.param(argumentType, GENERIC_PAYLOAD_ARGUMENT_NAME);

    // build a javadoc text out of all the params
    List<INamedParam> formParameters = bodyMimeType.getFormParameters();
    if(formParameters!=null){
        for (INamedParam formParameter : formParameters) {
            final StringBuilder sb = new StringBuilder();
            sb.append(formParameter.getKey()).append(": ");
            appendParameterJavadocDescription(formParameter, sb);
            javadoc.addParam(GENERIC_PAYLOAD_ARGUMENT_NAME).add(sb.toString());
        }
    }
}
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addFormParameters.</p>
 *
 * @param bodyMimeType a {@link org.aml.apimodel.MimeType} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @param javadoc a {@link com.sun.codemodel.JDocComment} object.
 * @throws java.lang.Exception if any.
 */
protected void addFormParameters(final MimeType bodyMimeType,
        final JMethod method, final JDocComment javadoc) throws Exception {
    if (hasAMultiTypeFormParameter(bodyMimeType)) {
        // use a "catch all" MultivaluedMap<String, String> parameter
        final JClass type = types.getGeneratorClass(MultivaluedMap.class)
                .narrow(String.class, String.class);

        addCatchAllFormParametersArgument(bodyMimeType, method, javadoc,
                type);
    } else {
        for (final INamedParam namedFormParameters : bodyMimeType.getFormParameters()) {
            addParameter(namedFormParameters.getKey(), namedFormParameters, FormParam.class, method, javadoc);
        }
    }
}
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addBodyParameters.</p>
 *
 * @param bodyMimeType a {@link org.aml.apimodel.MimeType} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @param javadoc a {@link com.sun.codemodel.JDocComment} object.
 * @throws java.lang.Exception if any.
 */
protected void addBodyParameters(final MimeType bodyMimeType,
        final JMethod method, final JDocComment javadoc) throws Exception {
    if (bodyMimeType == null) {
        return;
    } else if (MediaType.APPLICATION_FORM_URLENCODED.equals(bodyMimeType
            .getType())) {
        addFormParameters(bodyMimeType, method, javadoc);
    } else if (MediaType.MULTIPART_FORM_DATA.equals(bodyMimeType.getType())) {
        // use a "catch all" javax.mail.internet.MimeMultipart parameter
        addCatchAllFormParametersArgument(bodyMimeType, method, javadoc,
                types.getGeneratorType(MimeMultipart.class));
    } else {
        addPlainBodyArgument(bodyMimeType, method, javadoc);
    }
}
项目:aml    文件:AbstractGenerator.java   
private void addCatchAllFormParametersArgument(final MimeType bodyMimeType,
        final JMethod method, final JDocComment javadoc,
        final JType argumentType) {
    method.param(argumentType, GENERIC_PAYLOAD_ARGUMENT_NAME);

    // build a javadoc text out of all the params
    List<INamedParam> formParameters = bodyMimeType.getFormParameters();
    if(formParameters!=null){
        for (INamedParam formParameter : formParameters) {
            final StringBuilder sb = new StringBuilder();
            sb.append(formParameter.getKey()).append(": ");
            appendParameterJavadocDescription(formParameter, sb);
            javadoc.addParam(GENERIC_PAYLOAD_ARGUMENT_NAME).add(sb.toString());
        }
    }
}
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addFormParameters.</p>
 *
 * @param bodyMimeType a {@link org.aml.apimodel.MimeType} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @param javadoc a {@link com.sun.codemodel.JDocComment} object.
 * @throws java.lang.Exception if any.
 */
protected void addFormParameters(final MimeType bodyMimeType,
        final JMethod method, final JDocComment javadoc) throws Exception {
    if (hasAMultiTypeFormParameter(bodyMimeType)) {
        // use a "catch all" MultivaluedMap<String, String> parameter
        final JClass type = types.getGeneratorClass(MultivaluedMap.class)
                .narrow(String.class, String.class);

        addCatchAllFormParametersArgument(bodyMimeType, method, javadoc,
                type);
    } else {
        for (final INamedParam namedFormParameters : bodyMimeType.getFormParameters()) {
            addParameter(namedFormParameters.getKey(), namedFormParameters, FormParam.class, method, javadoc);
        }
    }
}
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addBodyParameters.</p>
 *
 * @param bodyMimeType a {@link org.aml.apimodel.MimeType} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @param javadoc a {@link com.sun.codemodel.JDocComment} object.
 * @throws java.lang.Exception if any.
 */
protected void addBodyParameters(final MimeType bodyMimeType,
        final JMethod method, final JDocComment javadoc) throws Exception {
    if (bodyMimeType == null) {
        return;
    } else if (MediaType.APPLICATION_FORM_URLENCODED.equals(bodyMimeType
            .getType())) {
        addFormParameters(bodyMimeType, method, javadoc);
    } else if (MediaType.MULTIPART_FORM_DATA.equals(bodyMimeType.getType())) {
        // use a "catch all" javax.mail.internet.MimeMultipart parameter
        addCatchAllFormParametersArgument(bodyMimeType, method, javadoc,
                types.getGeneratorType(MimeMultipart.class));
    } else {
        addPlainBodyArgument(bodyMimeType, method, javadoc);
    }
}
项目:kc-rice    文件:ImmutableJaxbGenerator.java   
private void renderConstantsClass(JDefinedClass classModel) throws Exception {

    // define constants class
    JDefinedClass constantsClass = classModel._class(JMod.STATIC, Util.CONSTANTS_CLASS_NAME);

    // generate the javadoc on the top of the Constants class
    JDocComment javadoc = constantsClass.javadoc();
    javadoc.append(Util.CONSTANTS_CLASS_JAVADOC);

    // render root element name
    JFieldVar rootElementField = constantsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.ROOT_ELEMENT_NAME_FIELD);
    rootElementField.init(JExpr.lit(Util.toLowerCaseFirstLetter(classModel.name())));

    // render type name
    JFieldVar typeNameField = constantsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.TYPE_NAME_FIELD);
    typeNameField.init(JExpr.lit(classModel.name() + Util.TYPE_NAME_SUFFIX));

}
项目:kc-rice    文件:ImmutableJaxbGenerator.java   
private void renderElementsClass(JDefinedClass classModel, List<FieldModel> fields) throws Exception {

    // define constants class
    JDefinedClass elementsClass = classModel._class(JMod.STATIC, Util.ELEMENTS_CLASS_NAME);

    // generate the javadoc on the top of the Elements class
    JDocComment javadoc = elementsClass.javadoc();
    javadoc.append(Util.ELEMENTS_CLASS_JAVADOC);

    // go through each field and create a corresponding constant
    for (FieldModel fieldModel : fields) {
        if (Util.isCommonElement(fieldModel.fieldName)) {
            continue;
        }
        JFieldVar elementFieldVar = elementsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.toConstantsVariable(fieldModel.fieldName));
        elementFieldVar.init(JExpr.lit(fieldModel.fieldName));
    }
}
项目:rice    文件:ImmutableJaxbGenerator.java   
private void renderConstantsClass(JDefinedClass classModel) throws Exception {

    // define constants class
    JDefinedClass constantsClass = classModel._class(JMod.STATIC, Util.CONSTANTS_CLASS_NAME);

    // generate the javadoc on the top of the Constants class
    JDocComment javadoc = constantsClass.javadoc();
    javadoc.append(Util.CONSTANTS_CLASS_JAVADOC);

    // render root element name
    JFieldVar rootElementField = constantsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.ROOT_ELEMENT_NAME_FIELD);
    rootElementField.init(JExpr.lit(Util.toLowerCaseFirstLetter(classModel.name())));

    // render type name
    JFieldVar typeNameField = constantsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.TYPE_NAME_FIELD);
    typeNameField.init(JExpr.lit(classModel.name() + Util.TYPE_NAME_SUFFIX));

}
项目:rice    文件:ImmutableJaxbGenerator.java   
private void renderElementsClass(JDefinedClass classModel, List<FieldModel> fields) throws Exception {

    // define constants class
    JDefinedClass elementsClass = classModel._class(JMod.STATIC, Util.ELEMENTS_CLASS_NAME);

    // generate the javadoc on the top of the Elements class
    JDocComment javadoc = elementsClass.javadoc();
    javadoc.append(Util.ELEMENTS_CLASS_JAVADOC);

    // go through each field and create a corresponding constant
    for (FieldModel fieldModel : fields) {
        if (Util.isCommonElement(fieldModel.fieldName)) {
            continue;
        }
        JFieldVar elementFieldVar = elementsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.toConstantsVariable(fieldModel.fieldName));
        elementFieldVar.init(JExpr.lit(fieldModel.fieldName));
    }
}
项目:xjc-inst    文件:ListToSet.java   
private void replaceGetter(ClassOutline co, JFieldVar f, JType inner) {
    //Create the method name
    String get = "get";
    String name  = f.name().substring(0, 1).toUpperCase() 
            + f.name().substring(1);
    String methodName = get+name;

    //Create HashSet JType
    JType hashSetType = co.parent().getCodeModel().ref(HashSet.class).narrow(inner);

    //Find and remove Old Getter!
    JMethod oldGetter = co.implClass.getMethod(methodName, new JType[0]);
    JDocComment comment = oldGetter.javadoc();

    co.implClass.methods().remove(oldGetter);

    //Create New Getter
    JMethod getter = co.implClass.method(JMod.PUBLIC, f.type(), methodName);
    getter.javadoc().addAll(comment);

    //Create Getter Body -> {if (f = null) f = new HashSet(); return f;}
    getter.body()._if(JExpr.ref(f.name()).eq(JExpr._null()))._then()
    .assign(f, JExpr._new(hashSetType));

    getter.body()._return(JExpr.ref(f.name()));
}
项目:kuali_rice    文件:ImmutableJaxbGenerator.java   
private void renderConstantsClass(JDefinedClass classModel) throws Exception {

    // define constants class
    JDefinedClass constantsClass = classModel._class(JMod.STATIC, Util.CONSTANTS_CLASS_NAME);

    // generate the javadoc on the top of the Constants class
    JDocComment javadoc = constantsClass.javadoc();
    javadoc.append(Util.CONSTANTS_CLASS_JAVADOC);

    // render root element name
    JFieldVar rootElementField = constantsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.ROOT_ELEMENT_NAME_FIELD);
    rootElementField.init(JExpr.lit(Util.toLowerCaseFirstLetter(classModel.name())));

    // render type name
    JFieldVar typeNameField = constantsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.TYPE_NAME_FIELD);
    typeNameField.init(JExpr.lit(classModel.name() + Util.TYPE_NAME_SUFFIX));

}
项目:kuali_rice    文件:ImmutableJaxbGenerator.java   
private void renderElementsClass(JDefinedClass classModel, List<FieldModel> fields) throws Exception {

    // define constants class
    JDefinedClass elementsClass = classModel._class(JMod.STATIC, Util.ELEMENTS_CLASS_NAME);

    // generate the javadoc on the top of the Elements class
    JDocComment javadoc = elementsClass.javadoc();
    javadoc.append(Util.ELEMENTS_CLASS_JAVADOC);

    // go through each field and create a corresponding constant
    for (FieldModel fieldModel : fields) {
        if (Util.isCommonElement(fieldModel.fieldName)) {
            continue;
        }
        JFieldVar elementFieldVar = elementsClass.field(JMod.FINAL | JMod.STATIC, String.class, Util.toConstantsVariable(fieldModel.fieldName));
        elementFieldVar.init(JExpr.lit(fieldModel.fieldName));
    }
}
项目:GitHub    文件:JavaNameRule.java   
@Override
public JDocComment apply(String nodeName, JsonNode node, JDocCommentable generatableType, Schema currentSchema) {
    JDocComment javaDoc = generatableType.javadoc();

    javaDoc.append(String.format("%nCorresponds to the \"%s\" property.", nodeName));

    return javaDoc;
}
项目:aml    文件:ClientGenerator.java   
/** {@inheritDoc} */
protected void addResourceMethod(final JDefinedClass resourceInterface,
        final Resource resource,
        final String resourceInterfacePath,
        final Action action,
        final MimeType bodyMimeType,
        final boolean addBodyMimeTypeInMethodName,
        final Collection<MimeType> uniqueResponseMimeTypes)
        throws Exception {
    MimeType actualBodyMimeType = addBodyMimeTypeInMethodName ? bodyMimeType : null;
    String methodName = null;
    if(this.extensions!=null){
        for(GeneratorExtension ext : this.extensions){
            if(ext instanceof MethodNameBuilderExtension){
                methodName = ((MethodNameBuilderExtension)ext)
                        .buildResourceMethodName(action, actualBodyMimeType,resource);
                break;
            }
        }
    }
    if(methodName==null){
        methodName = Names.buildResourceMethodName(action,actualBodyMimeType);
    }
    final JType resourceMethodReturnType = getResourceMethodReturnType(
            methodName, action, uniqueResponseMimeTypes.isEmpty(),
            false, resourceInterface);
    final JMethod method = context.createResourceMethod(resourceInterface,
            methodName, resourceMethodReturnType);
    context.addHttpMethodAnnotation(action.method(), method);
    addParamAnnotation(resourceInterfacePath, action, method);
    addConsumesAnnotation(bodyMimeType, method);
    addProducesAnnotation(uniqueResponseMimeTypes, method);
    final JDocComment javadoc = addBaseJavaDoc(action, method);
    addParameters(action, bodyMimeType, method, javadoc);
    /* call registered extensions */
    for (GeneratorExtension e : extensions) {
        e.onAddResourceMethod(method, action, bodyMimeType,
                uniqueResponseMimeTypes);
    }
}
项目:aml    文件:ClientGenerator.java   
private void addParameters(final Action action,
        final MimeType bodyMimeType, final JMethod method,
        final JDocComment javadoc) throws Exception {
    addPathParameters(action, method, javadoc);
    addHeaderParameters(action, method, javadoc);
    addQueryParameters(action, method, javadoc);
    addBodyParameters(bodyMimeType, method, javadoc);
}
项目:aml    文件:AbstractGenerator.java   
private void addPlainBodyArgument(final MimeType bodyMimeType,
        final JMethod method, final JDocComment javadoc) throws IOException {

    if(context.getConfiguration().isUseJsr303Annotations()) {
           method.param(types.getRequestEntityClass(bodyMimeType),
                   GENERIC_PAYLOAD_ARGUMENT_NAME).annotate(Valid.class);
       } else {
           method.param(types.getRequestEntityClass(bodyMimeType),
                   GENERIC_PAYLOAD_ARGUMENT_NAME);
       }

    javadoc.addParam(GENERIC_PAYLOAD_ARGUMENT_NAME).add(
            getPrefixedExampleOrBlank(bodyMimeType.getExample()));
}
项目:aml    文件:AbstractGenerator.java   
private void addAllResourcePathParameters(Resource resource,
        final JMethod method, final JDocComment javadoc) throws Exception {
    for (final INamedParam namedUriParameter : resource.uriParameters()) {
        addParameter(namedUriParameter.getKey(),
                namedUriParameter, PathParam.class, method,
                javadoc);
    }
    Resource parentResource = resource.parentResource();

    if (parentResource != null) {
        addAllResourcePathParameters(parentResource, method, javadoc);
    }
}
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addHeaderParameters.</p>
 *
 * @param action a {@link org.aml.apimodel.Action} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @param javadoc a {@link com.sun.codemodel.JDocComment} object.
 * @throws java.lang.Exception if any.
 */
protected void addHeaderParameters(final Action action, final JMethod method,
        final JDocComment javadoc) throws Exception {
    for (final INamedParam namedHeaderParameter : action.headers()) {
        addParameter(namedHeaderParameter.getKey(),
                namedHeaderParameter, HeaderParam.class, method,
                javadoc);
    }
}
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addBaseJavaDoc.</p>
 *
 * @param action a {@link org.aml.apimodel.Action} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @return a {@link com.sun.codemodel.JDocComment} object.
 */
protected JDocComment addBaseJavaDoc(final Action action, final JMethod method)
   {
       final JDocComment javadoc = method.javadoc();
       if (isNotBlank(action.description()))
       {
           javadoc.add(action.description());
       }
       return javadoc;
   }
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addQueryParameters.</p>
 *
 * @param action a {@link org.aml.apimodel.Action} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @param javadoc a {@link com.sun.codemodel.JDocComment} object.
 * @throws java.lang.Exception if any.
 */
protected void addQueryParameters(final Action action, final JMethod method,
        final JDocComment javadoc) throws Exception {
    for (final INamedParam namedQueryParameter : action.queryParameters()) {
        addParameter(namedQueryParameter.getKey(),
                namedQueryParameter, QueryParam.class, method,
                javadoc);
    }
}
项目:aml    文件:AbstractGenerator.java   
private void addParameter(final String name, final INamedParam parameter,
        final Class<? extends Annotation> annotationClass,
        final JMethod method, final JDocComment javadoc) throws Exception {
    if (this.context.getConfiguration().getIgnoredParameterNames().contains(name)){
        return;
    }
    for (GeneratorExtension e : extensions) {
        if (!e.AddParameterFilter(name, parameter, annotationClass, method)) {
            return;
        }
    }

    final String argumentName = Names.buildVariableName(name);

    final JVar argumentVariable = method
            .param(types.buildParameterType(parameter, argumentName),
                    argumentName);

    argumentVariable.annotate(annotationClass).param(
            DEFAULT_ANNOTATION_PARAMETER, name);

    if (parameter.getDefaultValue() != null) {
        argumentVariable.annotate(DefaultValue.class).param(
                DEFAULT_ANNOTATION_PARAMETER, parameter.getDefaultValue());
    }

    if (context.getConfiguration().isUseJsr303Annotations()) {
        addJsr303Annotations(parameter, argumentVariable);
    }

    addParameterJavaDoc(parameter, argumentVariable.name(), javadoc);
}
项目:aml    文件:ClientGenerator.java   
/** {@inheritDoc} */
protected void addResourceMethod(final JDefinedClass resourceInterface,
        final Resource resource,
        final String resourceInterfacePath,
        final Action action,
        final MimeType bodyMimeType,
        final boolean addBodyMimeTypeInMethodName,
        final Collection<MimeType> uniqueResponseMimeTypes)
        throws Exception {
    MimeType actualBodyMimeType = addBodyMimeTypeInMethodName ? bodyMimeType : null;
    String methodName = null;
    if(this.extensions!=null){
        for(GeneratorExtension ext : this.extensions){
            if(ext instanceof MethodNameBuilderExtension){
                methodName = ((MethodNameBuilderExtension)ext)
                        .buildResourceMethodName(action, actualBodyMimeType,resource);
                break;
            }
        }
    }
    if(methodName==null){
        methodName = Names.buildResourceMethodName(action,actualBodyMimeType);
    }
    final JType resourceMethodReturnType = getResourceMethodReturnType(
            methodName, action, uniqueResponseMimeTypes.isEmpty(),
            false, resourceInterface);
    final JMethod method = context.createResourceMethod(resourceInterface,
            methodName, resourceMethodReturnType);
    context.addHttpMethodAnnotation(action.method(), method);
    addParamAnnotation(resourceInterfacePath, action, method);
    addConsumesAnnotation(bodyMimeType, method);
    addProducesAnnotation(uniqueResponseMimeTypes, method);
    final JDocComment javadoc = addBaseJavaDoc(action, method);
    addParameters(action, bodyMimeType, method, javadoc);
    /* call registered extensions */
    for (GeneratorExtension e : extensions) {
        e.onAddResourceMethod(method, action, bodyMimeType,
                uniqueResponseMimeTypes);
    }
}
项目:aml    文件:ClientGenerator.java   
private void addParameters(final Action action,
        final MimeType bodyMimeType, final JMethod method,
        final JDocComment javadoc) throws Exception {
    addPathParameters(action, method, javadoc);
    addHeaderParameters(action, method, javadoc);
    addQueryParameters(action, method, javadoc);
    addBodyParameters(bodyMimeType, method, javadoc);
}
项目:aml    文件:AbstractGenerator.java   
private void addPlainBodyArgument(final MimeType bodyMimeType,
        final JMethod method, final JDocComment javadoc) throws IOException {

    if(context.getConfiguration().isUseJsr303Annotations()) {
           method.param(types.getRequestEntityClass(bodyMimeType),
                   GENERIC_PAYLOAD_ARGUMENT_NAME).annotate(Valid.class);
       } else {
           method.param(types.getRequestEntityClass(bodyMimeType),
                   GENERIC_PAYLOAD_ARGUMENT_NAME);
       }

    javadoc.addParam(GENERIC_PAYLOAD_ARGUMENT_NAME).add(
            getPrefixedExampleOrBlank(bodyMimeType.getExample()));
}
项目:aml    文件:AbstractGenerator.java   
private void addAllResourcePathParameters(Resource resource,
        final JMethod method, final JDocComment javadoc) throws Exception {
    for (final INamedParam namedUriParameter : resource.uriParameters()) {
        addParameter(namedUriParameter.getKey(),
                namedUriParameter, PathParam.class, method,
                javadoc);
    }
    Resource parentResource = resource.parentResource();

    if (parentResource != null) {
        addAllResourcePathParameters(parentResource, method, javadoc);
    }

}
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addHeaderParameters.</p>
 *
 * @param action a {@link org.aml.apimodel.Action} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @param javadoc a {@link com.sun.codemodel.JDocComment} object.
 * @throws java.lang.Exception if any.
 */
protected void addHeaderParameters(final Action action, final JMethod method,
        final JDocComment javadoc) throws Exception {
    for (final INamedParam namedHeaderParameter : action.headers()) {
        addParameter(namedHeaderParameter.getKey(),
                namedHeaderParameter, HeaderParam.class, method,
                javadoc);
    }
}
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addBaseJavaDoc.</p>
 *
 * @param action a {@link org.aml.apimodel.Action} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @return a {@link com.sun.codemodel.JDocComment} object.
 */
protected JDocComment addBaseJavaDoc(final Action action, final JMethod method)
   {
       final JDocComment javadoc = method.javadoc();
       if (isNotBlank(action.description()))
       {
           javadoc.add(action.description());
       }
       return javadoc;
   }
项目:aml    文件:AbstractGenerator.java   
/**
 * <p>addQueryParameters.</p>
 *
 * @param action a {@link org.aml.apimodel.Action} object.
 * @param method a {@link com.sun.codemodel.JMethod} object.
 * @param javadoc a {@link com.sun.codemodel.JDocComment} object.
 * @throws java.lang.Exception if any.
 */
protected void addQueryParameters(final Action action, final JMethod method,
        final JDocComment javadoc) throws Exception {
    for (final INamedParam namedQueryParameter : action.queryParameters()) {
        addParameter(namedQueryParameter.getKey(),
                namedQueryParameter, QueryParam.class, method,
                javadoc);
    }
}
项目:aml    文件:AbstractGenerator.java   
private void addParameter(final String name, final INamedParam parameter,
        final Class<? extends Annotation> annotationClass,
        final JMethod method, final JDocComment javadoc) throws Exception {
    if (this.context.getConfiguration().getIgnoredParameterNames().contains(name)){
        return;
    }
    for (GeneratorExtension e : extensions) {
        if (!e.AddParameterFilter(name, parameter, annotationClass, method)) {
            return;
        }
    }

    final String argumentName = Names.buildVariableName(name);

    final JVar argumentVariable = method
            .param(types.buildParameterType(parameter, argumentName),
                    argumentName);

    argumentVariable.annotate(annotationClass).param(
            DEFAULT_ANNOTATION_PARAMETER, name);

    if (parameter.getDefaultValue() != null) {
        argumentVariable.annotate(DefaultValue.class).param(
                DEFAULT_ANNOTATION_PARAMETER, parameter.getDefaultValue());
    }

    if (context.getConfiguration().isUseJsr303Annotations()) {
        new ParameterValidationGenerator().addValidation(parameter, argumentVariable);
    }

    addParameterJavaDoc(parameter, argumentVariable.name(), javadoc);
}
项目:kc-rice    文件:ImmutableJaxbGenerator.java   
private void renderBuilderClass(JDefinedClass classModel, List<FieldModel> fields, Class<?> contractInterface) throws Exception {

    // define constants class
    JDefinedClass builderClass = classModel._class(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, Util.BUILDER_CLASS_NAME);

    // create a literal version of the Builder class so that the code generator won't pre-pend Builder class references with outermost class
    JClass literalBuilderClass = codeModel.ref("Builder");

    // generate the javadoc on the top of the Elements class
    JDocComment javadoc = builderClass.javadoc();
    javadoc.append(Util.generateBuilderJavadoc(classModel.name(), contractInterface.getSimpleName()));

    builderClass._implements(contractInterface);
    builderClass._implements(ModelBuilder.class);
    builderClass._implements(Serializable.class);

    // render the builder fields
    for (FieldModel fieldModel : fields) {
        builderClass.field(JMod.PRIVATE, fieldModel.fieldType, fieldModel.fieldName);
    }

    // render default empty constructor for builder
    JMethod constructor = builderClass.constructor(JMod.PRIVATE);
    constructor.body().directStatement("// TODO modify this constructor as needed to pass any required values and invoke the appropriate 'setter' methods");

    renderBuilderDefaultCreate(builderClass, literalBuilderClass);
    renderBuilderCreateContract(builderClass, literalBuilderClass, fields, contractInterface);
    renderBuild(builderClass);
    renderGetters(builderClass, fields);
    renderSetters(builderClass, fields);
}
项目:springmvc-raml-plugin    文件:AbstractBuilder.java   
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;
}
项目:springmvc-raml-plugin    文件:ClassCommentRule.java   
@Override
public JDocComment apply(ApiResourceMetadata controllerMetadata, JDefinedClass generatableType) {
    String comments = "No description";
    if(controllerMetadata.getDescription() != null) {
        comments = controllerMetadata.getDescription();
    }
    generatableType.javadoc().append(comments);
    generatableType.javadoc().append("\n(Generated with springmvc-raml-parser v."+ CodeModelHelper.getVersion()+")");
    return generatableType.javadoc();
}
项目:springmvc-raml-plugin    文件:MethodCommentRule.java   
@Override
public JDocComment apply(ApiActionMetadata endpointMetadata, JMethod generatableType) {
    String comments = "No description";
    if(endpointMetadata.getDescription() != null) {
        comments = endpointMetadata.getDescription();
    }
    return generatableType.javadoc().append(comments);
}
项目:springmvc-raml-plugin    文件:MethodCommentRuleTest.java   
@Test
public void applyRule_shouldCreate_validMethodComment() throws JClassAlreadyExistsException {

    JDefinedClass jClass = jCodeModel.rootPackage()._class("TestController");
    JMethod jMethod = jClass.method(JMod.PUBLIC, ResponseEntity.class, "getBaseById");
    JDocComment jDocComment = rule.apply(getEndpointMetadata(2), jMethod);
    assertNotNull(jDocComment);
    assertThat(serializeModel(), containsString("* Get base entity by ID"));
}
项目:springmvc-raml-plugin    文件:ClassCommentRuleTest.java   
@Test
public void applyRule_shouldCreate_validClassComment() throws JClassAlreadyExistsException {

    JDefinedClass jClass = jCodeModel.rootPackage()._class("BaseController");
    JDocComment jDocComment = rule.apply(getControllerMetadata(), jClass);
    assertNotNull(jDocComment);
    assertThat(serializeModel(), containsString("* The BaseController class"));
}
项目:jaxb2-rich-contract-plugin    文件:PartialCopyGenerator.java   
@Override
public void generatePartialArgs(final JDocComment javadoc) {
    javadoc .addParam(this.propertyTreeParam)
            .append(PartialCopyGenerator.RESOURCE_BUNDLE.getString("javadoc.method.param.propertyTree"));
    javadoc .addParam(this.propertyTreeUseParam)
            .append(MessageFormat.format(PartialCopyGenerator.RESOURCE_BUNDLE.getString("javadoc.method.param.propertyTreeUse"), this.propertyTreeParam.name()));
}
项目:generator    文件:InterfaceFieldHelper.java   
private static void addSetterDeclaration(Names names, Class<?> paramType, JDefinedClass setterReturnType)
{
    JMethod method = setterReturnType.method(JMod.NONE, setterReturnType, names.getSetterName());
    method.param(paramType, names.getParamName());
    JDocComment javadoc = method.javadoc();
    javadoc.append(names.getJavadoc());
}
项目:generator    文件:InterfaceFieldHelper.java   
private static void addSetterDeclaration(Names names, JDefinedClass paramType, JDefinedClass setterReturnType)
{
    JMethod method = setterReturnType.method(JMod.NONE, setterReturnType, names.getSetterName());
    method.param(paramType, names.getParamName());
    JDocComment javadoc = method.javadoc();
    javadoc.append(names.getJavadoc());
}
项目:generator    文件:InterfaceFieldHelper.java   
public static void addGetterSetterDeclaration(Names names, JClass type, JDefinedClass jDefinedClass)
{
    addGetterDeclaration(names, type, jDefinedClass);

    JMethod method = jDefinedClass.method(JMod.NONE, jDefinedClass, names.getSetterName());
    method.param(type, names.getParamName());

    JDocComment javadoc = method.javadoc();
    javadoc.append(names.getJavadoc());
}