mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-24 19:31:17 +08:00
don't travel into basic class
This commit is contained in:
parent
9871a96db0
commit
52878364ee
@ -105,7 +105,7 @@ public class OmniAccessor {
|
||||
}
|
||||
|
||||
private static List<String> generateMemberIndex(Class<?> clazz, String basePath, Set<Class<?>> classPool) {
|
||||
if (isAtomicType(clazz)) {
|
||||
if (TypeUtil.isBasicType(clazz)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
classPool.add(clazz);
|
||||
@ -121,13 +121,6 @@ public class OmniAccessor {
|
||||
return paths;
|
||||
}
|
||||
|
||||
private static boolean isAtomicType(Class<?> clazz) {
|
||||
return clazz.isEnum() || clazz.equals(Integer.class) || clazz.equals(Short.class) || clazz.equals(Long.class)
|
||||
|| clazz.equals(Byte.class) || clazz.equals(Character.class) || clazz.equals(Float.class)
|
||||
|| clazz.equals(Double.class) || clazz.equals(Boolean.class) || clazz.equals(Class.class)
|
||||
|| clazz.equals(String.class);
|
||||
}
|
||||
|
||||
private static String toPath(Field field) {
|
||||
return field.getName() + BRACE_START + field.getType().getSimpleName() + BRACE_END;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class OmniConstructor {
|
||||
for (int i = 0; i < Array.getLength(fieldIns); i++) {
|
||||
handleCircleReference(Array.get(fieldIns, i), classPool);
|
||||
}
|
||||
} else if (!fieldType.isPrimitive() && !fieldType.isEnum()) {
|
||||
} else if (!fieldType.isPrimitive() && !TypeUtil.isBasicType(fieldType)) {
|
||||
if (fieldIns == null && classPool.containsKey(fieldType)) {
|
||||
f.set(instance, classPool.get(fieldType));
|
||||
} else if (fieldIns != null && !classPool.containsKey(fieldType)) {
|
||||
|
@ -99,6 +99,17 @@ public class TypeUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* whether class is a system basic type
|
||||
* @param clazz type to check
|
||||
*/
|
||||
public static boolean isBasicType(Class<?> clazz) {
|
||||
return clazz.isEnum() || clazz.equals(Integer.class) || clazz.equals(Short.class) || clazz.equals(Long.class)
|
||||
|| clazz.equals(Byte.class) || clazz.equals(Character.class) || clazz.equals(Float.class)
|
||||
|| clazz.equals(Double.class) || clazz.equals(Boolean.class) || clazz.equals(Class.class)
|
||||
|| clazz.equals(String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* type equals
|
||||
* @param classesLeft class to be compared
|
||||
|
Loading…
Reference in New Issue
Block a user