Class NumericSpinnerData

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<java.lang.Integer>, Collection<java.lang.Integer>, List<java.lang.Integer>, Sequence<java.lang.Integer>

    public class NumericSpinnerData
    extends ReadOnlySequence<java.lang.Integer>
    implements List<java.lang.Integer>
    Spinner data model that presents a bounded list of integers. This is a lightweight class that spoofs the actual list data (no data is stored in the list).

    The iterator returned by this class's iterator method is fail-fast: if the bounds of the enclosing spinner data change during iteration, a ConcurrentModificationException will be thrown.

    See Also:
    Serialized Form
    • Constructor Detail

      • NumericSpinnerData

        public NumericSpinnerData()
        Creates a new NumericSpinnerData instance bounded from Short.MIN_VALUE to Short.MAX_VALUE and an increment of one.
      • NumericSpinnerData

        public NumericSpinnerData​(int lowerBound,
                                  int upperBound)
        Creates a new NumericSpinnerData with the specified bounded range and an increment of one.
        Parameters:
        lowerBound - The lower bound for the data.
        upperBound - The upper bound for the data.
      • NumericSpinnerData

        public NumericSpinnerData​(int lowerBound,
                                  int upperBound,
                                  int increment)
        Creates a new NumericSpinnerData with the specified bounded range and increment.
        Parameters:
        lowerBound - The lower bound for the data.
        upperBound - The upper bound for the data.
        increment - The increment between values.
    • Method Detail

      • getLowerBound

        public int getLowerBound()
      • setLowerBound

        public void setLowerBound​(int lowerBound)
      • getUpperBound

        public int getUpperBound()
      • setUpperBound

        public void setUpperBound​(int upperBound)
      • getIncrement

        public int getIncrement()
      • setIncrement

        public void setIncrement​(int increment)
      • get

        public java.lang.Integer get​(int index)
        Description copied from interface: Sequence
        Retrieves the item at the given index.
        Specified by:
        get in interface Sequence<java.lang.Integer>
        Parameters:
        index - The index of the item to retrieve.
        Returns:
        The item at this index in the sequence.
      • indexOf

        public int indexOf​(java.lang.Integer item)
        Description copied from interface: Sequence
        Returns the index of an item in the sequence.
        Specified by:
        indexOf in interface Sequence<java.lang.Integer>
        Parameters:
        item - The item to locate.
        Returns:
        The index of first occurrence of the item if it exists in the sequence; -1, otherwise.
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Collection
        Tests the emptiness of the collection.
        Specified by:
        isEmpty in interface Collection<java.lang.Integer>
        Returns:
        true if the collection contains no elements; false, otherwise.
      • getLength

        public int getLength()
        Description copied from interface: List
        Returns the length of the list.
        Specified by:
        getLength in interface List<java.lang.Integer>
        Specified by:
        getLength in interface Sequence<java.lang.Integer>
        Returns:
        The number of items in the list, or -1 if the list's length is not known. In this case, the iterator must be used to retrieve the contents of the list.
      • iterator

        public java.util.Iterator<java.lang.Integer> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Integer>
      • getListListeners

        public ListenerList<ListListener<java.lang.Integer>> getListListeners()
        Description copied from interface: List
        Returns the list listener list.
        Specified by:
        getListListeners in interface List<java.lang.Integer>
        Returns:
        The list of listeners for this list.