Class ObjectUtils

java.lang.Object
org.eclipse.nebula.widgets.nattable.util.ObjectUtils

public final class ObjectUtils extends Object
  • Method Details

    • asCollection

      public static <T> Collection<T> asCollection(Iterator<T> iterator)
      Transfers the given iterator to an unmodifiable collection.
      Type Parameters:
      T - The type of the objects contained in the iterator.
      Parameters:
      iterator - The iterator to transfer.
      Returns:
      Contents of the iterator as an unmodifiable Collection.
    • asList

      public static <T> List<T> asList(Collection<T> collection)
    • asIntArray

      public static int[] asIntArray(Collection<Integer> collection)
    • asOrderedCollection

      public static <T> Collection<T> asOrderedCollection(Iterator<T> iterator, Comparator<T> comparator)
      Transfers the given iterator into an unmodifiable ordered collection based on the given comparator.
      Type Parameters:
      T - The type of the objects contained in the iterator.
      Parameters:
      iterator - The iterator to transfer.
      comparator - The comparator to order the collection.
      Returns:
      Contents of the iterator as an unmodifiable ordered Collection.
    • toString

      public static <T> String toString(Collection<T> collection)
    • toString

      public static <T> String toString(T[] array)
    • isEmpty

      public static <T> boolean isEmpty(Collection<T> collection)
      Type Parameters:
      T - The type of objects in the collection.
      Parameters:
      collection - The collection to check.
      Returns:
      true if the given collection is null or empty.
    • isEmpty

      public static boolean isEmpty(String string)
      Parameters:
      string - The string to check.
      Returns:
      true if the given string is null or empty.
    • isNotEmpty

      public static boolean isNotEmpty(String string)
      Parameters:
      string - The string to check.
      Returns:
      true if the given string is not null and not empty.
    • isNotEmpty

      public static <T> boolean isNotEmpty(Collection<T> collection)
      Type Parameters:
      T - The type of objects in the collection.
      Parameters:
      collection - The collection to check.
      Returns:
      true if the given collection is not null and not empty.
    • isNull

      public static boolean isNull(Object object)
      Parameters:
      object - The object to check.
      Returns:
      true if the given object reference is null.
    • isNotNull

      public static boolean isNotNull(Object object)
      Parameters:
      object - The object to check.
      Returns:
      true if the given object reference is not null.
    • getRandomDate

      public static Date getRandomDate()
      Returns:
      a random Date
    • getRandomNumber

      public static int getRandomNumber()
      Returns:
      4 digit random Integer number
    • getRandomNumber

      public static int getRandomNumber(int max)
      Parameters:
      max - the upper bound (exclusive)
      Returns:
      random Integer number between 0 and parameter max
    • getLastElement

      public static <T> T getLastElement(List<T> list)
    • getFirstElement

      public static <T> T getFirstElement(List<T> list)
    • collectionsEqual

      public static boolean collectionsEqual(Collection c1, Collection c2)
      Checks if the passed collections are equal or not. Checks for content equality and does not take the order of values in the collection into account.
      Parameters:
      c1 - The first collection.
      c2 - The second collection.
      Returns:
      true if the passed collections contain the same values even in different order, false if the collections do not contain the same values.
      Since:
      2.1