/** * Returns the union of all fields which the provided set of missing consents prevents from being used. Returns an * empty list if all fields are affected (not consented). Returns null if no fields are affected. * * @param missingConsents a set of presumably not granted consents */ private Set<String> getNonConsentedFieldSet(Set<Consent> missingConsents) { Set<String> notConsentedFields = new HashSet<>(); for (Consent consent : missingConsents) { if (consent.affectsAllFields()) { // if at least one of the consents affects all fields no point to examine other consents // since all fields are affected anyway return new HashSet<>(); } if (!consent.affectsSomeFields()) { continue; } // special cases: affects all fields and affects no fields notConsentedFields.addAll(consent.getFields()); } // empty list implies "all affected", null implies "none affected" if (notConsentedFields.size() == 0) { return null; } return notConsentedFields; } }