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