本文整理汇总了Java中com.squareup.javapoet.TypeName.isBoxedPrimitive方法的典型用法代码示例。如果您正苦于以下问题:Java TypeName.isBoxedPrimitive方法的具体用法?Java TypeName.isBoxedPrimitive怎么用?Java TypeName.isBoxedPrimitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.javapoet.TypeName
的用法示例。
在下文中一共展示了TypeName.isBoxedPrimitive方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isPrimitiveArray
import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static boolean isPrimitiveArray(Element element) {
if (element.asType().getKind() != TypeKind.ARRAY) {
return false;
}
ArrayType arrayType = (ArrayType) element.asType();
TypeMirror componentType = arrayType.getComponentType();
TypeName typeName = TypeName.get(componentType);
return typeName.isPrimitive() || typeName.isBoxedPrimitive();
}
示例2: checkIfTypeIsSupported
import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
private void checkIfTypeIsSupported(VariableElement variableElement) {
final TypeName typeOfCurrentElement = ClassName.get(variableElement.asType());
if (!typeOfCurrentElement.equals(ClassName.get(String.class)) &&
!typeOfCurrentElement.equals(BYTE_ARRAY_TYPE) &&
!typeOfCurrentElement.isPrimitive() &&
!typeOfCurrentElement.isBoxedPrimitive()) {
throwError("SlimOrm: Type " + typeOfCurrentElement + " is not supported");
} else if ((typeOfCurrentElement.isPrimitive() || typeOfCurrentElement.isBoxedPrimitive())
&& (typeOfCurrentElement.unbox().equals(TypeName.BYTE) || typeOfCurrentElement.unbox().equals(TypeName.CHAR))) {
throwError("SlimOrm: Type " + typeOfCurrentElement + " is not supported");
}
}
示例3: isSupportedType
import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static boolean isSupportedType(TypeName type) {
return type.isPrimitive() || type.isBoxedPrimitive() || SUPPORTED_TYPES.contains(type);
}
示例4: isPrimitive
import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static boolean isPrimitive(TypeName typeName) {
return typeName.isPrimitive() || typeName.isBoxedPrimitive();
}
示例5: isValidType
import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static boolean isValidType(TypeName typeName) {
return typeName.isPrimitive() || typeName.isBoxedPrimitive() || VALID_TYPES.contains(typeName);
}
示例6: isPrimitiveOrWrapper
import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static boolean isPrimitiveOrWrapper(TypeMirror type) {
TypeName typeName = TypeName.get(type);
return typeName.isPrimitive() || typeName.isBoxedPrimitive();
}
示例7: createDefaultBinding
import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
private static void createDefaultBinding(final String containingClassFieldName, final String contextFieldName, final StyleableField field, final MethodSpec.Builder builder) {
final ResourcesWriter resWriter = ResourcesWriter.writer(containingClassFieldName, RESOURCES_FIELD_NAME);
final PixelConverterWriter pixelWriter = PixelConverterWriter.writer(containingClassFieldName, contextFieldName);
final TypeName typeName = field.getTypeName();
int exceptionCount = 0;
if (typeName.isBoxedPrimitive() || typeName.isPrimitive()) {
final TypeName unboxedTypeName = typeName.unbox();
if (unboxedTypeName.equals(TypeName.BOOLEAN)) {
builder.addCode(resWriter.getBoolean(field.getName(), field.getDefaultValue()));
} else if (unboxedTypeName.equals(TypeName.INT)) {
// getColor(), getDimensionPixelOffset(), getDimensionPixelSize(), getInteger()
if (field.isColorInt()) {
builder.addCode(resWriter.getColor(field.getName(), field.getDefaultValue()));
} else if (field.isDimension()) {
StyleableField.DimensionUnit unit = field.getDimensionUnit();
if (unit == null || unit == StyleableField.DimensionUnit.PX) {
builder.addCode(resWriter.getDimensionPixelOffset(field.getName(), field.getDefaultValue()));
} else if (unit == StyleableField.DimensionUnit.DP) {
builder.addCode(resWriter.getDimensionPixelOffset(field.getName(), field.getDefaultValue()));
builder.addCode("\n");
builder.addCode(pixelWriter.convertPixelToDp(field.getName()));
} else if (unit == StyleableField.DimensionUnit.SP) {
builder.addCode(resWriter.getDimensionPixelSize(field.getName(), field.getDefaultValue()));
builder.addCode("\n");
builder.addCode(pixelWriter.convertPixelToDp(field.getName()));
}
} else {
builder.beginControlFlow("try");
builder.addCode(resWriter.getColor(field.getName(), field.getDefaultValue()));
builder.addCode("\n");
builder.nextControlFlow("catch (Exception e$L)", exceptionCount);
exceptionCount++;
builder.beginControlFlow("try");
builder.addCode(resWriter.getDimensionPixelOffset(field.getName(), field.getDefaultValue()));
builder.addCode("\n");
builder.nextControlFlow("catch (Exception e$L)", exceptionCount);
builder.addCode(resWriter.getInteger(field.getName(), field.getDefaultValue()));
builder.addCode("\n");
builder.endControlFlow();
builder.endControlFlow();
}
} else if (unboxedTypeName.equals(TypeName.FLOAT)) {
if (field.isDimension()) {
builder.addCode(resWriter.getDimension(field.getName(), field.getDefaultValue()));
} else {
builder.beginControlFlow("try");
builder.addCode(resWriter.getDimension(field.getName(), field.getDefaultValue()));
builder.addCode("\n");
builder.nextControlFlow("catch (Exception e$L)", exceptionCount);
builder.addCode(resWriter.getFraction(field.getName(), field.getDefaultValue(), 0, 1));
builder.addCode("\n");
builder.endControlFlow();
}
}
} else if (typeName.equals(COLOR_STATE_LIST)) {
builder.addCode(resWriter.getColorStateList(field.getName(), field.getDefaultValue()));
} else if (typeName.equals(DRAWABLE)) {
builder.addCode(resWriter.getDrawable(field.getName(), field.getDefaultValue()));
} else if (typeName.equals(CHAR_SEQUENCE)) {
builder.addCode(resWriter.getText(field.getName(), field.getDefaultValue()));
} else if (typeName.equals(CHAR_SEQUENCE_ARRAY)) {
builder.addCode(resWriter.getTextArray(field.getName(), field.getDefaultValue()));
} else if (typeName.equals(STRING)) {
builder.addCode(resWriter.getString(field.getName(), field.getDefaultValue()));
}
builder.addCode("\n");
}