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


Java Builder.addModifiers方法代码示例

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


在下文中一共展示了Builder.addModifiers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: generate

import com.squareup.javapoet.TypeSpec.Builder; //导入方法依赖的package包/类
public void generate(Appendable appendable) throws IOException {
	int pos = this.fullyQualifiedName.lastIndexOf(".");
	String className;
	String packageName;
	if (pos > 0) {
		packageName = this.fullyQualifiedName.substring(0, pos);
		className = this.fullyQualifiedName.substring(pos + 1);
	}
	else {
		packageName = "";
		className = this.fullyQualifiedName;
	}
	Builder classBuilder = TypeSpec.classBuilder(className);
	classBuilder.addModifiers(Modifier.PUBLIC, Modifier.FINAL);
	classBuilder.addSuperinterface(CodecProvider.class);

	addInstanceFields(classBuilder);
	addConstructor(classBuilder);
	addGetMethod(classBuilder);

	JavaFile javaFile = JavaFile.builder(packageName, classBuilder.build()).build();
	javaFile.writeTo(appendable);
}
 
开发者ID:ralscha,项目名称:bsoncodec-apt,代码行数:24,代码来源:ProviderCodeGenerator.java

示例3: generate

import com.squareup.javapoet.TypeSpec.Builder; //导入方法依赖的package包/类
public void generate(Appendable appendable) throws IOException {
	Builder classBuilder = TypeSpec.classBuilder(this.className);
	classBuilder.addModifiers(Modifier.PUBLIC, Modifier.FINAL);

	ClassName codec = ClassName.get(Codec.class);
	classBuilder.addSuperinterface(ParameterizedTypeName.get(codec, this.thisType));

	List<FieldModel> fieldInfos = collectFields();
	addEncodeMethod(classBuilder, fieldInfos);
	addDecodeMethod(classBuilder, fieldInfos);
	addGetEncoderClassMethod(classBuilder);

	addInstanceFields(classBuilder);
	addConstructor(classBuilder);

	JavaFile javaFile = JavaFile.builder(this.packageName, classBuilder.build())
			.build();
	javaFile.writeTo(appendable);
}
 
开发者ID:ralscha,项目名称:bsoncodec-apt,代码行数:20,代码来源:CodecCodeGenerator.java

示例4: generate

import com.squareup.javapoet.TypeSpec.Builder; //导入方法依赖的package包/类
public void generate(Appendable appendable) throws IOException {
	Builder classBuilder = TypeSpec.classBuilder(this.className);
	classBuilder.addModifiers(Modifier.PUBLIC, Modifier.FINAL);

	for (Constant constant : collectFields()) {
		FieldSpec fieldSpec = FieldSpec.builder(String.class, constant.getName())
				.addModifiers(Modifier.PUBLIC, Modifier.FINAL, Modifier.STATIC)
				.initializer("$S", constant.getValue()).build();

		classBuilder.addField(fieldSpec);
	}

	JavaFile javaFile = JavaFile.builder(this.packageName, classBuilder.build())
			.build();
	javaFile.writeTo(appendable);
}
 
开发者ID:ralscha,项目名称:constgen,代码行数:17,代码来源:CodeGenerator.java

示例5: initializeInterfaceTypeSpec

import com.squareup.javapoet.TypeSpec.Builder; //导入方法依赖的package包/类
private Builder initializeInterfaceTypeSpec(TypeElement asynchronizeElement,
    String asyncClassSimpleName) {
  Builder interfaceBuilder = TypeSpec.interfaceBuilder(asyncClassSimpleName);

  // warn if input element is not public
  if (!asynchronizeElement.getModifiers().contains(Modifier.PUBLIC)) {
    env.messager().printMessage(Kind.MANDATORY_WARNING,
        "Warning: @Asynchronize annotated interface should be public",
        asynchronizeElement);
  }
  interfaceBuilder.addModifiers(Modifier.PUBLIC); // async will be public
                                                  // anyway
  return interfaceBuilder;
}
 
开发者ID:codejuicer,项目名称:asynchronize,代码行数:15,代码来源:AsynchronizeAnnotationProcessor.java


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