public Optional<Set<String>> getIncludedTypes() {
        if (visibleTypes != null) {
            final Set<String> visibleTypeNames = visibleTypes.stream()
                    .map(DocumentType::getType)
                    .collect(Collectors.toSet());
            if (selected.containsAll(visibleTypeNames)) {
                // All selected so return null to save the back end pointlessly filtering on them.
                // The visible types are derived from finding the distinct types of all the entities
                // that a user has permission to read, so there is no point in filtering on all visible types.
                return Optional.empty();
            } else {
                return Optional.of(selected);
            }
        } else {
            return Optional.of(selected);
        }
    }
@return A set of types to include, or empty if the type filter is not active
stroom-core-client/src/main/java/stroom/explorer/client/presenter/TypeFilterPresenter.java