當前位置: 首頁>>代碼示例>>Java>>正文


Java CodeBlock.of方法代碼示例

本文整理匯總了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]));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:ProcessorUtil.java

示例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);
	}
}
 
開發者ID:MatthewTamlin,項目名稱:Spyglass,代碼行數:14,代碼來源:CastWrapperGenerator.java

示例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);
    }
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:30,代碼來源:AwsServiceModel.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:TypedArrayWriter.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:ResourcesWriter.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:TypedArrayWriter.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:ResourcesWriter.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:TypedArrayWriter.java

示例9: Id

import com.squareup.javapoet.CodeBlock; //導入方法依賴的package包/類
Id(int value) {
    this.value = value;
    this.code = CodeBlock.of("$L", value);
    this.qualifed = false;
}
 
開發者ID:hendraanggrian,項目名稱:r-parser,代碼行數:6,代碼來源:Id.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:TypedArrayWriter.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:ResourcesWriter.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:TypedArrayWriter.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:ResourcesWriter.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:ResourcesWriter.java

示例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);
}
 
開發者ID:chRyNaN,項目名稱:glimpse,代碼行數:4,代碼來源:TypedArrayWriter.java


注:本文中的com.squareup.javapoet.CodeBlock.of方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。