Class StructuredSelection

  • All Implemented Interfaces:
    java.lang.Iterable, ISelection, IStructuredSelection
    Direct Known Subclasses:
    TreeSelection

    public class StructuredSelection
    extends java.lang.Object
    implements IStructuredSelection
    A concrete implementation of the IStructuredSelection interface, suitable for instantiating.

    This class is not intended to be subclassed.

    Restriction:
    This class is not intended to be subclassed by clients.
    • Constructor Summary

      Constructors 
      Constructor Description
      StructuredSelection()
      Creates a new empty selection.
      StructuredSelection​(java.lang.Object element)
      Creates a structured selection containing a single object.
      StructuredSelection​(java.lang.Object[] elements)
      Creates a structured selection from the given elements.
      StructuredSelection​(java.util.List elements)
      Creates a structured selection from the given List.
      StructuredSelection​(java.util.List elements, IElementComparer comparer)
      Creates a structured selection from the given List and element comparer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Returns whether this structured selection is equal to the given object.
      java.lang.Object getFirstElement()
      Returns the first element in this selection, or null if the selection is empty.
      int hashCode()  
      boolean isEmpty()
      Returns whether this selection is empty.
      java.util.Iterator iterator()
      Returns an iterator over the elements of this selection.
      int size()
      Returns the number of elements selected in this selection.
      java.lang.Object[] toArray()
      Returns the elements in this selection as an array.
      java.util.List toList()
      Returns the elements in this selection as a List.
      java.lang.String 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 Detail

      • EMPTY

        public static final StructuredSelection EMPTY
        The canonical empty selection. This selection should be used instead of null.
    • Constructor Detail

      • StructuredSelection

        public StructuredSelection()
        Creates a new empty selection. See also the static field EMPTY which contains an empty selection singleton.
        See Also:
        EMPTY
      • StructuredSelection

        public StructuredSelection​(java.lang.Object[] elements)
        Creates a structured selection from the given elements. The given element array must not be null.
        Parameters:
        elements - an array of elements
      • StructuredSelection

        public StructuredSelection​(java.lang.Object element)
        Creates a structured selection containing a single object. The object must not be null.
        Parameters:
        element - the element
      • StructuredSelection

        public StructuredSelection​(java.util.List elements)
        Creates a structured selection from the given List.
        Parameters:
        elements - list of selected elements
      • StructuredSelection

        public StructuredSelection​(java.util.List elements,
                                   IElementComparer comparer)
        Creates a structured selection from the given List 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 elements
        comparer - the comparer, or null
        Since:
        3.4
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        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.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - the other object
        Returns:
        true if they are equal, and false otherwise
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getFirstElement

        public java.lang.Object getFirstElement()
        Description copied from interface: IStructuredSelection
        Returns the first element in this selection, or null if the selection is empty.
        Specified by:
        getFirstElement in interface IStructuredSelection
        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 interface ISelection
        Returns:
        true if this selection is empty, and false otherwise
      • iterator

        public java.util.Iterator iterator()
        Description copied from interface: IStructuredSelection
        Returns an iterator over the elements of this selection.
        Specified by:
        iterator in interface IStructuredSelection
        Specified by:
        iterator in interface java.lang.Iterable
        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 interface IStructuredSelection
        Returns:
        the number of elements selected
      • toArray

        public java.lang.Object[] toArray()
        Description copied from interface: IStructuredSelection
        Returns the elements in this selection as an array.
        Specified by:
        toArray in interface IStructuredSelection
        Returns:
        the selected elements as an array
      • toList

        public java.util.List toList()
        Description copied from interface: IStructuredSelection
        Returns the elements in this selection as a List.
        Specified by:
        toList in interface IStructuredSelection
        Returns:
        the selected elements as a list
      • toString

        public java.lang.String toString()
        Internal method which returns a string representation of this selection suitable for debug purposes only.
        Overrides:
        toString in class java.lang.Object
        Returns:
        debug string