当前位置: 首页>>代码示例>>Java>>正文


Java TypeName.isBoxedPrimitive方法代码示例

本文整理汇总了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();
}
 
开发者ID:srym,项目名称:vulture,代码行数:12,代码来源:TypeUtils.java

示例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");
    }
}
 
开发者ID:Neristance,项目名称:slimorm,代码行数:15,代码来源:SlimOrmProcessor.java

示例3: isSupportedType

import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static boolean isSupportedType(TypeName type) {
  return type.isPrimitive() || type.isBoxedPrimitive() || SUPPORTED_TYPES.contains(type);
}
 
开发者ID:setheclark,项目名称:auto-value-json,代码行数:4,代码来源:JsonGeneratorUtils.java

示例4: isPrimitive

import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static boolean isPrimitive(TypeName typeName) {
    return typeName.isPrimitive() || typeName.isBoxedPrimitive();
}
 
开发者ID:srym,项目名称:vulture,代码行数:4,代码来源:TypeUtils.java

示例5: isValidType

import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static boolean isValidType(TypeName typeName) {
    return typeName.isPrimitive() || typeName.isBoxedPrimitive() || VALID_TYPES.contains(typeName);
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:4,代码来源:Parcelables.java

示例6: isPrimitiveOrWrapper

import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static boolean isPrimitiveOrWrapper(TypeMirror type) {
    TypeName typeName = TypeName.get(type);

    return typeName.isPrimitive() || typeName.isBoxedPrimitive();
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:6,代码来源:TypeUtil.java

示例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");
}
 
开发者ID:chRyNaN,项目名称:glimpse,代码行数:72,代码来源:StyleableAttributeClassCreator.java


注:本文中的com.squareup.javapoet.TypeName.isBoxedPrimitive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。