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 SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionCreates 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 givenListand element comparer.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanReturns whether this structured selection is equal to the given object.Returns the first element in this selection, ornullif the selection is empty.inthashCode()booleanisEmpty()Returns whether this selection is empty.iterator()Returns an iterator over the elements of this selection.intsize()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.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Field Details- 
EMPTYThe canonical empty selection. This selection should be used instead ofnull.
 
- 
- 
Constructor Details- 
StructuredSelectionpublic StructuredSelection()Creates a new empty selection. See also the static fieldEMPTYwhich contains an empty selection singleton.- See Also:
 
- 
StructuredSelectionCreates a structured selection from the given elements. The given element array must not benull.- Parameters:
- elements- an array of elements
 
- 
StructuredSelectionCreates a structured selection containing a single object. The object must not benull.- Parameters:
- element- the element
 
- 
StructuredSelectionCreates a structured selection from the givenList.- Parameters:
- elements- list of selected elements
 
- 
StructuredSelectionCreates a structured selection from the givenListand 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 elements
- comparer- the comparer, or null
- Since:
- 3.4
 
 
- 
- 
Method Details- 
equalsReturns 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.
- 
hashCodepublic int hashCode()
- 
getFirstElementDescription copied from interface:IStructuredSelectionReturns the first element in this selection, ornullif the selection is empty.- Specified by:
- getFirstElementin interface- IStructuredSelection
- Returns:
- an element, or nullif none
 
- 
isEmptypublic boolean isEmpty()Description copied from interface:ISelectionReturns whether this selection is empty.- Specified by:
- isEmptyin interface- ISelection
- Returns:
- trueif this selection is empty, and- falseotherwise
 
- 
iteratorDescription copied from interface:IStructuredSelectionReturns an iterator over the elements of this selection.- Specified by:
- iteratorin interface- IStructuredSelection
- Specified by:
- iteratorin interface- Iterable
- Returns:
- an iterator over the selected elements
 
- 
sizepublic int size()Description copied from interface:IStructuredSelectionReturns the number of elements selected in this selection.- Specified by:
- sizein interface- IStructuredSelection
- Returns:
- the number of elements selected
 
- 
toArrayDescription copied from interface:IStructuredSelectionReturns the elements in this selection as an array.- Specified by:
- toArrayin interface- IStructuredSelection
- Returns:
- the selected elements as an array
 
- 
toListDescription copied from interface:IStructuredSelectionReturns the elements in this selection as aList.- Specified by:
- toListin interface- IStructuredSelection
- Returns:
- the selected elements as a list
 
- 
streamDescription copied from interface:IStructuredSelectionReturns the elements in this selection as aStream.- Specified by:
- streamin interface- IStructuredSelection
- Returns:
- the selected elements as a stream
 
- 
toStringInternal method which returns a string representation of this selection suitable for debug purposes only.
 
-