void (@NotNull List<? super VFileEvent> outValidated, @NotNull List<? super Runnable> outApplyActions, @NotNull Map<VirtualDirectoryImpl, Object> created) { if (!created.isEmpty()) { // since the VCreateEvent.isValid() is extremely expensive, combine all creation events for the directory // and use VirtualDirectoryImpl.validateChildrenToCreate() optimised for bulk validation boolean hasValidEvents = false; for (Map.Entry<VirtualDirectoryImpl, Object> entry : created.entrySet()) { VirtualDirectoryImpl directory = entry.getKey(); Object value = entry.getValue(); //noinspection unchecked Set<VFileCreateEvent> createEvents = value instanceof VFileCreateEvent ? new HashSet<>(List.of((VFileCreateEvent)value)) : (Set<VFileCreateEvent>)value; directory.validateChildrenToCreate(createEvents); hasValidEvents |= !createEvents.isEmpty(); outValidated.addAll(createEvents); entry.setValue(createEvents); } if (hasValidEvents) { //noinspection unchecked,rawtypes Map<VirtualDirectoryImpl, Set<VFileCreateEvent>> finalGrouped = (Map)created; outApplyActions.add((Runnable)() -> { applyCreations(finalGrouped); incStructuralModificationCount(); }); } } }