狗市代码

47 阅读1分钟
public String judgeType(Object o){
    if(o instanceof List
          && !((List<?>) o).isEmpty()
          && ((List<?>) o).get(0) instanceof Map
          && ((List<Map<?, ?>>) o).get(0).keySet().stream().allMatch(key -> key instanceof String)) {
       return "List<Map<String,Object>>";
    }
    else if(o instanceof Map
          &&((Map<?, ?>) o).keySet().stream().allMatch(key -> key instanceof String)){
       return "Map<String,Object>";
    }else{
       return "error";
    }
}
```