void (@NotNull List<MapInfo> items) { boolean hasUnregistered = false; boolean hasSeparator = false; for (MapInfo item : items) { if (item.type == MapInfo.Type.UNREGISTERED) { hasUnregistered = true; } else if (item.type == MapInfo.Type.SEPARATOR) { hasSeparator = true; } } if (!hasUnregistered && hasSeparator) { items.remove(MapInfo.SEPARATOR); } else if (hasUnregistered && !hasSeparator) { items.add(MapInfo.SEPARATOR); } items.sort(MapInfo.COMPARATOR); }