<p>List<Object> objects = dataResults.toJavaList(Object.class);
List&lt;Sz_device&gt; query = szDeviceService.query(Cnd.where(&quot;deviceType&quot;, &quot;=&quot;, &quot;energy&quot;));
List&lt;Sz_device&gt; result = objects.stream()
.filter(obj -&gt; obj instanceof Map) // Filter objects that are of type Map
.map(obj -&gt; (Map&lt;String, Object&gt;) obj) // Cast object to Map
.filter(map -&gt; map.containsKey(&quot;metername&quot;)) // Filter maps that contain key &quot;metername&quot;
.filter(map -&gt; query.stream().noneMatch(device -&gt; device.getName().equals(map.get(&quot;metername&quot;)))) // Filter maps where the value of &quot;metername&quot; is not present in query list
.map(map -&gt; {
Sz_device device = new Sz_device();
device.setName(map.get(&quot;metername&quot;).toString()); // Set name to &quot;metername&quot; value
return device;
})
.collect(Collectors.toList()); // Collect the filtered Sz_device objects into a list named resul</p>
java ListObject objects = dataResultstoJavaListObjectclass; ListSz_device query = szDeviceServicequeryCndwheredeviceType = energy; ListSz_device result = new ArrayList;请用stream流

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

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