当前位置: 首页>>代码示例>>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;未经允许,请勿转载。