本文整理匯總了Java中com.squareup.javapoet.TypeName.CHAR屬性的典型用法代碼示例。如果您正苦於以下問題:Java TypeName.CHAR屬性的具體用法?Java TypeName.CHAR怎麽用?Java TypeName.CHAR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.squareup.javapoet.TypeName
的用法示例。
在下文中一共展示了TypeName.CHAR屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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);
}
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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);
}
示例8: 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);
}
}