Will you tell me how to implement beautifully logic in this method?
protected Map<QueueType, QueueContext> getQueueContexts() {
List<QueueContext> queueContexts = QueueContext.parseConfigs(Config.KAFKA_QUEUES.get());
return queueContexts.stream()
.collect(Collectors.toMap(QueueContext::getQueueType, Function.identity()));
}
It is necessary to check if there is a QueueType.unknown in the List queueContexts and if there is, then write to the log, if not, then add to the Map.
I do just such a check, but it turns out that I'm collecting Map correctly, but all the logs are written that are, and I need to write only those that are unknown
return queueContexts.stream().filter(type -> type.getQueueType() != QueueType.unknown)
.peek(ls -> LOGGER.info(ls))
.collect(Collectors.toMap(QueueContext::getQueueType, Function.identity()));