class FlowChainLogService {

    public boolean hasEventInFlowChainQueue(List<FlowChainLog> flowChains) {
        Map<String, List<FlowChainLog>> byFlowChainId = flowChains.stream()
                .collect(Collectors.groupingBy(FlowChainLog::getFlowChainId, toList()));
        return byFlowChainId.entrySet().stream().anyMatch(entry -> {
            FlowChainLog latestFlowChain = entry.getValue()
                    .stream()
                    .sorted(comparing(FlowChainLog::getCreated).reversed())
                    .findFirst()
                    .get();
            LOGGER.debug("Checking if chain with id {} has any event in it's queue", latestFlowChain.getFlowChainId());
            Queue<Selectable> chain = (Queue<Selectable>) JsonReader.jsonToJava(latestFlowChain.getChain());
            return !chain.isEmpty();
        });
    }

}