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


Java TypeName.unbox方法代码示例

本文整理汇总了Java中com.squareup.javapoet.TypeName.unbox方法的典型用法代码示例。如果您正苦于以下问题:Java TypeName.unbox方法的具体用法?Java TypeName.unbox怎么用?Java TypeName.unbox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.javapoet.TypeName的用法示例。


在下文中一共展示了TypeName.unbox方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unbox

import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
private static TypeName unbox(TypeName typeName) {
    try {
        return typeName.unbox();
    } catch (UnsupportedOperationException e) {
        return typeName;
    }
}
 
开发者ID:srym,项目名称:vulture,代码行数:8,代码来源:TypeUtils.java

示例2: unbox

import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
@Nonnull
@CheckReturnValue
static TypeName unbox(@Nonnull TypeName typeName) {
    try {
        return typeName.unbox();
    } catch (Exception e) {
        return typeName;
    }
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:10,代码来源:PsiTypeConverter.java

示例3: unbox

import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
public static TypeName unbox(TypeName typeName) {
    try {
        return typeName.unbox();
    } catch (Exception e) {
        return typeName;
    }
}
 
开发者ID:florent37,项目名称:RxAndroidOrm,代码行数:8,代码来源:ProcessUtils.java

示例4: getPropertyExtractor

import com.squareup.javapoet.TypeName; //导入方法依赖的package包/类
private static CodeBlock.Builder getPropertyExtractor(
    PropertyInfo info,
    CodeBlock.Builder builder) {
  TypeName propertyType = info.propertyType;
  if (propertyType.equals(STRING_TYPE)) {
    return builder.add("props.getString(name)");
  } else if (propertyType.equals(READABLE_ARRAY_TYPE)) {
    return builder.add("props.getArray(name)");
  } else if (propertyType.equals(READABLE_MAP_TYPE)) {
    return builder.add("props.getMap(name)");
  } else if (propertyType.equals(DYNAMIC_TYPE)) {
    return builder.add("props.getDynamic(name)");
  }

  if (BOXED_PRIMITIVES.contains(propertyType)) {
    propertyType = propertyType.unbox();
  }

  if (propertyType.equals(TypeName.BOOLEAN)) {
    return builder.add("props.getBoolean(name, $L)", info.mProperty.defaultBoolean());
  } if (propertyType.equals(TypeName.DOUBLE)) {
    double defaultDouble = info.mProperty.defaultDouble();
    if (Double.isNaN(defaultDouble)) {
      return builder.add("props.getDouble(name, $T.NaN)", Double.class);
    } else {
      return builder.add("props.getDouble(name, $Lf)", defaultDouble);
    }
  }
  if (propertyType.equals(TypeName.FLOAT)) {
    float defaultFloat = info.mProperty.defaultFloat();
    if (Float.isNaN(defaultFloat)) {
      return builder.add("props.getFloat(name, $T.NaN)", Float.class);
    } else {
      return builder.add("props.getFloat(name, $Lf)", defaultFloat);
    }
  }
  if (propertyType.equals(TypeName.INT)) {
    return builder.add("props.getInt(name, $L)", info.mProperty.defaultInt());
  }

  throw new IllegalArgumentException();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:43,代码来源:ReactPropertyProcessor.java

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