return Lists.newArrayList(Lists.transform(choices, ObjectAdapterMemento.Functions.fromAdapter()));
}
// called by setProviderAndCurrAndPending
private void resetIfCurrentNotInChoices(final Select2Choice<ObjectAdapterMemento> select2Field, final List<ObjectAdapterMemento> choiceMementos) {
final ObjectAdapterMemento curr = select2Field.getModelObject();
if(curr == null) {
select2Field.getModel().setObject(null);
getModel().setObject(null);
return;
}
if(!curr.containedIn(choiceMementos)) {
if(!choiceMementos.isEmpty()) {
final ObjectAdapterMemento newAdapterMemento = choiceMementos.get(0);
select2Field.getModel().setObject(newAdapterMemento);
getModel().setObject(newAdapterMemento.getObjectAdapter(ConcurrencyChecking.NO_CHECK));
} else {
select2Field.getModel().setObject(null);
getModel().setObject(null);
}
}