<p>List<Object> objects = dataResults.toJavaList(Object.class);\nList&lt;Sz_device&gt; query = szDeviceService.query(Cnd.where(&quot;deviceType&quot;, &quot;=&quot;, &quot;energy&quot;));\nList&lt;Sz_device&gt; result = objects.stream().filter(obj -&gt; obj instanceof Map).map(obj -&gt; (Map&lt;String, Object&gt;) obj).filter(map -&gt; map.containsKey(&quot;metername&quot;)).filter(map -&gt; query.stream().noneMatch(device -&gt; device.getName().equals(map.get(&quot;metername&quot;)))).map(map -&gt; {\nSz_device device = new Sz_device();\ndevice.setName(map.get(&quot;metername&quot;).toString());\nreturn device;\n}).collect(Collectors.toList());</p>
Java Stream API: Filtering Objects based on Key-Value Comparison

原文地址: https://www.cveoy.top/t/topic/pHaT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录