本文整理汇总了Java中com.squareup.javapoet.FieldSpec.builder方法的典型用法代码示例。如果您正苦于以下问题:Java FieldSpec.builder方法的具体用法?Java FieldSpec.builder怎么用?Java FieldSpec.builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.javapoet.FieldSpec
的用法示例。
在下文中一共展示了FieldSpec.builder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFields
import com.squareup.javapoet.FieldSpec; //导入方法依赖的package包/类
private void addFields(final TypeSpec.Builder classBuilder) {
FieldSpec.Builder viewIdsField = FieldSpec.builder(int[].class, "viewIds", Modifier.PRIVATE, Modifier.STATIC,
Modifier.FINAL);
StringBuilder sb = new StringBuilder();
sb.append("{");
for (Integer id : viewIds) {
sb.append(id).append(",");
}
if (viewIds.size() > 0) {
sb.deleteCharAt(sb.length() - 1);
}
sb.append("}");
viewIdsField.initializer(CodeBlock.of(sb.toString()));
classBuilder.addField(viewIdsField.build());
}
示例2: createMembers
import com.squareup.javapoet.FieldSpec; //导入方法依赖的package包/类
@NonNull
protected FieldSpec[] createMembers() {
final List<FieldSpec> fields = new ArrayList<>();
final TypeName typeOfField = TypeName.get(type.element.asType());
final FieldSpec.Builder builder = FieldSpec.builder(typeOfField, "inner", Modifier.PROTECTED, Modifier.FINAL);
fields.add(builder.build());
return fields.toArray(new FieldSpec[0]);
}
示例3: buildProviderField
import com.squareup.javapoet.FieldSpec; //导入方法依赖的package包/类
private static FieldSpec.Builder buildProviderField( final @Nonnull ComponentDescriptor descriptor )
{
return FieldSpec.builder( ParameterizedTypeName.get( PROVIDER_CLASSNAME,
TypeName.get( descriptor.getDeclaredType() ) ),
"c_provider",
Modifier.STATIC,
Modifier.PRIVATE );
}
示例4: create
import com.squareup.javapoet.FieldSpec; //导入方法依赖的package包/类
public FieldSpec create(Column column, VariableElement element, TypeElement entityClass) {
ColumnType columnType = ColumnType.fromVariable(element);
ParameterizedTypeName typeName = ParameterizedTypeName.get(ClassName.get(columnType.getColumnClass()), ClassName.get(entityClass));
String fieldName = NamingUtils.columnFieldName(element.getSimpleName().toString());
FieldSpec.Builder builder = FieldSpec.builder(typeName, fieldName, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL);
builder.initializer("$T.$N($T.class, $S)", DbColumn.class, columnType.getFactoryMethod(), ClassName.get(entityClass), column.value());
return builder.build();
}
示例5: createFieldBuilder
import com.squareup.javapoet.FieldSpec; //导入方法依赖的package包/类
@Override
public FieldSpec.Builder[] createFieldBuilder(String pkgName, String interName, String classname,
List<FieldData> datas, int superInterfaceFlagsForParent) {
//if parent handled.
if(Util.hasFlag(superInterfaceFlagsForParent, FieldData.FLAG_SELECTABLE)){
return null;
}
return new FieldSpec.Builder[]{
FieldSpec.builder(TypeName.BOOLEAN, FD_SELECTABLE.getPropertyName(), Modifier.PRIVATE),
};
}
示例6: asField
import com.squareup.javapoet.FieldSpec; //导入方法依赖的package包/类
public FieldSpec asField(MemberModel memberModel, Modifier... modifiers) {
FieldSpec.Builder builder = FieldSpec.builder(typeProvider.fieldType(memberModel),
memberModel.getVariable().getVariableName());
if (modifiers != null) {
builder.addModifiers(modifiers);
}
return builder.build();
}
示例7: privateField
import com.squareup.javapoet.FieldSpec; //导入方法依赖的package包/类
public static FieldSpec.Builder privateField(Type fType, String name) {
return FieldSpec.builder(fType, name, Modifier.PRIVATE);
}
示例8: addFields
import com.squareup.javapoet.FieldSpec; //导入方法依赖的package包/类
private void addFields(final TypeSpec.Builder builder, final ClassName dataBindingName) {
FieldSpec.Builder field = FieldSpec.builder(dataBindingName, "binding", Modifier.PRIVATE, Modifier.FINAL);
builder.addField(field.build());
}