/** * Given a list of enabled section elements and a list of consented section elements, disables any elements in * {@code enabledElements} that do not have the required consents. * * @param enabledElements the section elements that are currently enabled * @param consentedElements the section elements that have all the required consents */ private void disableNonConsentedElements(@Nonnull final List<RecordElement> enabledElements, @Nonnull final List<RecordElement> consentedElements) { for (final RecordElement element : enabledElements) { if (!consentedElements.contains(element)) { element.setEnabled(false); } } }
/** * Given a list of enabled section elements and a list of consented section elements, disables any elements in * {@code enabledElements} that do not have the required consents. * * @param enabledElements the section elements that are currently enabled * @param consentedElements the section elements that have all the required consents */ private void disableNonConsentedElements(@Nonnull final List<RecordElement> enabledElements, @Nonnull final List<RecordElement> consentedElements) { for (final RecordElement element : enabledElements) { if (!consentedElements.contains(element)) { element.setEnabled(false); } } }
/** * Given the {@code section} that needs to be configured, and the {@code fieldOverrides enabled fields}, configures * the {@code section} elements. * * @param section the {@link RecordSection record section} that needs to be configured * @param fieldOverrides the list of identifiers for enabled fields */ private void configureFields(final RecordSection section, final List<String> fieldOverrides) { List<RecordElement> updatedElements = new ArrayList<>(section.getAllElements()); Collections.<RecordElement>sort(updatedElements, new Comparator<RecordElement>() { @Override public int compare(RecordElement o1, RecordElement o2) { int i1 = fieldOverrides.indexOf(o1.getExtension().getId()); int i2 = fieldOverrides.indexOf(o2.getExtension().getId()); return (i2 == -1 || i1 == -1) ? (i2 - i1) : (i1 - i2); } }); for (final RecordElement element : updatedElements) { if (!fieldOverrides.contains(element.getExtension().getId())) { element.setEnabled(false); } } section.setElements(updatedElements); }