Use stream

This commit is contained in:
Volodymyr Babak 2021-05-18 11:09:52 +03:00
parent bb064cbbbd
commit c081f9b8d3

View File

@ -133,6 +133,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Data @Data
@ -430,14 +431,10 @@ public final class EdgeGrpcSession implements Closeable {
} }
private List<DownlinkMsg> convertToDownlinkMsgsPack(List<EdgeEvent> edgeEvents) { private List<DownlinkMsg> convertToDownlinkMsgsPack(List<EdgeEvent> edgeEvents) {
List<DownlinkMsg> result = new ArrayList<>(); return edgeEvents
for (EdgeEvent edgeEvent : edgeEvents) { .stream()
DownlinkMsg downlinkMsg = convertToDownlinkMsg(edgeEvent); .map(this::convertToDownlinkMsg)
if (downlinkMsg != null) { .collect(Collectors.toList());
result.add(downlinkMsg);
}
}
return result;
} }
private DownlinkMsg processEntityMergeRequestMessage(EdgeEvent edgeEvent) { private DownlinkMsg processEntityMergeRequestMessage(EdgeEvent edgeEvent) {