本文整理汇总了Java中com.leansoft.mxjc.model.TypeInfo.isArray方法的典型用法代码示例。如果您正苦于以下问题:Java TypeInfo.isArray方法的具体用法?Java TypeInfo.isArray怎么用?Java TypeInfo.isArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.leansoft.mxjc.model.TypeInfo
的用法示例。
在下文中一共展示了TypeInfo.isArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFieldImports
import com.leansoft.mxjc.model.TypeInfo; //导入方法依赖的package包/类
private Set<String> getFieldImports(ClassInfo clazz) {
Set<String> imports = new HashSet<String>();
for(FieldInfo field : clazz.getFields()) {
TypeInfo fieldType = field.getType();
if (fieldType.isArray()) {
TypeInfo elementType = fieldType.getElementType();
if (elementType != null && !elementType.isPrimitive() && !elementType.isEnum()) {
imports.add(elementType.getFullName());
}
} else {
if (!fieldType.isPrimitive() && !fieldType.isEnum() && !fieldType.isCollection()) {
imports.add(fieldType.getFullName());
}
}
// import type parameters
for(TypeInfo paraType : fieldType.getTypeParameters()) { // object type
if (!paraType.isPrimitive() && !paraType.isEnum() && !field.isAny()) {
imports.add(paraType.getFullName());
}
}
}
return imports;
}
示例2: adjustPackageNameOfNestClass
import com.leansoft.mxjc.model.TypeInfo; //导入方法依赖的package包/类
private void adjustPackageNameOfNestClass(List<ClassInfo> classes) {
for(ClassInfo classInfo : classes) {
// adjust class
if (classInfo.isNestClass()) {
String pkgName = classInfo.getPackageName().toLowerCase();
classInfo.setPackageName(pkgName);
classInfo.setFullName(pkgName + "." + classInfo.getName());
}
// adjust fields
for(FieldInfo fieldInfo : classInfo.getFields()) {
TypeInfo attrType = fieldInfo.getType();
// no need to handle primitive type
if (attrType.isPrimitive())
continue;
// handle array
if (attrType.isArray()) {
// T of T[]
TypeInfo elementType = attrType.getElementType();
// no need to handle primitive type
if (elementType.isPrimitive()) {
continue;
}
if (elementType.isNestClass()) {
String elementTypePackageName = ClassNameUtil
.getPackageName(elementType.getFullName());
elementTypePackageName = elementTypePackageName.toLowerCase();
elementType.setFullName(elementTypePackageName + "." + elementType.getName());
}
continue;
}
if (attrType.isNestClass()) {
String attrTypePackageName = ClassNameUtil.getPackageName(attrType.getFullName());
attrTypePackageName = attrTypePackageName.toLowerCase();
attrType.setFullName(attrTypePackageName + "." + attrType.getName());
}
// has type parameters?
for (TypeInfo paramType : attrType.getTypeParameters()) {
if (paramType.isNestClass()) {
String paramTypePackageName = ClassNameUtil
.getPackageName(paramType.getFullName());
paramTypePackageName = paramTypePackageName.toLowerCase();
paramType.setFullName(paramTypePackageName + "." + paramType.getName());
}
}
}
}
}
示例3: getClassImports
import com.leansoft.mxjc.model.TypeInfo; //导入方法依赖的package包/类
/**
*
* helper to find out all classes that should be imported by a class
*
* @param clazz
* , ClassInfo instance
* @return a set of class names that should be imported
*/
private Set<String> getClassImports(ClassInfo clazz) {
Set<String> imports = new HashSet<String>();
String clazzPackageName = clazz.getPackageName();
// extends super class?
if (clazz.getSuperClass() != null) {
TypeInfo superClassType = clazz.getSuperClass();
String superClassTypePackageName = ClassNameUtil
.getPackageName(superClassType.getFullName());
if (needImport(clazzPackageName, superClassTypePackageName)) {
imports.add(ClassNameUtil.erase(superClassType.getFullName()));
}
}
// import field type
for (FieldInfo field : clazz.getFields()) {
TypeInfo attrType = field.getType();
String attrTypePackageName = ClassNameUtil.getPackageName(attrType.getFullName());
// no import for primitive type
if (attrType.isPrimitive())
continue;
// import component type of array
if (attrType.isArray()) {
// T of T[]
TypeInfo elementType = attrType.getElementType();
// no import for primitive type
if (elementType.isPrimitive()) {
continue;
}
String elementTypePackageName = ClassNameUtil
.getPackageName(elementType.getFullName());
if (needImport(clazzPackageName, elementTypePackageName)) {
imports.add(ClassNameUtil.erase(elementType.getFullName()));
}
continue;
}
if (needImport(clazzPackageName, attrTypePackageName)) {
// erase type parameters before import
imports.add(ClassNameUtil.erase(attrType.getFullName()));
}
// has type parameters?
for (TypeInfo paramType : attrType.getTypeParameters()) {
String paramTypePackageName = ClassNameUtil
.getPackageName(paramType.getFullName());
if (needImport(clazzPackageName, paramTypePackageName)) {
// erase type parameters before import
imports.add(ClassNameUtil.erase(paramType.getFullName()));
}
}
}
return imports;
}