本文整理汇总了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();
}
示例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());
}
}