Package org.scijava.util
Class ListUtils
- java.lang.Object
-
- org.scijava.util.ListUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tfirst(List<T> list)Gets the first element of the given list, or null if none.static Stringstring(List<?> list)Converts the given list to a string.static Stringstring(List<?> list, boolean encloseSingletons)Converts the given list to a string.static Stringstring(List<?> list, String lDelimiter, String rDelimiter, String separator, boolean encloseSingletons)Converts the given list to a string.
-
-
-
Method Detail
-
first
public static <T> T first(List<T> list)
Gets the first element of the given list, or null if none.
-
string
public static String string(List<?> list)
Converts the given list to a string.The list elements will be separated by a comma then a space. The list will be enclosed in square brackets.
- Parameters:
list- The list to stringify.- See Also:
string(List, String, String, String, boolean)
-
string
public static String string(List<?> list, boolean encloseSingletons)
Converts the given list to a string.The list elements will be separated by a comma then a space. The list will be enclosed in square brackets unless it is a singleton with the
encloseSingletonsflag set to false.- Parameters:
list- The list to stringify.encloseSingletons- Whether to enclose singleton lists in brackets.- Returns:
- The stringified list.
- See Also:
string(List, String, String, String, boolean)
-
string
public static String string(List<?> list, String lDelimiter, String rDelimiter, String separator, boolean encloseSingletons)
Converts the given list to a string.The list elements will be comma-separated. It will be enclosed in square brackets unless the list is a singleton with the
encloseSingletonsflag set to false.- Parameters:
list- The list to stringify.lDelimiter- The left-hand symbol(s) in which to enclose the list.rDelimiter- The right-hand symbol(s) in which to enclose the list.separator- The symbol(s) to place in between each element.encloseSingletons- Whether to enclose singleton lists inside the delimiter symbols.- Returns:
- The stringified list.
-
-