本文整理汇总了Java中com.squareup.javapoet.TypeName.INT属性的典型用法代码示例。如果您正苦于以下问题:Java TypeName.INT属性的具体用法?Java TypeName.INT怎么用?Java TypeName.INT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.squareup.javapoet.TypeName
的用法示例。
在下文中一共展示了TypeName.INT属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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";
}
}
示例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);
}
}
示例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 "";
}
示例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);
}
}
示例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 "";
}
示例7: 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;
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: 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);
}
示例11: 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);
}
}
示例12: getTypeName
@Override
public TypeName getTypeName() {
return (isPrimitive ? TypeName.INT : ClassName.get(Integer.class));
}