Package org.apache.storm.daemon.utils
Class ListFunctionalSupport
java.lang.Object
org.apache.storm.daemon.utils.ListFunctionalSupport
Implements missing sequence functions in Java compared to Clojure.
To make thing simpler, it only supports List type.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>
Drop the first N elements and create a new list.static <T> T
Get the first element in list.static <T> T
get the last element in list.static <T> List<T>
Drop the only first element and create a new list. equivalent to drop(list, 1).static <T> List<T>
Get the last N elements as a new list.
-
Constructor Details
-
ListFunctionalSupport
public ListFunctionalSupport()
-
-
Method Details
-
first
Get the first element in list.- Parameters:
list
- list to get- Returns:
- the first element. null if list is null or empty.
-
last
get the last element in list.- Parameters:
list
- list to get- Returns:
- the last element. null if list is null or empty.
-
takeLast
Get the last N elements as a new list.- Parameters:
list
- list to getcount
- 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
Drop the first N elements and create a new list.- Parameters:
list
- the listcount
- element count to drop- Returns:
- newly created sublist that drops the first N elements from origin list. null if list is null.
-
rest
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.
-