本文整理汇总了Java中com.squareup.javapoet.CodeBlock.of方法的典型用法代码示例。如果您正苦于以下问题:Java CodeBlock.of方法的具体用法?Java CodeBlock.of怎么用?Java CodeBlock.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.javapoet.CodeBlock
的用法示例。
在下文中一共展示了CodeBlock.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSeeMethodJavadocInternal
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
private CodeBlock generateSeeMethodJavadocInternal(
TypeName nameOfClassContainingMethod, String methodName,
List<Object> safeParameterNames) {
StringBuilder javadocString = new StringBuilder("@see $T#$L(");
List<Object> javadocArgs = new ArrayList<>();
javadocArgs.add(nameOfClassContainingMethod);
javadocArgs.add(methodName);
for (Object param : safeParameterNames) {
javadocString.append("$T, ");
javadocArgs.add(param);
}
if (javadocArgs.size() > 2) {
javadocString = new StringBuilder(javadocString.substring(0, javadocString.length() - 2));
}
javadocString.append(")\n");
return CodeBlock.of(javadocString.toString(), javadocArgs.toArray(new Object[0]));
}
示例2: generateCharacterCastWrapperFor
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
private CodeBlock generateCharacterCastWrapperFor(final MethodSpec method, final TypeMirror recipient) {
final TypeMirror methodReturnType = elementHelper.getTypeElement(method.returnType.toString()).asType();
if (recipient.toString().equals("char")) {
return CodeBlock.of("(char) $N()", method);
} else if (recipient.toString().equals(Character.class.getCanonicalName())) {
return CodeBlock.of("($T) $N()", Character.class, method);
} else {
return CodeBlock.of("($T) $N()", methodReturnType, method);
}
}
示例3: enumGetterStatement
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
private CodeBlock enumGetterStatement(MemberModel member) {
String fieldName = member.getVariable().getVariableName();
if (member.isList()) {
ClassName valueEnumClass = poetExtensions.getModelClass(member.getListModel().getListMemberModel().getEnumType());
return CodeBlock.of("return $T.convert($N, $T::fromValue);", TypeConverter.class, fieldName, valueEnumClass);
} else if (member.isMap()) {
MapModel mapModel = member.getMapModel();
String keyEnumType = mapModel.getKeyModel().getEnumType();
String valueEnumType = mapModel.getValueModel().getEnumType();
CodeBlock keyConverter = keyEnumType != null ? enumConverterFunction(poetExtensions.getModelClass(keyEnumType))
: identityFunction();
CodeBlock valueConverter = valueEnumType != null ? enumConverterFunction(poetExtensions.getModelClass(valueEnumType))
: identityFunction();
CodeBlock entryPredicate = mapEntryFilter(keyEnumType);
return CodeBlock.builder()
.add("return $T.convert($N, ", TypeConverter.class, fieldName)
.add(keyConverter).add(", ")
.add(valueConverter).add(", ")
.add(entryPredicate).add(");")
.build();
} else {
ClassName enumClass = poetExtensions.getModelClass(member.getEnumType());
return CodeBlock.of("return $T.fromValue($N);", enumClass, fieldName);
}
}
示例4: getDimension
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getDimension(final String fieldName, final String indexReference, final String defValue) {
return CodeBlock.of("$L.$L = $L.getDimension($L, $L);", targetFieldName, fieldName, typedArrayName, indexReference, defValue);
}
示例5: getInteger
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getInteger(final String fieldName, final String idReference) {
return CodeBlock.of("$L.$L = $L.getInteger($L);", targetFieldName, fieldName, resoucesFieldName, idReference);
}
示例6: getString
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getString(final String fieldName, final String indexReference) {
return CodeBlock.of("$L.$L = $L.getString($L);", targetFieldName, fieldName, typedArrayName, indexReference);
}
示例7: getColorStateList
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getColorStateList(final String fieldName, final String idReference) {
return CodeBlock.of("$L.$L = $L.getColorStateList($L);", targetFieldName, fieldName, resoucesFieldName, idReference);
}
示例8: getFraction
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getFraction(final String fieldName, final String indexReference, final int base, final int pBase, final String defValue) {
return CodeBlock.of("$L.$L = $L.getFraction($L, $L, $L, $L);", targetFieldName, fieldName, typedArrayName, indexReference, base, pBase, defValue);
}
示例9: Id
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
Id(int value) {
this.value = value;
this.code = CodeBlock.of("$L", value);
this.qualifed = false;
}
示例10: getInt
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getInt(final String fieldName, final String indexReference, final String defValue) {
return CodeBlock.of("$L.$L = $L.getInt($L, $L);", targetFieldName, fieldName, typedArrayName, indexReference, defValue);
}
示例11: getDimensionPixelSize
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getDimensionPixelSize(final String fieldName, final String idReference) {
return CodeBlock.of("$L.$L = $L.getDimensionPixelSize($L);", targetFieldName, fieldName, resoucesFieldName, idReference);
}
示例12: getColorStateList
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getColorStateList(final String fieldName, final String indexReference) {
return CodeBlock.of("$L.$L = $L.getColorStateList($L);", targetFieldName, fieldName, typedArrayName, indexReference);
}
示例13: getString
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getString(final String fieldName, final String idReference) {
return CodeBlock.of("$L.$L = $L.getString($L);", targetFieldName, fieldName, resoucesFieldName, idReference);
}
示例14: getDimensionPixelOffset
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getDimensionPixelOffset(final String fieldName, final String idReference) {
return CodeBlock.of("$L.$L = $L.getDimensionPixelOffset($L);", targetFieldName, fieldName, resoucesFieldName, idReference);
}
示例15: getBoolean
import com.squareup.javapoet.CodeBlock; //导入方法依赖的package包/类
CodeBlock getBoolean(final String fieldName, final String indexReference, final String defValue) {
return CodeBlock.of("$L.$L = $L.getBoolean($L, $L);", targetFieldName, fieldName, typedArrayName, indexReference, defValue);
}