Class SimpleSelection<E>
- java.lang.Object
-
- com.macrofocus.selection.implementation.AbstractSelection<E>
-
- com.macrofocus.selection.implementation.AbstractMutableSelection<E>
-
- com.macrofocus.selection.implementation.SimpleSelection<E>
-
- Type Parameters:
E
- the type of elements that can be selected
- All Implemented Interfaces:
MutableSelection<E>
,Selection<E>
,java.lang.Iterable<E>
public final class SimpleSelection<E> extends AbstractMutableSelection<E> implements MutableSelection<E>
Default data model for multiple selection. Selecting a null value is treated as clearing the selection.
-
-
Constructor Summary
Constructors Constructor Description SimpleSelection()
SimpleSelection(E... selected)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
clearSelection()
Change the selection to the empty set.int
getSelectedCount()
Returns the number of elements currently selected.java.util.Set<E>
getSelectedSet()
Returns the selected elements as a Set.boolean
isActive()
Indicates whether at least one element is currently selected.boolean
isSelected(E element)
Indicates whether a given element is selected or not.java.util.Iterator<E>
iterator()
boolean
setSelected(boolean selected, E... elements)
Set the selection state.void
setSelected(E e)
void
setSelected(E element, boolean selected)
boolean
setSelected(java.lang.Iterable<E> elements, boolean selected)
Set the selection state.void
setSelectedElements(E... elements)
void
setSelectedIterable(java.lang.Iterable<E> elements)
java.lang.String
toString()
-
Methods inherited from class com.macrofocus.selection.implementation.AbstractMutableSelection
setEnabled
-
Methods inherited from class com.macrofocus.selection.implementation.AbstractSelection
addSelectionListener, addWeakSelectionListener, isEnabled, notifySelectedChanged, removeSelectionListener, removeSelectionListeners
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.macrofocus.selection.MutableSelection
setEnabled
-
Methods inherited from interface com.macrofocus.selection.Selection
addSelectionListener, addWeakSelectionListener, isEnabled, removeSelectionListener, removeSelectionListeners
-
-
-
-
Constructor Detail
-
SimpleSelection
public SimpleSelection()
-
SimpleSelection
public SimpleSelection(E... selected)
-
-
Method Detail
-
clearSelection
public boolean clearSelection()
Description copied from interface:MutableSelection
Change the selection to the empty set. If this represents a change to the current selection then notify each listener.- Specified by:
clearSelection
in interfaceMutableSelection<E>
- Returns:
- true, if the set of selected elements was changed.
-
isActive
public boolean isActive()
Description copied from interface:Selection
Indicates whether at least one element is currently selected.
-
isSelected
public boolean isSelected(E element)
Description copied from interface:Selection
Indicates whether a given element is selected or not.- Specified by:
isSelected
in interfaceSelection<E>
- Parameters:
element
- the element to be tested- Returns:
- true if the element is selected, false otherwise
-
setSelected
public void setSelected(E e)
- Specified by:
setSelected
in interfaceMutableSelection<E>
-
setSelected
public void setSelected(E element, boolean selected)
- Specified by:
setSelected
in interfaceMutableSelection<E>
-
setSelected
public boolean setSelected(java.lang.Iterable<E> elements, boolean selected)
Description copied from interface:MutableSelection
Set the selection state.- Specified by:
setSelected
in interfaceMutableSelection<E>
- Parameters:
elements
- the elements to changeselected
- true to have the elements selected, false otherwise- Returns:
- true, if the set of selected elements was changed.
-
setSelected
public boolean setSelected(boolean selected, E... elements)
Description copied from interface:MutableSelection
Set the selection state.- Specified by:
setSelected
in interfaceMutableSelection<E>
- Parameters:
selected
- true to have the elements selected, false otherwiseelements
- the elements to change- Returns:
- true, if the set of selected elements was changed.
-
setSelectedElements
public void setSelectedElements(E... elements)
- Specified by:
setSelectedElements
in interfaceMutableSelection<E>
-
setSelectedIterable
public void setSelectedIterable(java.lang.Iterable<E> elements)
- Specified by:
setSelectedIterable
in interfaceMutableSelection<E>
-
getSelectedCount
public int getSelectedCount()
Description copied from interface:Selection
Returns the number of elements currently selected.- Specified by:
getSelectedCount
in interfaceSelection<E>
- Returns:
- the number of selected elements.
-
getSelectedSet
public java.util.Set<E> getSelectedSet()
Description copied from interface:Selection
Returns the selected elements as a Set.- Specified by:
getSelectedSet
in interfaceSelection<E>
- Returns:
- the Set of selected elements.
-
iterator
public java.util.Iterator<E> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<E>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-