/** * Ensures that the current value is present so that the form can be idempotently saved in those cases where the * user saving the form cannot view the current credential * * @param value the current value. * @return {@code this} for method chaining. * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> includeCurrentValue(@NonNull String value) { if (StringUtils.isEmpty(value)) { return includeEmptyValue(); } for (Option a : this) { if (StringUtils.equals(value, a.value)) { return this; } } // the current should be the first (unless the first is the empty selection int index = isEmpty() ? 0 : "".equals(get(0).value) ? 1 : 0; add(index, new Option(Messages.AbstractIdCredentialsListBoxModel_CurrentSelection(), value)); return this; }
/** * Ensures that the current value is present so that the form can be idempotently saved in those cases where the * user saving the form cannot view the current credential * * @param value the current value. * @return {@code this} for method chaining. * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> includeCurrentValue(@NonNull String value) { if (StringUtils.isEmpty(value)) { return includeEmptyValue(); } for (Option a : this) { if (StringUtils.equals(value, a.value)) { return this; } } // the current should be the first (unless the first is the empty selection int index = isEmpty() ? 0 : "".equals(get(0).value) ? 1 : 0; add(index, new Option(Messages.AbstractIdCredentialsListBoxModel_CurrentSelection(), value)); return this; }