mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-09 20:00:21 +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 java.lang.reflect.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author flin
|
||||
@ -98,6 +95,13 @@ public class OmniConstructor {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user