本文整理匯總了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());
}