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


Java TypeName.BOOLEAN属性代码示例

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


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

示例1: bestGuess

private static TypeName bestGuess(String type) {
  switch (type) {
    case "void": return TypeName.VOID;
    case "boolean": return TypeName.BOOLEAN;
    case "byte": return TypeName.BYTE;
    case "char": return TypeName.CHAR;
    case "double": return TypeName.DOUBLE;
    case "float": return TypeName.FLOAT;
    case "int": return TypeName.INT;
    case "long": return TypeName.LONG;
    case "short": return TypeName.SHORT;
    default:
      int left = type.indexOf('<');
      if (left != -1) {
        ClassName typeClassName = ClassName.bestGuess(type.substring(0, left));
        List<TypeName> typeArguments = new ArrayList<>();
        do {
          typeArguments.add(WildcardTypeName.subtypeOf(Object.class));
          left = type.indexOf('<', left + 1);
        } while (left != -1);
        return ParameterizedTypeName.get(typeClassName,
            typeArguments.toArray(new TypeName[typeArguments.size()]));
      }
      return ClassName.bestGuess(type);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:BindingSet.java

示例2: defaultValue

private String defaultValue(JsonProperty property, TypeName type) {
  if (property.defaultValue != null) {
    return property.defaultValue;
  }
  if (type == TypeName.BOOLEAN) {
    return "false";
  } else if (type == TypeName.BYTE) {
    return "(byte) 0";
  } else if (type == TypeName.SHORT) {
    return "0";
  } else if (type == TypeName.INT) {
    return "0";
  } else if (type == TypeName.LONG) {
    return "0L";
  } else if (type == TypeName.CHAR) {
    return "'\0'";
  } else if (type == TypeName.FLOAT) {
    return "0.0f";
  } else if (type == TypeName.DOUBLE) {
    return "0.0d";
  } else {
    return "null";
  }
}
 
开发者ID:setheclark,项目名称:auto-value-json,代码行数:24,代码来源:AutoValueJsonExtension.java

示例3: convertClass

private static TypeName convertClass(String originClazz) {
    switch (originClazz) {
        case "int":
            return TypeName.INT;
        case "long":
            return TypeName.LONG;
        case "float":
            return TypeName.FLOAT;
        case "double":
            return TypeName.DOUBLE;
        case "short":
            return TypeName.SHORT;
        case "boolean":
            return TypeName.BOOLEAN;
        case "char":
            return TypeName.CHAR;
        default:
            return ClassName.bestGuess(originClazz);
    }
}
 
开发者ID:bboylin,项目名称:D-Router,代码行数:20,代码来源:RouterProcessor.java

示例4: mapTypeToCursorGetMethod

private String mapTypeToCursorGetMethod(TypeName typeName) {
    if (typeName == TypeName.BOOLEAN) {
        return "getInt";
    } else if (typeName == TypeName.SHORT) {
        return "getShort";
    } else if (typeName == TypeName.INT) {
        return "getInt";
    } else if (typeName == TypeName.LONG) {
        return "getLong";
    } else if (typeName == TypeName.FLOAT) {
        return "getFloat";
    } else if (typeName == TypeName.DOUBLE) {
        return "getDouble";
    }
    return "";
}
 
开发者ID:Neristance,项目名称:slimorm,代码行数:16,代码来源:SlimOrmProcessor.java

示例5: classToTypeName

public static TypeName classToTypeName(Class scalar) {
    if (scalar.isPrimitive()) {
        switch (scalar.getSimpleName()) {
            case "int":
                return TypeName.INT;

            case "boolean":
                return TypeName.BOOLEAN;

            case "double":
                return TypeName.DOUBLE;

            case "float":
                return TypeName.FLOAT;

            case "byte":
                return TypeName.BYTE;

            case "char":
                return TypeName.CHAR;

            case "short":
                return TypeName.SHORT;

            case "long":
                return TypeName.LONG;

            case "void":
                return TypeName.VOID; // ?

            default:
                throw new GenerationException("can't handle type: " + scalar);
        }
    } else {
        return ClassName.get(scalar);
    }
}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:37,代码来源:Scalars.java

示例6: getFieldType

public static String getFieldType(VariableElement variableElement) {
    TypeName typeName = getFieldClass(variableElement);
    if (typeName == TypeName.INT || typeName == TypeName.BOOLEAN || typeName == TypeName.BYTE) {
        return "Int";
    } else if (typeName == TypeName.LONG) {
        return "Long";
    } else if (typeName == TypeName.FLOAT) {
        return "Float";
    } else if (typeName == TypeName.DOUBLE) {
        return "Double";
    } else if (ClassName.get(String.class).equals(typeName)) {
        return "String";
    }
    return "";
}
 
开发者ID:florent37,项目名称:RxAndroidOrm,代码行数:15,代码来源:ProcessUtils.java

示例7: getFieldCast

public static String getFieldCast(VariableElement variableElement) {
    TypeName typeName = getFieldClass(variableElement);
    if (typeName == TypeName.BOOLEAN) {
        return "(1 == %s)";
    }
    return "%s";
}
 
开发者ID:florent37,项目名称:RxAndroidOrm,代码行数:7,代码来源:ProcessUtils.java

示例8: getFieldTableType

public static String getFieldTableType(Element variableElement) {
    TypeName typeName = getFieldClass(variableElement);
    if (typeName == TypeName.INT
        || typeName == TypeName.BOOLEAN
        || typeName == TypeName.LONG
        || typeName == TypeName.BYTE) {
        return "integer";
    }
    if (typeName == TypeName.FLOAT) {
        return "real";
    } else if (ClassName.get(String.class).equals(typeName) || isDate(typeName)) {
        return "text";
    }
    return null;
}
 
开发者ID:florent37,项目名称:RxAndroidOrm,代码行数:15,代码来源:ProcessUtils.java

示例9: getQueryCast

public static String getQueryCast(VariableElement variableElement) {
    TypeName typeName = getFieldClass(variableElement);
    if (ClassName.get(String.class).equals(typeName)) {
        return "$L";
    } else if (typeName == TypeName.BOOLEAN || typeName.equals(TypeName.get(Boolean.class))) {
        return "String.valueOf($L ? 1 : 0)";
    } else {
        return "String.valueOf($L)";
    }
}
 
开发者ID:florent37,项目名称:RxAndroidOrm,代码行数:10,代码来源:ProcessUtils.java

示例10: bestGuess

public static TypeName bestGuess(String type) {
    switch (type) {
        case "void":
            return TypeName.VOID;
        case "boolean":
            return TypeName.BOOLEAN;
        case "byte":
            return TypeName.BYTE;
        case "char":
            return TypeName.CHAR;
        case "double":
            return TypeName.DOUBLE;
        case "float":
            return TypeName.FLOAT;
        case "int":
            return TypeName.INT;
        case "long":
            return TypeName.LONG;
        case "short":
            return TypeName.SHORT;
        default:
            int left = type.indexOf('<');
            if (left != -1) {
                ClassName typeClassName = ClassName.bestGuess(type.substring(0, left));
                List<TypeName> typeArguments = new ArrayList<>();
                do {
                    typeArguments.add(WildcardTypeName.subtypeOf(Object.class));
                    left = type.indexOf('<', left + 1);
                } while (left != -1);
                return ParameterizedTypeName.get(typeClassName,
                        typeArguments.toArray(new TypeName[typeArguments.size()]));
            }
            return ClassName.bestGuess(type);
    }
}
 
开发者ID:wangjiegulu,项目名称:RapidRouter,代码行数:35,代码来源:EasyType.java

示例11: bestGuessDeep

/**
 * @param type
 * @return
 */
public static TypeName bestGuessDeep(String type) {
    switch (type) {
        case "void":
            return TypeName.VOID;
        case "boolean":
            return TypeName.BOOLEAN;
        case "byte":
            return TypeName.BYTE;
        case "char":
            return TypeName.CHAR;
        case "double":
            return TypeName.DOUBLE;
        case "float":
            return TypeName.FLOAT;
        case "int":
            return TypeName.INT;
        case "long":
            return TypeName.LONG;
        case "short":
            return TypeName.SHORT;
        default:
            int left = type.indexOf('<');
            int right = type.indexOf('>');
            if (-1 != left && -1 != right) {
                ClassName typeClassName = ClassName.bestGuess(type.substring(0, left));
                List<TypeName> typeArguments = new ArrayList<>();
                do {
                    typeArguments.add(WildcardTypeName.subtypeOf(bestGuess(type.substring(left + 1, right))));
                    left = type.indexOf('<', left + 1);
                    right = type.indexOf('>', right - 1);
                } while (left != -1);
                return ParameterizedTypeName.get(typeClassName,
                        typeArguments.toArray(new TypeName[typeArguments.size()]));
            }
            return ClassName.bestGuess(type);
    }
}
 
开发者ID:wangjiegulu,项目名称:RapidRouter,代码行数:41,代码来源:EasyType.java

示例12: getTypeName

public static TypeName getTypeName(String type){
    switch (type){
        case NAME_int:
            return TypeName.INT;

        case NAME_long:
            return TypeName.LONG;

        case NAME_short:
            return TypeName.SHORT;

        case NAME_byte:
            return TypeName.BYTE;

        case NAME_boolean:
            return TypeName.BOOLEAN;

        case NAME_float:
            return TypeName.FLOAT;

        case NAME_double:
            return TypeName.DOUBLE;

        case NAME_char:
            return TypeName.CHAR;

        case NAME_void:
            return TypeName.VOID;
    }
    return ClassName.bestGuess(type);
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:31,代码来源:TypeUtils.java

示例13: bestGuess

private static TypeName bestGuess(String type) {
    switch (type) {
        case "void":
            return TypeName.VOID;
        case "boolean":
            return TypeName.BOOLEAN;
        case "byte":
            return TypeName.BYTE;
        case "char":
            return TypeName.CHAR;
        case "double":
            return TypeName.DOUBLE;
        case "float":
            return TypeName.FLOAT;
        case "int":
            return TypeName.INT;
        case "long":
            return TypeName.LONG;
        case "short":
            return TypeName.SHORT;
        default:
            int left = type.indexOf('<');
            if (left != -1) {
                ClassName typeClassName = ClassName.bestGuess(type.substring(0, left));
                List<TypeName> typeArguments = new ArrayList<>();
                do {
                    typeArguments.add(WildcardTypeName.subtypeOf(Object.class));
                    left = type.indexOf('<', left + 1);
                } while (left != -1);
                return ParameterizedTypeName.get(typeClassName,
                        typeArguments.toArray(new TypeName[typeArguments.size()]));
            }
            return ClassName.bestGuess(type);
    }
}
 
开发者ID:qq542391099,项目名称:butterknife-parent,代码行数:35,代码来源:BindingSet.java

示例14: addPrimitiveType

private void addPrimitiveType(VariableElement element, MethodSpec.Builder methodBuilder) {

        Field field = element.getAnnotation(Field.class);
        final TypeName typeName = ClassName.get(element.asType());

        if (typeName == TypeName.BOOLEAN) {
            methodBuilder.addStatement("row.$L = cursor." + mapTypeToCursorGetMethod(typeName) + "(cursor.getColumnIndex($S)) == 1", element.getSimpleName(), field.columnName());
        } else {
            methodBuilder.addStatement("row.$L = cursor." + mapTypeToCursorGetMethod(typeName) + "(cursor.getColumnIndex($S))", element.getSimpleName(), field.columnName());
        }
    }
 
开发者ID:Neristance,项目名称:slimorm,代码行数:11,代码来源:SlimOrmProcessor.java

示例15: getTypeName

@Override
public TypeName getTypeName() {
    return (isPrimitive ? TypeName.BOOLEAN : ClassName.get(Boolean.class));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:BooleanFieldType.java


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