Interface SplitPointDataSource<T extends SplitPointUnit,​U extends SplitPointDataSource<T,​U>>

  • Type Parameters:
    T - the type of split point units
    U - the type of data source
    All Known Implementing Classes:
    SheetDataSource, SplitPointDataList

    public interface SplitPointDataSource<T extends SplitPointUnit,​U extends SplitPointDataSource<T,​U>>
    Provides split point data source. Data provided by via this interface is expected to be immutable. The interface is designed to work with data sources of unknown size. Access to the interfaces methods should be done with care to limit unnecessary computation in the data source.
    • Method Detail

      • get

        T get​(int index)
        Gets the item at index.
        Parameters:
        index - the index
        Returns:
        returns the item
        Throws:
        IndexOutOfBoundsException - if the index is beyond the end of the stream
      • getRemaining

        List<T> getRemaining()
        Gets all remaining items. Note that using this method will result in all elements being computed, if this is not what is needed. Consider using split(int) instead.
        Returns:
        returns all remaining items
      • createEmpty

        U createEmpty()
        Creates a new empty data source of the implementing type.
        Returns:
        returns a new empty data source of the implementing type
      • split

        default SplitResult<T,​U> split​(int atIndex)

        Gets the result of splitting at the specified index. An implementation must be able to handle indexes where hasElementAt(int) returns false.

        If atIndex is 0, the head of the result is empty and the original stream is in the tail. Conversely, if atIndex is greater than hasElementAt(int) the head of the result contains getRemaining() and the tail is empty.

        Parameters:
        atIndex - the index where the tail starts
        Returns:
        returns a split result at the specified index
      • splitInRange

        SplitResult<T,​U> splitInRange​(int atIndex)
        Gets the result of splitting at the specified index.
        Parameters:
        atIndex - the index where the tail starts
        Returns:
        returns a split result at the specified index
        Throws:
        IndexOutOfBoundsException - if the index isn't within the bounds of available data.
      • getDataSource

        U getDataSource()
        Gets the data source as is, typically "return this".
        Returns:
        returns the data source
      • hasElementAt

        boolean hasElementAt​(int index)
        Returns true if the manager has an element at the specified index.
        Parameters:
        index - the index
        Returns:
        returns true if the manager has an element at the specified index, false otherwise
      • getSize

        int getSize​(int limit)
        Gets the size of the manager or the limit if the number of items is greater than the limit.
        Parameters:
        limit - the limit
        Returns:
        returns the size, or the limit
      • isEmpty

        boolean isEmpty()
        Returns true if the manager contains no items. Note that this method can returns true, even if getSupplements() is non-empty.
        Returns:
        returns true if the manager has no items, false otherwise
      • getSupplements

        Supplements<T> getSupplements()
        Gets the split point data source supplements.
        Returns:
        the supplements