Package com.inductiveautomation.rm.base
Class RMListUtils
java.lang.Object
com.inductiveautomation.rm.base.RMListUtils
Utility methods for use with Java.util.List.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>
Adds an object to the given list and returns list (creates list if missing).static <T> List<T>
addAllUnique
(List<T> aList, int anIndex, T... theObjects) Adds all object from second list to first list (creates first list if missing).static <T> List<T>
addAllUnique
(List<T> aList, List<T> theObjects) Adds all object from second list to first list (creates first list if missing).static <T> List<T>
addAllUnique
(List<T> aList, T... theObjects) Adds all object from second list to first list (creates first list if missing).static <T> List<T>
addAllUniqueId
(List<T> aList, List<T> theObjects) Adds all object from second list to first list (creates first list if missing).static <T> List<T>
addAllUniqueId
(List<T> aList, T... theObjects) Adds all object from second list to first list (creates first list if missing).static <T> List<T>
Adds an object to the given list if object is absent (creates list if missing).static <T> List<T>
addUniqueId
(List<T> aList, T anObj) Adds an object to the given list if identical object is missing (creates list if missing).static <T> int
binarySearch
(List<? extends Comparable<? super T>> aList, T aKey) Returns the result of binary search, but always returns insert index.static <T> List<T>
Returns a copy of the given list.static <T> List<T>
Returns a copy of the given list with copies of all its items (recursively).static boolean
Returns whether list contains given object (accepts null list).static boolean
containsId
(List aList, Object anObj) Returns whether list contains identical 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 boolean
Returns whether lists have same objects in them.static void
Filters a given list in place with the given key chain string.static <T> T
Returns the object at the given index (returns null object for null list or invalid index).static List
getFilteredList
(List aList, String aKeyChain) Returns a filtered list (copy with given key chain string.static Object
getFirstLeaf
(List aList) Returns the first non-list object in the given list hierarchy, recursing if a list is found.static int[]
getIndexesId
(List aList, List aSubList) Returns an array of indexes for given list and given objects in list.static <T> T
Returns the last object in the given list.static <T> T
getMatch
(Collection<T> aCollection, String aKeyChain, Object aValue) Returns the matching object for this given key value.static <T> List<T>
getMatches
(Collection<T> aCollection, String aKeyChain, Object aValue) Returns the matching object for this given key value.static int
getMatchIndex
(List aList, String aKeyChain, Object aValue) Returns the matching index for this given key value.static int
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 aList, int anIndex) Moves the object at the given index to the front of the list.static void
moveToFront
(List aList, Object anObj) Move the given object to the front of the list.static <T> List<T>
newArrayList
(int aCapacity, T anObj) Creates a new array list with given object and capacity.static <T> List<T>
newArrayList
(int aCapacity, T... theObjects) Creates a new array list with given objects and capacity.static <T> List<T>
newArrayList
(T anObj) Creates a new array list with given object.static <T> List<T>
newArrayList
(T... theObjects) Creates a new array list with given objects.static <T> List<T>
newList
(T... objects) Creates a new list containing the objects in the object array.static <T> Vector<T>
newVector
(T... objects) 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 boolean
Removes given object from given list (accepts null list).static int
Removes the object identical to the given object from list.static <T> T
removeLast
(List<T> 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 <T> T[]
Returns an array of object of given class.static <T> List<T>
Converts an iterable to list.static <T> List<T>
toList
(Enumeration<T> anEnumeration) Converts an enumeration to a 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 whether list contains given object (accepts null list). -
containsId
Returns whether list contains identical given object (accepts null list). -
indexOfId
Returns index of identical given object in given list. -
getIndexesId
Returns an array of indexes for given list and given objects in list. -
add
Adds an object to the given list and returns list (creates list if missing). -
addUnique
Adds an object to the given list if object is absent (creates list if missing). -
addUniqueId
Adds an object to the given list if identical object is missing (creates list if missing). -
addAllUnique
Adds all object from second list to first list (creates first list if missing). -
addAllUniqueId
Adds all object from second list to first list (creates first list if missing). -
addAllUnique
Adds all object from second list to first list (creates first list if missing). -
addAllUnique
Adds all object from second list to first list (creates first list if missing). -
addAllUniqueId
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. -
removeId
Removes the object identical to the given object from list. -
binarySearch
Returns the result of binary search, but always returns insert index. -
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. -
toArray
Returns an array of object of given class. -
newArrayList
Creates a new array list with given object. -
newArrayList
Creates a new array list with given object and capacity. -
newArrayList
Creates a new array list with given objects. -
newArrayList
Creates a new array list with given objects and capacity. -
newList
Creates a new list containing the objects in the object array. -
newVector
Creates a new vector for the given array of objects. -
toList
Converts an iterable to list. -
toList
Converts an enumeration to a list. -
xor
Adds object from list 2 to list 1, unless they are already present (then removes them). -
getMatch
Returns the matching object for this given key value. -
getMatches
Returns the matching object for this given key value. -
getMatchIndex
Returns the matching index for this given key value. -
filter
Filters a given list in place with the given key chain string. -
getFilteredList
Returns a filtered list (copy with given key chain string. -
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. -
equalsId
Returns whether lists have same objects in them. -
clone
Returns a copy of the given list. -
cloneDeep
Returns a copy of the given list with copies of all its items (recursively).
-