Package org.eclipse.jface.viewers
Class StructuredSelection
java.lang.Object
org.eclipse.jface.viewers.StructuredSelection
- All Implemented Interfaces:
Iterable
,ISelection
,IStructuredSelection
- Direct Known Subclasses:
TreeSelection
A concrete implementation of the
IStructuredSelection
interface,
suitable for instantiating.
This class is not intended to be subclassed.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new empty selection.StructuredSelection
(Object element) Creates a structured selection containing a single object.StructuredSelection
(Object[] elements) Creates a structured selection from the given elements.StructuredSelection
(List elements) Creates a structured selection from the givenList
.StructuredSelection
(List elements, IElementComparer comparer) Creates a structured selection from the givenList
and element comparer. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether this structured selection is equal to the given object.Returns the first element in this selection, ornull
if the selection is empty.int
hashCode()
boolean
isEmpty()
Returns whether this selection is empty.iterator()
Returns an iterator over the elements of this selection.int
size()
Returns the number of elements selected in this selection.stream()
Returns the elements in this selection as aStream
.Object[]
toArray()
Returns the elements in this selection as an array.toList()
Returns the elements in this selection as aList
.toString()
Internal method which returns a string representation of this selection suitable for debug purposes only.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY
The canonical empty selection. This selection should be used instead ofnull
.
-
-
Constructor Details
-
StructuredSelection
public StructuredSelection()Creates a new empty selection. See also the static fieldEMPTY
which contains an empty selection singleton.- See Also:
-
StructuredSelection
Creates a structured selection from the given elements. The given element array must not benull
.- Parameters:
elements
- an array of elements
-
StructuredSelection
Creates a structured selection containing a single object. The object must not benull
.- Parameters:
element
- the element
-
StructuredSelection
Creates a structured selection from the givenList
.- Parameters:
elements
- list of selected elements
-
StructuredSelection
Creates a structured selection from the givenList
and element comparer. If an element comparer is provided, it will be used to determine equality between structured selection objects provided that they both are based on the same (identical) comparer. See bug- Parameters:
elements
- list of selected elementscomparer
- the comparer, or null- Since:
- 3.4
-
-
Method Details
-
equals
Returns whether this structured selection is equal to the given object. Two structured selections are equal if they contain the same elements in the same order. -
hashCode
public int hashCode() -
getFirstElement
Description copied from interface:IStructuredSelection
Returns the first element in this selection, ornull
if the selection is empty.- Specified by:
getFirstElement
in interfaceIStructuredSelection
- Returns:
- an element, or
null
if none
-
isEmpty
public boolean isEmpty()Description copied from interface:ISelection
Returns whether this selection is empty.- Specified by:
isEmpty
in interfaceISelection
- Returns:
true
if this selection is empty, andfalse
otherwise
-
iterator
Description copied from interface:IStructuredSelection
Returns an iterator over the elements of this selection.- Specified by:
iterator
in interfaceIStructuredSelection
- Specified by:
iterator
in interfaceIterable
- Returns:
- an iterator over the selected elements
-
size
public int size()Description copied from interface:IStructuredSelection
Returns the number of elements selected in this selection.- Specified by:
size
in interfaceIStructuredSelection
- Returns:
- the number of elements selected
-
toArray
Description copied from interface:IStructuredSelection
Returns the elements in this selection as an array.- Specified by:
toArray
in interfaceIStructuredSelection
- Returns:
- the selected elements as an array
-
toList
Description copied from interface:IStructuredSelection
Returns the elements in this selection as aList
.- Specified by:
toList
in interfaceIStructuredSelection
- Returns:
- the selected elements as a list
-
stream
Description copied from interface:IStructuredSelection
Returns the elements in this selection as aStream
.- Specified by:
stream
in interfaceIStructuredSelection
- Returns:
- the selected elements as a stream
-
toString
Internal method which returns a string representation of this selection suitable for debug purposes only.
-