getTypeStr static method
cover dart type to java type
wantAddPre
if true, it when add pre keywords, like: public static final .....
Implementation
static String getTypeStr(
Property property, {
bool wantAddPre = false,
bool showNullTag = true,
}) {
String typeStr;
var baseType = TypeUtils.javaMap[property.type];
if (baseType != null) {
//base
typeStr = baseType;
} else {
//other not base type
typeStr = property.type.split(".").last;
}
if (showNullTag && typeStr != "void") {
typeStr = (property.canBeNull ? " @Nullable " : " @NotNull ") + typeStr;
}
if (property.subType.isNotEmpty) {
typeStr += "<";
property.subType.forEach((element) {
typeStr += getTypeStr(element, showNullTag: false) + ", ";
});
if (typeStr.endsWith(", ")) {
//remove ", " ,because java method arg can't end with ", "
typeStr = typeStr.substring(0, typeStr.length - 2);
}
typeStr += ">";
}
if (wantAddPre) {
if (property.isConst) {
typeStr = " final " + typeStr;
}
if (property.isStatic) {
typeStr = " static " + typeStr;
}
if (property.isPrivate) {
typeStr = " private " + typeStr;
} else {
typeStr = " public " + typeStr;
}
}
return typeStr;
}