boolean (@NotNull LibraryEntity oldEntity, @NotNull LibraryEntity newEntity) { if (newEntity.getRoots().size() > oldEntity.getRoots().size()) return true; if (oldEntity.getExcludedRoots().size() > newEntity.getExcludedRoots().size()) return true; List<LibraryRoot> oldEntityRoots = oldEntity.getRoots(); for (LibraryRoot root : newEntity.getRoots()) { if (!oldEntityRoots.contains(root)) return true; } List<ExcludeUrlEntity> newEntityExcludedRoots = newEntity.getExcludedRoots(); for (ExcludeUrlEntity excludedRoot : oldEntity.getExcludedRoots()) { if (!newEntityExcludedRoots.contains(excludedRoot.getUrl())) return true; } return false; }