public class ListUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_JOIN_SEPARATOR
default join separator
|
Constructor and Description |
---|
ListUtils() |
Modifier and Type | Method and Description |
---|---|
static <V> boolean |
addDistinctEntry(java.util.List<V> sourceList,
V entry)
add distinct entry to list
|
static <V> int |
addDistinctList(java.util.List<V> sourceList,
java.util.List<V> entryList)
add all distinct entry to list1 from list2
|
static <V> boolean |
addListNotNullValue(java.util.List<V> sourceList,
V value)
add not null entry to list
|
static <V> int |
distinctList(java.util.List<V> sourceList)
remove duplicate entries in list
|
static <V> V |
getLast(java.util.List<V> sourceList,
V value) |
static <V> V |
getNext(java.util.List<V> sourceList,
V value) |
static <V> int |
getSize(java.util.List<V> sourceList)
get size of list
getSize(null) = 0;
getSize({}) = 0;
getSize({1}) = 1;
|
static <V> java.util.List<V> |
invertList(java.util.List<V> sourceList)
invert list
|
static <V> boolean |
isEmpty(java.util.List<V> sourceList)
is null or its size is 0
isEmpty(null) = true;
isEmpty({}) = true;
isEmpty({1}) = false;
|
static <V> boolean |
isEquals(java.util.ArrayList<V> actual,
java.util.ArrayList<V> expected)
compare two list
isEquals(null, null) = true;
isEquals(new ArrayList<String>(), null) = false;
isEquals(null, new ArrayList<String>()) = false;
isEquals(new ArrayList<String>(), new ArrayList<String>()) = true;
|
static java.lang.String |
join(java.util.List<java.lang.String> list)
join list to string, separator is ","
join(null) = "";
join({}) = "";
join({a,b}) = "a,b";
|
static java.lang.String |
join(java.util.List<java.lang.String> list,
char separator)
join list to string
join(null, '#') = "";
join({}, '#') = "";
join({a,b,c}, ' ') = "abc";
join({a,b,c}, '#') = "a#b#c";
|
static java.lang.String |
join(java.util.List<java.lang.String> list,
java.lang.String separator)
join list to string. if separator is null, use
DEFAULT_JOIN_SEPARATOR
join(null, "#") = "";
join({}, "#$") = "";
join({a,b,c}, null) = "a,b,c";
join({a,b,c}, "") = "abc";
join({a,b,c}, "#") = "a#b#c";
join({a,b,c}, "#$") = "a#$b#$c";
|
public static final java.lang.String DEFAULT_JOIN_SEPARATOR
public static <V> int getSize(java.util.List<V> sourceList)
getSize(null) = 0; getSize({}) = 0; getSize({1}) = 1;
V
- sourceList
- List.size()
.public static <V> boolean isEmpty(java.util.List<V> sourceList)
isEmpty(null) = true; isEmpty({}) = true; isEmpty({1}) = false;
V
- sourceList
- public static <V> boolean isEquals(java.util.ArrayList<V> actual, java.util.ArrayList<V> expected)
isEquals(null, null) = true; isEquals(new ArrayList<String>(), null) = false; isEquals(null, new ArrayList<String>()) = false; isEquals(new ArrayList<String>(), new ArrayList<String>()) = true;
V
- actual
- expected
- public static java.lang.String join(java.util.List<java.lang.String> list)
join(null) = ""; join({}) = ""; join({a,b}) = "a,b";
list
- public static java.lang.String join(java.util.List<java.lang.String> list, char separator)
join(null, '#') = ""; join({}, '#') = ""; join({a,b,c}, ' ') = "abc"; join({a,b,c}, '#') = "a#b#c";
list
- separator
- public static java.lang.String join(java.util.List<java.lang.String> list, java.lang.String separator)
DEFAULT_JOIN_SEPARATOR
join(null, "#") = ""; join({}, "#$") = ""; join({a,b,c}, null) = "a,b,c"; join({a,b,c}, "") = "abc"; join({a,b,c}, "#") = "a#b#c"; join({a,b,c}, "#$") = "a#$b#$c";
list
- separator
- public static <V> boolean addDistinctEntry(java.util.List<V> sourceList, V entry)
V
- sourceList
- entry
- public static <V> int addDistinctList(java.util.List<V> sourceList, java.util.List<V> entryList)
V
- sourceList
- entryList
- public static <V> int distinctList(java.util.List<V> sourceList)
V
- sourceList
- public static <V> boolean addListNotNullValue(java.util.List<V> sourceList, V value)
sourceList
- value
- List.add(Object)
public static <V> V getLast(java.util.List<V> sourceList, V value)
ArrayUtils#getLast(Object[], Object, Object, boolean)} defaultValue is null, isCircle is true
public static <V> V getNext(java.util.List<V> sourceList, V value)
ArrayUtils#getNext(Object[], Object, Object, boolean)} defaultValue is null, isCircle is true
public static <V> java.util.List<V> invertList(java.util.List<V> sourceList)
V
- sourceList
-