Package org.apache.storm.daemon.utils

## Class ListFunctionalSupport

- java.lang.Object
- - org.apache.storm.daemon.utils.ListFunctionalSupport

-     public class ListFunctionalSupport
      extends Object

  Implements missing sequence functions in Java compared to Clojure. To make thing simpler, it only supports List type.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ListFunctionalSupport()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static <T> List<T>` | `drop​(List<T> list, int count)` | Drop the first N elements and create a new list.
    `static <T> T` | `first​(List<T> list)` | Get the first element in list.
    `static <T> T` | `last​(List<T> list)` | get the last element in list.
    `static <T> List<T>` | `rest​(List<T> list)` | Drop the only first element and create a new list.
    `static <T> List<T>` | `takeLast​(List<T> list, int count)` | Get the last N elements as a new list.

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

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

- - ### Constructor Detail

    - #### ListFunctionalSupport

          public ListFunctionalSupport()

  - ### Method Detail

    - #### first

          public static <T> T first​(List<T> list)

      Get the first element in list.
      Parameters:
        `list` - list to get
      Returns:
        the first element. null if list is null or empty.

    - #### last

          public static <T> T last​(List<T> list)

      get the last element in list.
      Parameters:
        `list` - list to get
      Returns:
        the last element. null if list is null or empty.

    - #### takeLast

          public static <T> List<T> takeLast​(List<T> list,
                                             int count)

      Get the last N elements as a new list.
      Parameters:
        `list` - list to get
        `count` - element count to get
      Returns:
        the first element. null if list is null. elements in a new list may be less than count if there're not enough elements in the list.

    - #### drop

          public static <T> List<T> drop​(List<T> list,
                                         int count)

      Drop the first N elements and create a new list.
      Parameters:
        `list` - the list
        `count` - element count to drop
      Returns:
        newly created sublist that drops the first N elements from origin list. null if list is null.

    - #### rest

          public static <T> List<T> rest​(List<T> list)

      Drop the only first element and create a new list. equivalent to drop(list, 1).
      Parameters:
        `list` - the list
      Returns:
        newly created sublist that drops the first element from origin list. null if list is null.