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