/** * Sets the current selection to the given item or clears selection if given * {@code null}. * * @param item * the item to select or {@code null} to clear selection */ public void setSelectedItem(T item) { setSelectedItem(item, false); }
/** * Sets the value of this object which is an item to select. If the new * value is not equal to {@code getValue()}, fires a value change event. If * value is {@code null} then it deselects currently selected item. * <p> * The call is delegated to {@link #setSelectedItem(Object)}. * * @see #setSelectedItem(Object) * @see Single#setSelectedItem(Object) * * @param value * the item to select or {@code null} to clear selection */ @Override public void setValue(T value) { setSelectedItem(value); }
@Override public void select(String key) { setSelectedItem(keyToItem(key), true); }
@Override public void deselect(String key) { T item = keyToItem(key); if (isSelected(item)) { setSelectedItem(null, true); } } });
@Override public void deselect(T item) { if (item != null) { getSelectedItem().filter(i -> i.equals(item)).ifPresent(i -> getInternalField().setSelectedItem(null)); } }
@Override public void select(T item) { getInternalField().setSelectedItem(toInternalValue(item)); }