本文整理汇总了Java中com.squareup.javapoet.TypeSpec.Builder.addAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.addAnnotation方法的具体用法?Java Builder.addAnnotation怎么用?Java Builder.addAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.javapoet.TypeSpec.Builder
的用法示例。
在下文中一共展示了Builder.addAnnotation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addAsyncOfAnnotation
import com.squareup.javapoet.TypeSpec.Builder; //导入方法依赖的package包/类
private static void addAsyncOfAnnotation(TypeElement inputInterfaceElement,
Builder outputInterfaceBuilder) {
CodeBlock codeBlock =
CodeBlock.builder().add("$T.class", inputInterfaceElement.asType()).build();
outputInterfaceBuilder.addAnnotation(
AnnotationSpec.builder(AsyncOf.class).addMember("value", codeBlock).build());
}
示例3: getComponentJsTypeBuilder
import com.squareup.javapoet.TypeSpec.Builder; //导入方法依赖的package包/类
/**
* Create and return the builder for the JsType of our {@link VueComponent}.
* @param component The {@link VueComponent} we are generating for
* @param jsTypeClassName The name of the generated JsType class
* @return A Builder to build the class
*/
private Builder getComponentJsTypeBuilder(TypeElement component, ClassName jsTypeClassName)
{
Builder componentJsTypeBuilder = TypeSpec
.classBuilder(jsTypeClassName)
.addModifiers(Modifier.PUBLIC)
.superclass(TypeName.get(component.asType()));
// Add @JsType annotation. This ensure this class is included.
// As we use a class reference to use our Components, this class would be removed by GWT
// tree shaking.
componentJsTypeBuilder.addAnnotation(AnnotationSpec
.builder(JsType.class)
.addMember("namespace", "\"VueGWT.javaComponentConstructors\"")
.addMember("name", "$S", component.getQualifiedName().toString().replaceAll("\\.", "_"))
.build());
// Add a block that registers the VueFactory for the VueComponent
componentJsTypeBuilder.addStaticBlock(CodeBlock
.builder()
.addStatement("$T.onReady(() -> $T.register($S, () -> $T.get()))",
VueGWT.class,
VueGWT.class,
component.getQualifiedName(),
componentFactoryName(component))
.build());
return componentJsTypeBuilder;
}