Module org.firebirdsql.jaybird
Package org.firebirdsql.jaybird.util

# Class CollectionUtils

java.lang.Object
org.firebirdsql.jaybird.util.CollectionUtils

@NullMarked public final class CollectionUtils extends Object
Helper class for collections

Since:
  6
Author:
  Mark Rotteveel

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T extends @Nullable Object>
  @Nullable T`
  `getLast(List<T> list)`
  Returns the last item of a list, or `null` if the list is empty.
  `static void`
  `growToSize(List<?> list, int size)`
  Grows the size of `list` to `size` by padding it with `null` to the requested size.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### growToSize

    public static void growToSize(List<?> list, int size)
    Grows the size of `list` to `size` by padding it with `null` to the requested size.

    If the size of the list is already `size` or larger, it will not be modified

    Parameters:
      `list` - list to grow
      `size` - desired size
    Throws:
      `NullPointerException` - if `list` is `null`, or does not accept `null` as a value
      `UnsupportedOperationException` - if `list` is unmodifiable or fixed size and its current size is less than `size`

  - ### getLast

    public static <T extends @Nullable Object> @Nullable T getLast(List<T> list)
    Returns the last item of a list, or `null` if the list is empty.
    Type Parameters:
      `T` - type of the list
    Parameters:
      `list` - list
    Returns:
      last item (which may be `null`), or `null` if the list is empty
    Throws:
      `NullPointerException` - if `list` is `null`