mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-10 12:20:09 +08:00
fit common collection interfaces
This commit is contained in:
parent
ea8f305152
commit
9b56e3d64a
@ -5,10 +5,7 @@ import com.alibaba.testable.core.model.Null;
|
|||||||
import com.alibaba.testable.core.util.TypeUtil;
|
import com.alibaba.testable.core.util.TypeUtil;
|
||||||
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author flin
|
* @author flin
|
||||||
@ -98,6 +95,13 @@ public class OmniConstructor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T newInterface(Class<T> clazz) {
|
private static <T> T newInterface(Class<T> clazz) {
|
||||||
|
if (clazz.equals(List.class)) {
|
||||||
|
return (T)Collections.emptyList();
|
||||||
|
} else if (clazz.equals(Map.class)) {
|
||||||
|
return (T)Collections.emptyMap();
|
||||||
|
} else if (clazz.equals(Set.class)) {
|
||||||
|
return (T)Collections.emptySet();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user