Class XCollections

java.lang.Object
org.openxava.util.XCollections

public class XCollections extends Object
Utilities to work with collections, enumerations and iterators.

Author:
Javier Paniza
  • Constructor Details

    • XCollections

      public XCollections()
  • Method Details

    • last

      public static Object last(Collection collection)
      Returns the last element of sent collection.

      Parameters:
      collection - Can be null
      Returns:
      Last element, or null if collection is null or empty.
    • add

      public static void add(Collection collection, Enumeration toAdd)
      Adds elements from the enumeration to the collection.

      Parameters:
      collection - Not null
      toAdd - If null no elements are added.
    • println

      public static void println(Collection c)
      Print in standard output the collection elements.

      Util to debug.

      Parameters:
      c - Can be null.
    • println

      public static void println(Iterator it)
      Print in standard output the elements by it iterate.

      Util to debug.

      Parameters:
      c - Can be null.
    • toCollection

      public static Collection toCollection(Enumeration e)
      Returns a collection from a enumeration.

      Parameters:
      e - If null then returns a empty collection.
      Returns:
      Not null.
    • toList

      public static List toList(Iterable it)
      Returns a List from an Iterable.

      Parameters:
      it - If null then returns a empty list.
      Returns:
      Not null.
      Since:
      5.6.1
    • toStringArray

      public static String[] toStringArray(Collection c)
      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

      public static void move(List list, int from, int to)
      Since:
      5.2
    • isEmptyOrZero

      public static boolean isEmptyOrZero(Collection values)
      It's empty if is null, without elements, with null elements or elements with neutral value (empty strings, collections, nulls or zeroes). Mirrors Maps.isEmptyOrZero(Map) semantics for collections. Numeric values with value 0 are considered empty.
      Parameters:
      values - Can be null.
      Since:
      7.6