Class ListUtils
- java.lang.Object
-
- com.googlecode.wicket.jquery.core.utils.ListUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<T>contains(String search, List<T> list)Returns a sub list of items of type T having their textual representation (toString()) containing the search criteria
The max size of the sub list isMAXstatic <T> List<T>contains(String search, List<T> list, int max)Returns a sub list of items of type T having their textual representation (toString()) containing the search criteriastatic voidempty(List<?> list)Empty aListstatic List<String>exclude(List<String> list, String... items)Excludes items from aListand return a newListstatic List<String>exclude(List<String> list, List<String> items)Excludes items from aListand return a newListstatic <T> TfromHash(int hash, List<T> list)Gets the list-item matching the given hash against the liststatic intindexOf(int hash, List<?> list)Gets the index of the item occurrence matching the specified hashcode.static booleanisEmpty(List<StringValue> list)Indicates whether the list isnullor emptystatic <T> voidmove(T item, int index, List<T> list)Utility method to move a list-item at a new position in the specified list
This method will use the hashcode of the list-item to retrieve it against the list.static intrandom(int bound)Returns a pseudo-randomintvalue between 0 (inclusive) and the specified bound (exclusive)static doublerandom(int min, int max)Returns a pseudo-randomdoublevalue between the minimum (inclusive) and the maximum bound (exclusive)static <T> Trandom(List<T> list)Gets a random object from the suppliedListstatic <T> Trandom(T[] array)Gets a random object from the supplied arraystatic <T> List<T>startsWith(String search, List<T> list)Returns a sub list of items of type T having their textual representation (toString()) starting with the search criteria
The max size of the sub list isMAXstatic <T> List<T>startsWith(String search, List<T> list, int max)Returns a sub list of items of type T having their textual representation (toString()) starting with the search criteriastatic List<String>toStringList(List<StringValue> values)static List<String>toStringList(StringValue values)Converts aStringValueto a list ofString
-
-
-
Method Detail
-
random
public static int random(int bound)
Returns a pseudo-randomintvalue between 0 (inclusive) and the specified bound (exclusive)- Parameters:
bound- the maximum bound (exclusive)- Returns:
- a pseudo-random
int
-
random
public static <T> T random(T[] array)
Gets a random object from the supplied array- Type Parameters:
T- the object type- Parameters:
array- the array- Returns:
nullif the supplied array is empty
-
random
public static <T> T random(List<T> list)
Gets a random object from the suppliedList- Type Parameters:
T- the object type- Parameters:
list- theList- Returns:
nullif the supplied list is empty
-
random
public static double random(int min, int max)Returns a pseudo-randomdoublevalue between the minimum (inclusive) and the maximum bound (exclusive)- Parameters:
min- the minimum bound (inclusive)max- the maximum bound (exclusive)- Returns:
- a pseudo-random
double
-
fromHash
public static <T> T fromHash(int hash, List<T> list)Gets the list-item matching the given hash against the list- Type Parameters:
T- the object type- Parameters:
hash- the hashcode to matchlist- theListto search in- Returns:
- the list-item or
nullif not found
-
indexOf
public static int indexOf(int hash, List<?> list)Gets the index of the item occurrence matching the specified hashcode.- Parameters:
list- theListhash- the hashcode to match- Returns:
- the index of the item matching the hashcode or -1 if not found
-
move
public static <T> void move(T item, int index, List<T> list)Utility method to move a list-item at a new position in the specified list
This method will use the hashcode of the list-item to retrieve it against the list.- Type Parameters:
T- the object type- Parameters:
list- theListitem- the itemindex- the position to move to
-
contains
public static <T> List<T> contains(String search, List<T> list)
Returns a sub list of items of type T having their textual representation (toString()) containing the search criteria
The max size of the sub list isMAX- Type Parameters:
T- the type- Parameters:
search- search criterialist- reference list- Returns:
- the sub list
-
contains
public static <T> List<T> contains(String search, List<T> list, int max)
Returns a sub list of items of type T having their textual representation (toString()) containing the search criteria- Type Parameters:
T- the type- Parameters:
search- search criterialist- reference listmax- max size of the sub list to be returned- Returns:
- the sub list
-
startsWith
public static <T> List<T> startsWith(String search, List<T> list)
Returns a sub list of items of type T having their textual representation (toString()) starting with the search criteria
The max size of the sub list isMAX- Type Parameters:
T- the type- Parameters:
search- search criterialist- reference list- Returns:
- the sub list
-
startsWith
public static <T> List<T> startsWith(String search, List<T> list, int max)
Returns a sub list of items of type T having their textual representation (toString()) starting with the search criteria- Type Parameters:
T- the type- Parameters:
search- search criterialist- reference listmax- max size of the sub list to be returned- Returns:
- the sub list
-
exclude
public static List<String> exclude(List<String> list, String... items)
Excludes items from aListand return a newList- Parameters:
list- the originalListitems- items to remove- Returns:
- a new
Listwithout excluded items
-
exclude
public static List<String> exclude(List<String> list, List<String> items)
Excludes items from aListand return a newList- Parameters:
list- the originalListitems- items to remove- Returns:
- a new
Listwithout excluded items
-
isEmpty
public static boolean isEmpty(List<StringValue> list)
Indicates whether the list isnullor empty- Parameters:
list-- Returns:
trueif the list isnullor empty
-
toStringList
public static List<String> toStringList(StringValue values)
Converts aStringValueto a list ofString- Parameters:
value- theStringValue- Returns:
- a list of
String
-
toStringList
public static List<String> toStringList(List<StringValue> values)
- Parameters:
value- the list ofStringValues- Returns:
- a list of
String
-
-