public class CollectionUtil
extends java.lang.Object
Constructor and Description |
---|
CollectionUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
applies(java.lang.String[] events,
java.lang.String event)
Checks to see if an event is applicable given an array of event names.
|
static <T> java.util.List<T> |
asList(java.lang.Iterable<T> in)
Converts an Iterable into a List that can be navigated in ways other than simple
iteration.
|
static java.util.List<java.lang.Object> |
asList(java.lang.Object in)
Converts an Object reference that is known to be an array into a List.
|
static java.lang.Object[] |
asObjectArray(java.lang.Object in)
Converts an Object reference that is known to be an array into an Object[].
|
static boolean |
contains(java.lang.Object[] arr,
java.lang.Object item)
Checks to see if an array contains an item.
|
static boolean |
empty(java.lang.String[] arr)
Checks to see if the array contains any values that are non-null non empty-string values.
|
public static boolean contains(java.lang.Object[] arr, java.lang.Object item)
arr
- the array to scan for the item.item
- the item to be looked forpublic static boolean empty(java.lang.String[] arr)
public static boolean applies(java.lang.String[] events, java.lang.String event)
Checks to see if an event is applicable given an array of event names. The array is
usually derived from the on attribute of one of the Stripes annotations
(e.g. ValidationMethod
). The array can
be composed of positive event names (e.g. {"foo", "bar"}) in which case the event
must be contained in the array, or negative event names (e.g. {"!splat", "!whee"}) in
which case the event must not be contained in the array.
Calling this method with a null or zero length array will always return true.
events
- an array containing event names or event names prefixed with bangsevent
- the event name to check for applicability given the arraypublic static java.lang.Object[] asObjectArray(java.lang.Object in)
in
- an array of Objects or primitivesjava.lang.IllegalArgumentException
- thrown if the in parameter is null or not an arraypublic static java.util.List<java.lang.Object> asList(java.lang.Object in)
Converts an Object reference that is known to be an array into a List. Semantically
very similar to Arrays.asList(Object[])
except that this method
can deal with arrays of primitives in the same manner as arrays as objects.
A new List is created of the same size as the array, and elements are copied from the array into the List. If elements are primitives then they are converted to the appropriate wrapper types in order to return a List.
in
- an array of Objects or primitives (null values are not allowed)java.lang.IllegalArgumentException
- thrown if the in parameter is null or not an arraypublic static <T> java.util.List<T> asList(java.lang.Iterable<T> in)
in
- an Iterable to serve as the source for a List? Copyright 2005-2006, Stripes Development Team.