Package org.aksw.commons.util.list
Class ListUtils
- java.lang.Object
-
- org.aksw.commons.util.list.ListUtils
-
public class ListUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description ListUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TgetOrDefault(List<T> list, int i, T dflt)static <T> TgetOrNull(List<T> list, int i)Return the item at index or null if it does not exist.
-
-
-
Method Detail
-
getOrNull
public static <T> T getOrNull(List<T> list, int i)
Return the item at index or null if it does not exist. Checks the size of the list before accessing the item (hence, the complexity of size() is ideally O(1)) Argument must not be negative- Parameters:
list-i-- Returns:
-
getOrDefault
public static <T> T getOrDefault(List<T> list, int i, T dflt)
-
-