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


Java Builder.addAnnotation方法代码示例

本文整理汇总了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();
}
 
开发者ID:sap-nocops,项目名称:Jerkoff,代码行数:33,代码来源:PojoCreatorImpl.java

示例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());
}
 
开发者ID:codejuicer,项目名称:asynchronize,代码行数:8,代码来源:AsynchronizeAnnotationProcessor.java

示例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;
}
 
开发者ID:Axellience,项目名称:vue-gwt,代码行数:35,代码来源:ComponentJsTypeGenerator.java


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