JDK1.8特性(更新中..)
“15,5,9,17,99,107,47”转List<Long>
List<Long> linkCompanyIds = Arrays.asList("15,5,9,17,99,107,47".split(",")).stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
15, 16, 1, 89, 9, 89, 9, 16, 15 去重,排序 后 转 List<Integer>
List<Integer> list = Arrays.asList(15, 16, 1, 89, 9, 89, 9, 16, 15); list.stream().distinct().sorted((Integer s1, Integer s2) -> s1 - s2).forEach(System.out::println);
对 List<Map<String,Object>> 中的 日期排序 及 字段过滤(针对KUDU返回数据)
data.stream().filter((p) -> MapUtils.getDouble(p, "saraly") > 15000) .sorted((Map<String, Object> d1, Map<String, Object> d2) -> MapUtils.getLong(d2, "createTime") .compareTo(MapUtils.getLong(d1, "createTime"))) .forEach(i -> System.out.println(new Gson().toJson(i)));