Package com.reportmill.base
Class RMListUtils
java.lang.Object
com.reportmill.base.RMListUtils
Utility methods for use with Java.util.List.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List
Adds an object to the given list and returns list (creates list if missing).static List
Adds all object from second list to first list (creates first list if missing).static List
addIfAbsent
(List aList, Object anObj) Adds an object to the given list if object is absent (creates list if missing).static List
addIfAbsentIdentical
(List aList, Object anObj) Adds an object to the given list if identical object is missing (creates list if missing).static List
Returns a copy of the given list.static List
Returns a copy of the given list with copies of all its items (recursively).static boolean
Returns whehter list contains given object (accepts null list).static boolean
containsIdentical
(List aList, Object anObj) Returns whehter list contains indentical given object (accepts null list).static int
countAtLevel
(List aList, int aLevel) Returns the number of objects at a given level in the given list hierarchy.static Object
Returns the object at the given index (returns null object for null list or invalid index).static Object
getFirstLeaf
(List aList) Returns the first non-list object in the given list hierarchy, recursing if a list is found.static Object
Returns the last object in the given list.static int
indexOfIdentical
(List aList, Object anObj) Returns index of identical given object in given list.static String
joinStrings
(List aList, String aString) Returns a string by concatenating strings in given list separated by given string.static void
Moves the object at index 1 to index 2.static void
moveToFront
(List l, int i) Moves the object at the given index to the front of the list.static void
moveToFront
(List l, Object o) Move the given object to the front of the list.static List
Creates a new list containing the given object.static List
Creates a new list containing the objects in the object array.static Vector
Creates a new Vector for the given object.static Vector
Creates a new vector for the given array of objects.static List
objectsAtLevel
(List aList, int aLevel) Returns the objects at a given level in the given list hierarchy.static boolean
Returns whether objects in list all have same class.static void
Removes range of objects from given list (from start to end, not including end).static void
Removes given object from given list (accepts null list).static void
removeAllIdentical
(List aList, List bList) Removes from aList all objects that are common to both lists.static void
removeIdentical
(List aList, Object anObj) Removes the object identical to the given object from list.static void
removeLast
(List aList) Removes the last object from given list.static List
Reverses the items in the given list.static int
Returns the size of a list (accepts null list).static void
Adds object from list 2 to list 1, unless they are already present (then removes them).
-
Constructor Details
-
RMListUtils
public RMListUtils()
-
-
Method Details
-
size
Returns the size of a list (accepts null list). -
get
Returns the object at the given index (returns null object for null list or invalid index). -
getLast
Returns the last object in the given list. -
contains
Returns whehter list contains given object (accepts null list). -
containsIdentical
Returns whehter list contains indentical given object (accepts null list). -
indexOfIdentical
Returns index of identical given object in given list. -
add
Adds an object to the given list and returns list (creates list if missing). -
addIfAbsent
Adds an object to the given list if object is absent (creates list if missing). -
addIfAbsentIdentical
Adds an object to the given list if identical object is missing (creates list if missing). -
addAll
Adds all object from second list to first list (creates first list if missing). -
remove
Removes given object from given list (accepts null list). -
remove
Removes range of objects from given list (from start to end, not including end). -
removeLast
Removes the last object from given list. -
removeIdentical
Removes the object identical to the given object from list. -
removeAllIdentical
Removes from aList all objects that are common to both lists. -
move
Moves the object at index 1 to index 2. -
reverse
Reverses the items in the given list. -
getFirstLeaf
Returns the first non-list object in the given list hierarchy, recursing if a list is found. -
objectsAtLevel
Returns the objects at a given level in the given list hierarchy. -
countAtLevel
Returns the number of objects at a given level in the given list hierarchy. -
joinStrings
Returns a string by concatenating strings in given list separated by given string. -
newList
Creates a new list containing the given object. -
newList
Creates a new list containing the objects in the object array. -
newVector
Creates a new Vector for the given object. -
newVector
Creates a new vector for the given array of objects. -
xor
Adds object from list 2 to list 1, unless they are already present (then removes them). -
objectsHaveSameClass
Returns whether objects in list all have same class. -
moveToFront
Moves the object at the given index to the front of the list. -
moveToFront
Move the given object to the front of the list. -
clone
Returns a copy of the given list. -
cloneDeep
Returns a copy of the given list with copies of all its items (recursively).
-