当前位置: 首页>>代码示例>>Java>>正文


Java Builder.addJavadoc方法代码示例

本文整理汇总了Java中com.squareup.javapoet.TypeSpec.Builder.addJavadoc方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.addJavadoc方法的具体用法?Java Builder.addJavadoc怎么用?Java Builder.addJavadoc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.javapoet.TypeSpec.Builder的用法示例。


在下文中一共展示了Builder.addJavadoc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTypeSpec

import com.squareup.javapoet.TypeSpec.Builder; //导入方法依赖的package包/类
/**
 * genera classe di test per clazz
 * 
 * @param clazz
 * @param prop
 * @param mongo
 * @return
 */
@Override
public TypeSpec getTypeSpec(Class<?> clazz) {
	Builder classTestBuilder = TypeSpec.classBuilder(clazz.getSimpleName() + TEST);
	ClassName superClass = ClassName.get(
			PropertiesUtils.getRequiredProperty(prop, PropertiesUtils.TEST_BASE_PACKAGE),
			PropertiesUtils.getRequiredProperty(prop, PropertiesUtils.TEST_BASE_CLASS));
	classTestBuilder.superclass(superClass);
	classTestBuilder.addJavadoc("@author \n");
	classTestBuilder.addModifiers(Modifier.PUBLIC);
	AnnotationSpec.Builder annSpecBuilder = AnnotationSpec.builder(Generated.class);
	annSpecBuilder.addMember("value", "\"it.fratta.jerkoff.Generator\"");
	annSpecBuilder.addMember("date", "\"" + Calendar.getInstance().getTime().toString() + "\"");
	AnnotationSpec annGenSpec = annSpecBuilder.build();
	classTestBuilder.addAnnotation(annGenSpec);
	/*
	 * for spring test
	 */
	// FieldSpec.Builder spec = FieldSpec.builder(clazz,
	// getNewInstanceOfNoParameters(clazz), Modifier.PRIVATE);
	// spec.addAnnotation(Autowired.class);
	// classTestBuilder.addField(spec.build());
	addClassMethodsToBuilder(classTestBuilder, clazz);
	return classTestBuilder.build();
}
 
开发者ID:sap-nocops,项目名称:Jerkoff,代码行数:33,代码来源:PojoCreatorImpl.java

示例2: processElementAnnotatedWithAsynchronize

import com.squareup.javapoet.TypeSpec.Builder; //导入方法依赖的package包/类
protected void processElementAnnotatedWithAsynchronize(TypeElement inputInterfaceElement) {

    final Set<ExecutableElement> methodsToAsyncronize = new HashSet<ExecutableElement>(
        ElementFilter.methodsIn(inputInterfaceElement.getEnclosedElements()));

    String interfaceName = inputInterfaceElement.getSimpleName().toString();
    String asyncInterfaceName = interfaceName + SUFFIX;
    String packageName = extractPackageNameString(inputInterfaceElement);

    Options generationOptions = extractGenerationOptions(inputInterfaceElement);

    Builder outputInterfaceBuilder =
        initializeInterfaceTypeSpec(inputInterfaceElement, asyncInterfaceName);

    String docComment = env.elementUtils().getDocComment(inputInterfaceElement);
    if (docComment != null) {
      outputInterfaceBuilder.addJavadoc("Asynchronous version of " + interfaceName + " \n");
      outputInterfaceBuilder.addJavadoc("\n");
      outputInterfaceBuilder.addJavadoc(docComment);
    }

    ClassName callbackClassName =
        getNameOrGenerateNestedCallback(inputInterfaceElement, outputInterfaceBuilder,
            generationOptions);

    TypeName asyncReturnTypeName = generationOptions.returnType != null
        ? TypeName.get(generationOptions.returnType) : null;

    if (generationOptions.addOriginAnnotation) {
      addAsyncOfAnnotation(inputInterfaceElement, outputInterfaceBuilder);
    }

    // management of exented asynchronize interfaces
    for (TypeMirror extendedInterfaceMirror : inputInterfaceElement.getInterfaces()) {
      manageExtendedInterface(methodsToAsyncronize, outputInterfaceBuilder,
          extendedInterfaceMirror);
    }

    // sort methods by name
    List<ExecutableElement> sortedMethodsToAsyncronize =
        new ArrayList<ExecutableElement>(methodsToAsyncronize);
    Comparator<ExecutableElement> a = new Comparator<ExecutableElement>() {

      @Override
      public int compare(ExecutableElement o1, ExecutableElement o2) {
        return o1.getSimpleName().toString().compareTo(o2.getSimpleName().toString());
      }
    };
    Collections.sort(sortedMethodsToAsyncronize, a);

    // management of each method
    for (ExecutableElement methodElement : sortedMethodsToAsyncronize) {
      MethodSpec asyncMethod =
          AsynchronousMethodBuilder.createAsyncMethod(methodElement,
              generationOptions.fireAndForget,
              asyncReturnTypeName, callbackClassName);
      outputInterfaceBuilder.addMethod(asyncMethod);
    }

    // Write file
    try {
      JavaFile.builder(packageName, outputInterfaceBuilder.build()).build().writeTo(
          processingEnv.getFiler());
    } catch (IOException e) {
      env.messager().printMessage(Kind.ERROR, e.getMessage());
    }
  }
 
开发者ID:codejuicer,项目名称:asynchronize,代码行数:68,代码来源:AsynchronizeAnnotationProcessor.java


注:本文中的com.squareup.javapoet.TypeSpec.Builder.addJavadoc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。