Class RMListUtils

java.lang.Object
com.reportmill.base.RMListUtils

public class RMListUtils extends Object
Utility methods for use with Java.util.List.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List
    add(List aList, Object anObj)
    Adds an object to the given list and returns list (creates list if missing).
    static List
    addAll(List l1, List l2)
    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
    Adds an object to the given list if identical object is missing (creates list if missing).
    static List
    clone(List aList)
    Returns a copy of the given list.
    static List
    cloneDeep(List aList)
    Returns a copy of the given list with copies of all its items (recursively).
    static boolean
    contains(List aList, Object anObj)
    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
    get(List aList, int anIndex)
    Returns the object at the given index (returns null object for null list or invalid index).
    static Object
    Returns the first non-list object in the given list hierarchy, recursing if a list is found.
    static Object
    getLast(List aList)
    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
    move(List aList, int anIndex1, int anIndex2)
    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
    Move the given object to the front of the list.
    static List
    newList(Object anObj)
    Creates a new list containing the given object.
    static List
    newList(Object[] objs)
    Creates a new list containing the objects in the object array.
    static Vector
    Creates a new Vector for the given object.
    static Vector
    newVector(Object[] objs)
    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
    remove(List aList, int start, int end)
    Removes range of objects from given list (from start to end, not including end).
    static void
    remove(List aList, Object anObj)
    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
    Removes the last object from given list.
    static List
    reverse(List aList)
    Reverses the items in the given list.
    static int
    size(List aList)
    Returns the size of a list (accepts null list).
    static void
    xor(List l1, List l2)
    Adds object from list 2 to list 1, unless they are already present (then removes them).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RMListUtils

      public RMListUtils()
  • Method Details

    • size

      public static int size(List aList)
      Returns the size of a list (accepts null list).
    • get

      public static Object get(List aList, int anIndex)
      Returns the object at the given index (returns null object for null list or invalid index).
    • getLast

      public static Object getLast(List aList)
      Returns the last object in the given list.
    • contains

      public static boolean contains(List aList, Object anObj)
      Returns whehter list contains given object (accepts null list).
    • containsIdentical

      public static boolean containsIdentical(List aList, Object anObj)
      Returns whehter list contains indentical given object (accepts null list).
    • indexOfIdentical

      public static int indexOfIdentical(List aList, Object anObj)
      Returns index of identical given object in given list.
    • add

      public static List add(List aList, Object anObj)
      Adds an object to the given list and returns list (creates list if missing).
    • addIfAbsent

      public static List addIfAbsent(List aList, Object anObj)
      Adds an object to the given list if object is absent (creates list if missing).
    • addIfAbsentIdentical

      public static List addIfAbsentIdentical(List aList, Object anObj)
      Adds an object to the given list if identical object is missing (creates list if missing).
    • addAll

      public static List addAll(List l1, List l2)
      Adds all object from second list to first list (creates first list if missing).
    • remove

      public static void remove(List aList, Object anObj)
      Removes given object from given list (accepts null list).
    • remove

      public static void remove(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(List aList)
      Removes the last object from given list.
    • removeIdentical

      public static void removeIdentical(List aList, Object anObj)
      Removes the object identical to the given object from list.
    • removeAllIdentical

      public static void removeAllIdentical(List aList, List bList)
      Removes from aList all objects that are common to both lists.
    • move

      public static void move(List aList, int anIndex1, int anIndex2)
      Moves the object at index 1 to index 2.
    • reverse

      public static List reverse(List aList)
      Reverses the items in the given list.
    • getFirstLeaf

      public static Object getFirstLeaf(List aList)
      Returns the first non-list object in the given list hierarchy, recursing if a list is found.
    • objectsAtLevel

      public static List objectsAtLevel(List aList, int aLevel)
      Returns the objects at a given level in the given list hierarchy.
    • countAtLevel

      public static int countAtLevel(List aList, int aLevel)
      Returns the number of objects at a given level in the given list hierarchy.
    • joinStrings

      public static String joinStrings(List aList, String aString)
      Returns a string by concatenating strings in given list separated by given string.
    • newList

      public static List newList(Object anObj)
      Creates a new list containing the given object.
    • newList

      public static List newList(Object[] objs)
      Creates a new list containing the objects in the object array.
    • newVector

      public static Vector newVector(Object o)
      Creates a new Vector for the given object.
    • newVector

      public static Vector newVector(Object[] objs)
      Creates a new vector for the given array of objects.
    • xor

      public static void xor(List l1, List l2)
      Adds object from list 2 to list 1, unless they are already present (then removes them).
    • objectsHaveSameClass

      public static boolean objectsHaveSameClass(List l)
      Returns whether objects in list all have same class.
    • moveToFront

      public static void moveToFront(List l, int i)
      Moves the object at the given index to the front of the list.
    • moveToFront

      public static void moveToFront(List l, Object o)
      Move the given object to the front of the list.
    • clone

      public static List clone(List aList)
      Returns a copy of the given list.
    • cloneDeep

      public static List cloneDeep(List aList)
      Returns a copy of the given list with copies of all its items (recursively).