Package org.openxava.util
Class XCollections
java.lang.Object
org.openxava.util.XCollections
Utilities to work with collections, enumerations and iterators.
- Author:
- Javier Paniza
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadd(Collection collection, Enumeration toAdd) Adds elements from the enumeration to the collection.static booleanisEmptyOrZero(Collection values) It's empty if is null, without elements, with null elements or elements with neutral value (empty strings, collections, nulls or zeroes).static Objectlast(Collection collection) Returns the last element of sent collection.static voidstatic voidPrint in standard output the collection elements.static voidPrint in standard output the elements by it iterate.static CollectionReturns a collection from a enumeration.static ListReturns a List from an Iterable.static String[]Returns a String [] from a collection of Strings.
-
Constructor Details
-
XCollections
public XCollections()
-
-
Method Details
-
last
Returns the last element of sent collection.- Parameters:
collection- Can be null- Returns:
- Last element, or null if collection is null or empty.
-
add
Adds elements from the enumeration to the collection.- Parameters:
collection- Not nulltoAdd- If null no elements are added.
-
println
Print in standard output the collection elements.Util to debug.
- Parameters:
c- Can be null.
-
println
Print in standard output the elements by it iterate.Util to debug.
- Parameters:
c- Can be null.
-
toCollection
Returns a collection from a enumeration.- Parameters:
e- If null then returns a empty collection.- Returns:
- Not null.
-
toList
Returns a List from an Iterable.- Parameters:
it- If null then returns a empty list.- Returns:
- Not null.
- Since:
- 5.6.1
-
toStringArray
Returns a String [] from a collection of Strings.- Parameters:
c- Elements must be of type String. If null then returns a empty array.- Returns:
- Not null.
-
move
- Since:
- 5.2
-
isEmptyOrZero
It's empty if is null, without elements, with null elements or elements with neutral value (empty strings, collections, nulls or zeroes). MirrorsMaps.isEmptyOrZero(Map)semantics for collections. Numeric values with value 0 are considered empty.- Parameters:
values- Can be null.- Since:
- 7.6
-